aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-03-05 14:35:29 +0100
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-03-06 06:53:11 +0000
commit2ee028b0bd961c3b7c2aa797d6c4d4b24b867f91 (patch)
tree24a8f4ab7e0b51e303f2f78a903b43dbb36cb96a /test
parent23f22e8e8ca50c862d1cece31a0a87050685cdd7 (diff)
Fix Python linting issues in Python scripts
Fixed pylint issues for categories trailing-whitespace, trailing-newlines, syntax-error, unused-import. Change-Id: Iccbdb0c9538a6b8299c0517bafa1ec1be30f07cd Issue-ID: INT-1427 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test')
-rwxr-xr-xtest/hpa_automation/heat/hpa_automation.py18
-rwxr-xr-xtest/hpa_automation/tosca/hpa_automation.py55
-rwxr-xr-xtest/s3p/collector/get_resource_stats.py1
-rw-r--r--test/s3p/util/docker_util.py22
4 files changed, 46 insertions, 50 deletions
diff --git a/test/hpa_automation/heat/hpa_automation.py b/test/hpa_automation/heat/hpa_automation.py
index ab1d8d07f..5f90a3be3 100755
--- a/test/hpa_automation/heat/hpa_automation.py
+++ b/test/hpa_automation/heat/hpa_automation.py
@@ -463,25 +463,25 @@ create_customer(parameters)
add_customer_subscription(parameters)
vlm_output = create_vlm(parameters)
-print "vlm parameters={}".format(vlm_output)
+print("vlm parameters={}".format(vlm_output))
vsp_id = create_vsp(parameters, vlm_output)
-print "vsp id={}".format(vsp_id)
+print("vsp id={}".format(vsp_id))
vf_model_dict = create_vf_model(parameters, vsp_id)
-print "vf model parameters={}".format(vf_model_dict)
+print("vf model parameters={}".format(vf_model_dict))
vf_id = vf_model_dict["vf_id"]
vf_unique_id = vf_model_dict["vf_unique_id"]
service_model_list = create_service_model(parameters, vf_unique_id)
-print "service model parameters={}".format(service_model_list)
+print("service model parameters={}".format(service_model_list))
upload_policy_models(parameters)
add_policies(parameters)
#Create Service Instance
service_dict = create_service_instance(parameters, service_model_list)
-print "service instance parameters={}".format(service_dict)
+print("service instance parameters={}".format(service_dict))
service_model_uuid = service_dict["service_uuid"]
time.sleep(2)
db_dict = query_db(parameters, service_model_uuid, vf_id)
@@ -492,16 +492,16 @@ while True:
check_service_instance = os.popen("oclip service-instance-list -u {} -p {} -m {} |grep {}-{}".format(parameters["aai_username"], \
parameters["aai_password"], parameters["aai_url"], parameters["instance-name"], parameters["service_name"])).read()
if check_service_instance:
- print "service instance created successfully"
+ print("service instance created successfully")
#Create VNF Instance
vnf_dict = create_vnf(parameters, service_dict, db_dict, vf_model_dict)
time.sleep(10)
- print "vnf instance parameters={}".format(vnf_dict)
+ print("vnf instance parameters={}".format(vnf_dict))
break
- print "service instance create in progress"
+ print("service instance create in progress")
time.sleep(30)
#Preload VF module and create VF module
sdnc_preload(parameters, db_dict, service_dict)
create_vf_module(parameters, service_dict, vnf_dict, db_dict)
-print "Deployment complete!!!, check cloud to confirm that vf module has been created"
+print("Deployment complete!!!, check cloud to confirm that vf module has been created")
diff --git a/test/hpa_automation/tosca/hpa_automation.py b/test/hpa_automation/tosca/hpa_automation.py
index 86b51f562..93027237c 100755
--- a/test/hpa_automation/tosca/hpa_automation.py
+++ b/test/hpa_automation/tosca/hpa_automation.py
@@ -14,7 +14,6 @@
import json
import os
-import time
import argparse
import sys
import requests
@@ -287,7 +286,7 @@ def add_policy_models(parameters):
'OPERATOR=[<,<equal-sign,>,>equal-sign,equal-sign,!equal-sign,any,all,subset,], POLICYTYPE=[hpa,]', '""')
mycursor.execute(hpa_sql, hpa_val)
-
+
sql = "INSERT INTO microservicemodels (modelname, description, dependency, imported_by, \
attributes, ref_attributes, sub_attributes, version, annotation, enumValues, \
dataOrderInfo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
@@ -358,7 +357,7 @@ def add_policy_models(parameters):
mycursor.executemany(sql, val)
mydb.commit()
print(mycursor.rowcount, "was inserted.")
-
+
def add_policies(parameters):
#Loop through policy, put in resource_model_name and create policies
for policy in os.listdir(parameters["policy_directory"]):
@@ -394,30 +393,30 @@ def create_ns(parameters, csar_id):
ns = parameters["ns"]
ns_create_string = 'oclip vfc-nslcm-create -m {} -c {} -n {} -q {} -S {}'.format(parameters["vfc-url"], \
csar_id, ns.get("name"), parameters["customer_name"], parameters["service_name"])
- print ns_create_string
+ print(ns_create_string)
ns_create_out = (os.popen(ns_create_string)).read()
- print ns_create_out
+ print(ns_create_out)
ns_instance_id = (get_out_helper_2(ns_create_out))[4]
return ns_instance_id
def instantiate_ns(parameters, ns_instance_id):
ns_instantiate_string = 'oclip vfc-nslcm-instantiate -m {} -i {} -c {} -n {}'.format(parameters["vfc-url"], \
ns_instance_id, parameters["location"], parameters["sdc-controller-id"])
- print ns_instantiate_string
+ print(ns_instantiate_string)
ns_instantiate_out = (os.popen(ns_instantiate_string)).read()
return ns_instantiate_out
def terminate_ns(parameters, ns_instance_id):
ns_terminate_string = 'oclip vfc-nslcm-terminate -m {} -i {}'.format(parameters["vfc-url"], ns_instance_id)
- print ns_terminate_string
+ print(ns_terminate_string)
ns_terminate_out = (os.popen(ns_terminate_string)).read()
- print ns_terminate_out
+ print(ns_terminate_out)
return ns_terminate_out
def delete_ns(parameters, ns_instance_id):
ns_delete_string = 'oclip vfc-nslcm-delete -m {} -c {}'.format(parameters["vfc-url"], ns_instance_id)
- print ns_delete_string
+ print(ns_delete_string)
ns_delete_out = (os.popen(ns_delete_string)).read()
return ns_delete_out
@@ -426,7 +425,7 @@ def create_ns_package(parameters):
create_ns_string = 'oclip vfc-catalog-create-ns -m {} -c {} -e {}'.format(parameters["vfc-url"], \
ns.get("key"), ns.get("value"))
cmd_out = (os.popen(create_ns_string)).read()
- out_list = get_out_helper_2(cmd_out)
+ out_list = get_out_helper_2(cmd_out)
return out_list[4]
def create_vnf_package(parameters):
@@ -437,7 +436,7 @@ def create_vnf_package(parameters):
create_vnf_string = 'oclip vfc-catalog-create-vnf -m {} -c {} -e {}'.format(parameters["vfc-url"], \
vnf_values.get("key"), vnf_values.get("value"))
cmd_out = (os.popen(create_vnf_string)).read()
- out_list = get_out_helper_2(cmd_out)
+ out_list = get_out_helper_2(cmd_out)
outputs[vnf_key] = out_list[4]
return outputs
@@ -445,8 +444,8 @@ def create_vnf_package(parameters):
def upload_ns_package(parameters, ns_package_output):
ns = parameters["ns"]
ns_upload_string = '{}/api/nsd/v1/ns_descriptors/{}/nsd_content'.format(parameters["vfc-url"], ns_package_output)
- print ns_upload_string
- print ns.get("path")
+ print(ns_upload_string)
+ print(ns.get("path"))
resp = requests.put(ns_upload_string, files={'file': open(ns.get("path"), 'rb')})
return resp
@@ -496,30 +495,30 @@ register_vnfm(parameters)
# 5.1 upload csar file to catalog
# 5.2 FIXME:Because SDC internal API will change without notice, so I will maually design VNF and Service.
# SDC output data model is not align with VFC, we use an workaround method
-# We just do run time automation
+# We just do run time automation
ns_package_output = ""
if model == "sdc":
- print "use csar file is distributed by sdc"
+ print("use csar file is distributed by sdc")
# output = create_vlm(parameters)
# vsp_dict = create_vsp(parameters, output)
# vf_dict = create_vf_model(parameters, vsp_dict)
# service_model_list = create_service_model(parameters, vf_dict)
-
+
vnf_onboard_output = onboard_vnf(parameters)
- print vnf_onboard_output
+ print(vnf_onboard_output)
ns_out = onboard_ns(parameters)
- print ns_out
+ print(ns_out)
else:
- print "use csar file is uploaded by local"
+ print("use csar file is uploaded by local")
vnf_package_output = create_vnf_package(parameters)
- print vnf_package_output
+ print(vnf_package_output)
ns_package_output = create_ns_package(parameters)
- print ns_package_output
+ print(ns_package_output)
upload_vnf_out = upload_vnf_package(parameters, vnf_package_output)
- print upload_vnf_out
+ print(upload_vnf_out)
ns_out = upload_ns_package(parameters, ns_package_output)
- print ns_out
+ print(ns_out)
# 6.add_policies function not currently working, using curl commands
add_policy_models(parameters)
@@ -527,17 +526,17 @@ add_policies(parameters)
# 7. VFC part
ns_instance_id = create_ns(parameters, ns_out)
-print ns_instance_id
+print(ns_instance_id)
instantiate_ns_output = instantiate_ns(parameters, ns_instance_id)
-print instantiate_ns_output
+print(instantiate_ns_output)
#terminate and delete ns;
-#option args add the end of json file
+#option args add the end of json file
if sys.argv[3] == "terminate":
terminate_ns_output = terminate_ns(parameters, ns_instance_id)
- print terminate_ns_output
+ print(terminate_ns_output)
elif sys.argv[3] == "delete":
delete_ns_output = delete_ns(parameters, ns_instance_id)
- print delete_ns_output
+ print(delete_ns_output)
diff --git a/test/s3p/collector/get_resource_stats.py b/test/s3p/collector/get_resource_stats.py
index aca2514c8..db377a766 100755
--- a/test/s3p/collector/get_resource_stats.py
+++ b/test/s3p/collector/get_resource_stats.py
@@ -6,7 +6,6 @@ import datetime
import collections
import re
import tzlocal
-from decimal import Decimal
sys.path.append('../util')
import docker_util
diff --git a/test/s3p/util/docker_util.py b/test/s3p/util/docker_util.py
index a0e688199..021e48c98 100644
--- a/test/s3p/util/docker_util.py
+++ b/test/s3p/util/docker_util.py
@@ -22,7 +22,7 @@ def get_container_list(ip):
Args:
param1 (str): host ip
- Returns:
+ Returns:
list of containers in string
"""
@@ -35,7 +35,7 @@ def get_container_list(ip):
containers = []
if result == []:
error = ssh.stderr.readlines()
- print error
+ print(error)
else:
for line in result:
token = line.decode('ascii').strip()
@@ -47,12 +47,12 @@ def get_container_list(ip):
def get_container_volume_size(ip, container):
"""
Get container total volume usage
- Args:
+ Args:
param1 (str): host ip
param2 (str): container name
-
+
Returns:
- float number in GB if the container has volume(s), None otherwise
+ float number in GB if the container has volume(s), None otherwise
"""
cmd = ['ssh', '-i', 'onap_dev']
@@ -65,7 +65,7 @@ def get_container_volume_size(ip, container):
total = None
if result == []:
error = ssh.stderr.readlines()
- print error
+ print(error)
else:
data = json.loads(result[0])
for entry in data:
@@ -83,10 +83,10 @@ def get_container_volume_size(ip, container):
def get_volume_size(ip, volume):
"""
Get a volume size
- Args:
+ Args:
param1 (str): host ip
param2 (str): volume name
-
+
Returns:
float number in GB
"""
@@ -98,7 +98,7 @@ def get_volume_size(ip, volume):
p2 = subprocess.Popen(['grep', volume], stdin=p1.stdout,
stdout=subprocess.PIPE)
p1.stdout.close()
- (output, err) = p2.communicate()
+ (output, err) = p2.communicate() # pylint: disable=W0612
size = output.split()[2]
return convert_to_GB(size)
@@ -109,7 +109,7 @@ def convert_to_GB(s):
Args:
param1 (str): volume size with unit
- Returns:
+ Returns:
float number representing volume size in GB
"""
@@ -122,5 +122,3 @@ def convert_to_GB(s):
d = round(Decimal(float(re.sub('[^0-9\\.]', '', s))
/ 1000000.0), 1)
return d
-
-