summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib
diff options
context:
space:
mode:
authoreschcam <cameron.scholes@est.tech>2023-06-19 17:39:10 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-06-20 10:14:27 +0000
commita622b7fe17a94698c1d242772d5d1b1d48761a29 (patch)
treee35dd9070a008a0c9b65494dc6094e44fe3a8f23 /openecomp-be/lib/openecomp-sdc-translator-lib
parentf845ac23cdd262b7624785283531952e38557deb (diff)
Migrate Python 2 files to Python 3
Issue-ID: SDC-4498 Signed-off-by: eschcam <cameron.scholes@est.tech> Change-Id: I6b55fcd799371dd209898607c90d5c348e242c36
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/call_home.py8
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/check_availability.py8
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/register_status.py30
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/wait_for_resources.py12
4 files changed, 30 insertions, 28 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/call_home.py b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/call_home.py
index 54f2a69c09..0b120983eb 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/call_home.py
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/call_home.py
@@ -6,7 +6,6 @@ from socket import getfqdn
from sys import platform
from time import sleep
-
PARSER = argparse.ArgumentParser()
PARSER.add_argument("manager_ip", help="The IPv4 Address where one can read the MaveriQConductor.")
PARSER.add_argument("--mockupfile", type=str, help="The path of the json mockupfile to use.")
@@ -43,7 +42,7 @@ def check_availability():
is_connected = False
while is_connected is False:
try:
- if requests.get(URL_AVAIL, headers={'Connection': 'close'}).status_code is 200:
+ if requests.get(URL_AVAIL, headers={'Connection': 'close'}).status_code == 200:
is_connected = True
sleep(2)
except requests.exceptions.ConnectionError:
@@ -90,8 +89,9 @@ def main():
# Perform any replacement needed.
json_data = multiple_replace(regex_dict, json_data)
- print json_data
+ print(json_data)
check_availability()
return post_request(p_json_data=json_data, p_headers=HEADERS)
-print main()
+
+print(main())
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/check_availability.py b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/check_availability.py
index e93b372f15..09098b23d0 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/check_availability.py
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/check_availability.py
@@ -15,20 +15,20 @@ PARSER.add_argument("ScribeIP", type=str,
help="The Stage the application is currently in")
ARGS = PARSER.parse_args()
-print "Begining check availability check!"
+print("Beginning check availability check!")
isConnected = False
while isConnected is False:
try:
sys.stdout.write('.')
sleep(2)
if requests.get(conductor_url.format(ARGS.ScribeIP),
- headers={'Connection': 'close'}).status_code is 200 and requests.get(
+ headers={'Connection': 'close'}).status_code == 200 and requests.get(
check_api.format(ARGS.ScribeIP,
headers={'Connection': 'close'}),
auth=requests.auth.HTTPBasicAuth(check_user,
- check_password)).status_code is 200:
+ check_password)).status_code == 200:
isConnected = True
except requests.exceptions.ConnectionError as e:
sleep(2)
-print 'Conductor and Scribe are ready!'
+print('Conductor and Scribe are ready!')
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/register_status.py b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/register_status.py
index 98adafaf2f..55be22daf5 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/register_status.py
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/register_status.py
@@ -12,7 +12,6 @@ from socket import getfqdn
import sys
from time import time
-
parser = argparse.ArgumentParser()
parser.add_argument("scribe_ip", type=str,
help="The IP where the Scribe can be reached.")
@@ -88,22 +87,24 @@ def build_add_json():
ADD_COMPONENT_BODY["OAM_IP"] = OAM_DIRECT_IP
for interface in netifaces.interfaces():
- ADD_COMPONENT_BODY["machineNetworkInterfaces"].append({"name": interface, "value": netifaces.ifaddresses(interface)[2][0]['addr']})
+ ADD_COMPONENT_BODY["machineNetworkInterfaces"].append(
+ {"name": interface, "value": netifaces.ifaddresses(interface)[2][0]['addr']})
- if PROBE_ID is not "":
- ADD_COMPONENT_BODY["machineID"] = REGION + '_' + TENANT + '_' +\
- CLUSTER_NAME + '_' + MACHINE_NAME + '_' + PROBE_ID
+ if PROBE_ID != "":
+ ADD_COMPONENT_BODY["machineID"] = REGION + '_' + TENANT + '_' + \
+ CLUSTER_NAME + '_' + MACHINE_NAME + '_' + PROBE_ID
else:
- ADD_COMPONENT_BODY["machineID"] = REGION + '_' + TENANT + '_' +\
- CLUSTER_NAME + '_' + MACHINE_NAME
+ ADD_COMPONENT_BODY["machineID"] = REGION + '_' + TENANT + '_' + \
+ CLUSTER_NAME + '_' + MACHINE_NAME
return ADD_COMPONENT_BODY
def send_postage(p_url, p_url_user, p_url_password, p_json_data):
json_header = {'Content-type': 'application/json'}
- request = requests.post(p_url, json.dumps(p_json_data), json_header, auth=requests.auth.HTTPBasicAuth(p_url_user, p_url_password))
- print request.status_code
- if (request.status_code != 200):
+ request = requests.post(p_url, json.dumps(p_json_data), json_header,
+ auth=requests.auth.HTTPBasicAuth(p_url_user, p_url_password))
+ print(request.status_code)
+ if request.status_code != 200:
sys.exit(1)
return request.status_code
@@ -118,9 +119,10 @@ def post_add_machine():
read_metadata()
return send_postage(add_machine_ip, user, password, build_add_json())
+
if args.stage is None and args.status is None and args.description is None:
- print "adding machine"
- print post_add_machine()
+ print("adding machine")
+ print(post_add_machine())
else:
- print "logging health"
- print post_health()
+ print("logging health")
+ print(post_health())
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/wait_for_resources.py b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/wait_for_resources.py
index 5d960d659e..5abf961f75 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/wait_for_resources.py
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/resources/mock/services/heattotosca/securityrulestoportconnection/securityRulesToPortGetResource/inputfiles/wait_for_resources.py
@@ -16,9 +16,9 @@ def parse_json_file(json_path):
def check_network_interfaces():
for interface in netifaces.interfaces():
- if(sys.platform != 'win32' or netifaces.ifaddresses(interface)[-1000][0]['addr'] != '00:00:00:00:00:00:00:e0'):
+ if sys.platform != 'win32' or netifaces.ifaddresses(interface)[-1000][0]['addr'] != '00:00:00:00:00:00:00:e0':
while 2 not in netifaces.ifaddresses(interface).keys() and 23 not in netifaces.ifaddresses(interface).keys():
- print "Still waiting for interface:", interface
+ print("Still waiting for interface:", interface)
time.sleep(TIME_INTERVAL)
@@ -29,7 +29,7 @@ def check_connectivity():
ping_str = "ping -n 1 "
while os.system(ping_str + component_ip) != 0:
- print "No connectivity to", component_ip, "waiting", TIME_INTERVAL, "seconds"
+ print("No connectivity to", component_ip, "waiting", TIME_INTERVAL, "seconds")
time.sleep(TIME_INTERVAL)
@@ -51,7 +51,7 @@ def check_cinder_mounts():
cinder_attached = os.popen("wmic diskdrive get DeviceID | find /i \"PHYSICALDRIVE\" | find /V \"0\" /C").read()
while (int(cinder_attached) < cinder_count) and (cinder_count != 0):
- print "Missing a cinder mount, waiting", TIME_INTERVAL, "seconds"
+ print("Missing a cinder mount, waiting", TIME_INTERVAL, "seconds")
time.sleep(TIME_INTERVAL)
if sys.platform.startswith('linux'):
@@ -62,7 +62,7 @@ def check_cinder_mounts():
"wmic diskdrive get DeviceID | find /i \"PHYSICALDRIVE\" | find /V \"0\" /C").read()
if int(cinder_attached) == cinder_count:
- print "All cinder are attached and ready to be formatted and mounted"
+ print("All cinder are attached and ready to be formatted and mounted")
def main():
@@ -72,7 +72,7 @@ def main():
if component_ip is not None:
check_connectivity()
- print "All resources are ready"
+ print("All resources are ready")
if __name__ == "__main__":