summaryrefslogtreecommitdiffstats
path: root/ansible-server
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2023-06-14 17:35:20 -0400
committerDan Timoney <dtimoney@att.com>2023-06-14 17:35:20 -0400
commit080d79ed50f01191d36752df6e3b616df4ca695f (patch)
tree854c6f9d7635a42cbb285f7799ff8bb6c1384596 /ansible-server
parent1ba457702deae80530f57bcc9b44a62f53ab34ce (diff)
Convert scripts to python3
Convert python2 scripts to python3 Issue-ID: CCSDK-3906 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: I1435eb3381631a759866cc2e671cd350e12a031e
Diffstat (limited to 'ansible-server')
-rwxr-xr-xansible-server/src/main/ansible-server/UsersRestServer.py78
1 files changed, 39 insertions, 39 deletions
diff --git a/ansible-server/src/main/ansible-server/UsersRestServer.py b/ansible-server/src/main/ansible-server/UsersRestServer.py
index 5b664e40..d4566b88 100755
--- a/ansible-server/src/main/ansible-server/UsersRestServer.py
+++ b/ansible-server/src/main/ansible-server/UsersRestServer.py
@@ -157,8 +157,8 @@ def RunAnsible_Playbook (callback, Id, Inventory, Playbook, NodeList, TestRecord
f = open(Path + "/" + file, "r")
resultsData = f.read() # Not to pass vnf instance name
OutputP = json.loads(resultsData)
- Output['Output'] = OutputP
- cherrypy.log("Output = " + str(Output['Output']))
+ Output['Output'] = OutputP
+ cherrypy.log("Output = " + str(Output['Output']))
#Output['Output'][key] = f.read() # To pass vnf instance name
f.close()
@@ -341,7 +341,7 @@ class TestManager (object):
if True:
if not input_json['Id'] in TestRecord:
- # check if Id exists in previous run dirctory
+ # check if Id exists in previous run dirctory
# if so retun error
s_cmd = 'ls ' + ansible_temp + '/*_' + input_json['Id']
#if subprocess.check_output([s_cmd, ]):
@@ -359,7 +359,7 @@ class TestManager (object):
# cherrypy.log("EnvParameter object: " + i)
# cherrypy.log(" EnvParameter Value: " + EnvParameters[ i ])
- # Now get things out of EnvParameters
+ # Now get things out of EnvParameters
VNF_instance = None
VNF_instance = EnvParameters.get('vnf_instance')
@@ -392,42 +392,42 @@ class TestManager (object):
# Verify VNF_instance was passed in EnvParameters
if VNF_instance != None:
- cherrypy.log( "Request Decode: VnfInstance " + VNF_instance)
+ cherrypy.log( "Request Decode: VnfInstance " + VNF_instance)
else:
- cherrypy.log( "StatusCode: 107, StatusMessage: VNF_instance NOT PROVIDED" )
+ cherrypy.log( "StatusCode: 107, StatusMessage: VNF_instance NOT PROVIDED" )
return {"StatusCode": 107,
"StatusMessage": "VNF_instance NOT PROVIDED"}
if inventory_names != None:
- cherrypy.log( "Request Decode: Inventory Names " + inventory_names)
+ cherrypy.log( "Request Decode: Inventory Names " + inventory_names)
else:
- cherrypy.log( "Request Decode: Inventory Names " + "Not provided")
-
- cherrypy.log( "Request Decode: PlaybookName " + PlaybookName)
- PlayBookFunction = PlaybookName.rsplit("/",2)[1]
- PlayBookFile = PlayBookFunction + "/site.yml"
- cherrypy.log( "Request Decode: PlaybookFunction " + PlayBookFunction)
- cherrypy.log( "Request Decode: Playbook file " + PlayBookFile)
-
+ cherrypy.log( "Request Decode: Inventory Names " + "Not provided")
+
+ cherrypy.log( "Request Decode: PlaybookName " + PlaybookName)
+ PlayBookFunction = PlaybookName.rsplit("/",2)[1]
+ PlayBookFile = PlayBookFunction + "/site.yml"
+ cherrypy.log( "Request Decode: PlaybookFunction " + PlayBookFunction)
+ cherrypy.log( "Request Decode: Playbook file " + PlayBookFile)
+
BaseDir = ansible_path + "/" + PlaybookName.rsplit("/",1)[0]
CopyDir = ansible_path + "/" + PlaybookName.rsplit("/",2)[0]
- cherrypy.log( "Request Decode: Basedir " + BaseDir)
- cherrypy.log( "Request Decode: Copydir " + CopyDir)
-
+ cherrypy.log( "Request Decode: Basedir " + BaseDir)
+ cherrypy.log( "Request Decode: Copydir " + CopyDir)
+
PlaybookDir = ansible_temp + "/" + \
VNF_instance + "_" + str_uuid + "_" + str(Id)
- # AnsibleInv is the directory where the host file to be run exsists
+ # AnsibleInv is the directory where the host file to be run exsists
AnsibleInv = ansible_path + "/" + VnfType + "/latest/ansible/inventory/" + VNF_instance
ArchiveFlag = False
- # Create base run directory if it doesn't exist
+ # Create base run directory if it doesn't exist
if not os.path.exists(ansible_temp):
cherrypy.log( "Creating Base Run Directory: " + ansible_temp)
os.makedirs(ansible_temp)
- if not os.path.exists( CopyDir ):
+ if not os.path.exists( CopyDir ):
cherrypy.log("Playbook Not Found")
return {"StatusCode": 101,
"StatusMessage": "PLAYBOOK NOT FOUND"}
@@ -443,7 +443,7 @@ class TestManager (object):
cherrypy.log( "PlaybookDir: " + PlaybookDir)
cherrypy.log( "AnsibleInv: " + AnsibleInv)
- #location of host file
+ #location of host file
#HostFile = PlaybookDir + "/inventory/" + VNF_instance + "hosts"
#cherrypy.log("HostFile: " + HostFile)
@@ -467,14 +467,14 @@ class TestManager (object):
#AnsibleInvFail = False # ???
HaveNodeList = True
- ###############################################################################
- ##### Host file processing ###########################
- ##### 1. Use file delivered with playbook ###########################
- ##### 2. If HostNames + NodeList generate and use ###########################
- ##### 3. If HostNames = VM or NVF copy and use. ###########################
- ###############################################################################
+ ###############################################################################
+ ##### Host file processing ###########################
+ ##### 1. Use file delivered with playbook ###########################
+ ##### 2. If HostNames + NodeList generate and use ###########################
+ ##### 3. If HostNames = VM or NVF copy and use. ###########################
+ ###############################################################################
- #location of host file - Default
+ #location of host file - Default
HostFile = PlaybookDir + "/inventory/" + VNF_instance + "hosts"
cherrypy.log("HostFile: " + HostFile)
@@ -545,9 +545,9 @@ class TestManager (object):
if 'CallBack' in input_json:
callback_flag = input_json['CallBack']
- # if AnsibleServer is not set to 'na' don't send AnsibleServer in PENDING responce.
- if AnsibleServer != 'na':
- TestRecord[Id] = {'PlaybookName': PlaybookName,
+ # if AnsibleServer is not set to 'na' don't send AnsibleServer in PENDING responce.
+ if AnsibleServer != 'na':
+ TestRecord[Id] = {'PlaybookName': PlaybookName,
'Version': version,
'NodeList': NodeList,
'HostGroupList': hostgrouplist,
@@ -567,8 +567,8 @@ class TestManager (object):
'Output': {},
'Path': PlaybookDir,
'Mandatory': None}
- else:
- TestRecord[Id] = {'PlaybookName': PlaybookName,
+ else:
+ TestRecord[Id] = {'PlaybookName': PlaybookName,
'Version': version,
'NodeList': NodeList,
'HostGroupList': hostgrouplist,
@@ -601,7 +601,7 @@ class TestManager (object):
# Process playbook
- if os.path.exists( ansible_path + '/' + PlaybookName):
+ if os.path.exists( ansible_path + '/' + PlaybookName):
AnsiblePlaybookFail = False
if AnsiblePlaybookFail:
@@ -713,8 +713,8 @@ class TestManager (object):
cherrypy.log("Payload: " + str(input_data) + " Type " + input_data['Type'])
if 'LogRest' in input_data['Type']:
- sys.stdout.close()
- sys.stdout = open("/var/log/RestServer.log", "w")
+ sys.stdout.close()
+ sys.stdout = open("/var/log/RestServer.log", "w")
# Just a debug to dump any records
if 'GetStatus' in input_data['Type']:
@@ -885,7 +885,7 @@ class TestManager (object):
else:
playbooknametxt = "NA"
- # Add code to get other items not just output.log from files
+ # Add code to get other items not just output.log from files
if os.path.exists( rdir + "/log.file"):
cherrypy.log("Found log.file")
out_results = "NA:"
@@ -893,7 +893,7 @@ class TestManager (object):
line = f.readline()
while line :
- if "fatal" in line:
+ if "fatal" in line:
out_results = out_results + line
elif "RECAP" in line:
out_results = out_results + line
'n589' href='#n589'>589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979