Fix indentation and whitespace issues in Python scripts 08/103108/3
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Thu, 5 Mar 2020 09:28:03 +0000 (10:28 +0100)
committerMarco Platania <platania@research.att.com>
Thu, 5 Mar 2020 15:26:40 +0000 (15:26 +0000)
Reported by pylint.

Change-Id: I9d5ee152f3587bb2d7e8abee919e4ffe47d8ae85
Issue-ID: INT-1427
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
15 files changed:
S3Ptools/locustfile.py
test/hpa_automation/heat/insert_policy_models_heat.py
test/mocks/mass-pnf-sim/mass-pnf-sim.py
test/mocks/pnfsimulator/netconfsimulator/netconf/__init__.py
test/mocks/pnfsimulator/netconfsimulator/netconf/set-up-xmls.py
test/mocks/pnfsimulator/netconfsimulator/netconf/test_yang_loader_server.py
test/mocks/pnfsimulator/netconfsimulator/netconf/yang_loader_server.py
test/s3p/collector/get_resource_stats.py
test/s3p/generator/locustfile.py
test/security/check_for_ingress_and_nodeports.py
test/vcpe/preload.py
test/vcpe/soutils.py
test/vcpe/tests/test_imports.py
test/vcpe/vcpe.py
test/vcpe/vcpecommon.py

index 5fe5b37..91cd499 100644 (file)
@@ -1,15 +1,15 @@
 import random
 import string
 from locust import HttpLocust, TaskSet, task
+
 class UserBehavior(TaskSet):
     def on_start(self):
         """ on_start is called when a Locust start before any task is scheduled """
         self.init()
+
     def init(self):
         pass
+
     @task(1)
     def DCI(self):
         method = "POST"
@@ -20,7 +20,7 @@ class UserBehavior(TaskSet):
         print(data)
         response = self.client.request(method, url, headers=headers, data=data)
         print(response.json())
+
 class WebsiteUser(HttpLocust):
     task_set = UserBehavior
     host = "http://10.0.5.1:8080"
index 68a1d23..5497638 100644 (file)
@@ -1,13 +1,13 @@
 import mysql.connector
 import sys
-  
+
 mydb = mysql.connector.connect(
   host= sys.argv[1],
   user= sys.argv[2],
   passwd= sys.argv[3],
   database="onap_sdk",
 )
-  
+
 mycursor = mydb.cursor()
 
 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)"
@@ -22,9 +22,9 @@ val = [
   ('pciPolicy', 'Pci policy model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,resources=MANY-true,pciProperties=pciProperties_properties:MANY-true:description-null', '{"pciProperties_properties":{"pciOptimizationTimeConstraint":"string:defaultValue-null:required-false:MANY-false:description-null","pciOptimizationNwConstraint":"string:defaultValue-null:required-false:MANY-false:description-null","algoCategory":"string:defaultValue-null:required-false:MANY-false:description-null","pciOptmizationAlgoName":"string:defaultValue-null:required-false:MANY-false:description-null","pciOptimizationPriority":"string:defaultValue-null:required-false:MANY-false:description-null"}}', 'test1', 'olicyScope=matching-true, policyType=matching-true ', ' POLICYTYPE=[pciPolicy,]', '""'),
   ('subscriberPolicy', 'Subscriber Policy Model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false:description-null', 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,properties=properties_properties:MANY-false:description-type of a policy', '{"properties_properties":{"provStatus":"PROVSTATUS:defaultValue-null:required-true:MANY-false:description-null","subscriberName":"SUBSCRIBERNAME:defaultValue-null:required-true:MANY-false:description-null","subscriberRole":"SUBSCRIBERROLE:defaultValue-null:required-true:MANY-false:description-null"}}', 'test1', 'policyScope=matching-true, policyType=matching-true, properties=matching-true ', ' SUBSCRIBERNAME=[], SUBSCRIBERROLE=[], POLICYTYPE=[subscriberPolicy,], PROVSTATUS=[]', '""')
 ]
-  
+
 mycursor.executemany(sql, val)
-  
+
 mydb.commit()
-  
+
 print(mycursor.rowcount, "was inserted.")
index 353631d..98b66f2 100755 (executable)
@@ -76,9 +76,9 @@ if args.bootstrap and args.ipstart and args.urlves:
     start_port=2000
     ftps_pasv_port_start=8000
     ftps_pasv_port_num_of_ports=10
-    
+
     ftps_pasv_port_end=ftps_pasv_port_start + ftps_pasv_port_num_of_ports
-    
+
 
     for i in range(int(args.bootstrap)):
         print("PNF simulator instance: " + str(i) + ".")
@@ -97,13 +97,13 @@ if args.bootstrap and args.ipstart and args.urlves:
         IpFileServer = args.ipfileserver
         TypeFileServer = args.typefileserver
 
-        
+
         PortSftp=start_port +1
-        PortFtps=start_port +2 
+        PortFtps=start_port +2
         start_port +=2
         UrlFtps = str(ipaddress.ip_address(args.ipstart) + int(3 + (i * 16)))
         print("\tUrl Ftps: " + str(UrlFtps))
+
         UrlSftp = str(ipaddress.ip_address(args.ipstart) + int(4 + (i * 16)))
         print("\tUrl Sftp: " + str(UrlSftp))
 
@@ -138,7 +138,7 @@ if args.bootstrap and args.ipstart and args.urlves:
             composercmd,
             shell=True)
         print('Cloning:', completed.stdout)
-        
+
         ftps_pasv_port_start += ftps_pasv_port_num_of_ports + 1
         ftps_pasv_port_end += ftps_pasv_port_num_of_ports +1
 
@@ -202,23 +202,20 @@ if args.trigger:
             "; ./simulator.sh trigger-simulator",
             shell=True)
         print('Status:', completed.stdout)
-        
+
 if args.triggerstart and args.triggerend:
     print("Triggering VES sending by a range of simulators:")
-    
+
     for i in range(int(args.triggerstart), int(args.triggerend)+1):
         foldername = "pnf-sim-lw-" + str(i)
         print("Instance being processed:" + str(i))
-         
+
         completed = subprocess.run(
             'cd ' +
             foldername +
             "; ./simulator.sh trigger-simulator",
             shell=True)
         print('Status:', completed.stdout)
-         
-        
-
 else:
     print("No instruction was defined")
     sys.exit()
index 0f144c2..aa8b4f9 100644 (file)
@@ -7,9 +7,9 @@
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 #      http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
index cdc4e4f..2ec1cf2 100755 (executable)
@@ -9,9 +9,9 @@
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 #      http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,8 +29,8 @@ logging.basicConfig()
 logger = logging.getLogger()
 logger.setLevel(logging.INFO)
 
-# Placeholders definition - this needs to match placeholders in 
-# load_server_certs_xml_file and tls_listen_xml_file 
+# Placeholders definition - this needs to match placeholders in
+# load_server_certs_xml_file and tls_listen_xml_file
 SERVER_KEY_NAME = "SERVER_KEY_NAME"
 SERVER_CERT_NAME = "SERVER_CERT_NAME"
 SERVER_CERTIFICATE_HERE = "SERVER_CERTIFICATE_HERE"
index c5bd08d..a222087 100644 (file)
@@ -7,9 +7,9 @@
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 #      http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
index f414467..27d46ce 100644 (file)
@@ -7,9 +7,9 @@
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
-# 
+#
 #      http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
index 8ad22c5..aca2514 100755 (executable)
@@ -20,7 +20,7 @@ AAI2_IP = "10.0.1.2"
 SO_IP = "10.0.5.1"
 SDNC_IP = "10.0.7.1"
 
-def aai1(): 
+def aai1():
     containers = docker_util.get_container_list(AAI1_IP)
     run(AAI1_NAME, AAI1_IP, containers)
 
@@ -39,7 +39,7 @@ def sdnc():
 def run(component, ip, containers):
     cmd = ["ssh", "-i", "onap_dev"]
     cmd.append("ubuntu@" + ip)
-    cmd.append("sudo docker stats --no-stream") 
+    cmd.append("sudo docker stats --no-stream")
     for c in containers:
         cmd.append(c)
     ssh = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -80,7 +80,7 @@ def get_memory_number(s):
     return f
 
 file = open("resource.log", "w+")
-while True: 
+while True:
     so()
     sdnc()
     aai1()
index 63031cd..ca926b3 100644 (file)
@@ -26,7 +26,7 @@ class UserBehavior(TaskSet):
         self.init()
 
     def init(self):
-       pass
+        pass
 
     def myconverter(self, o):
         if isinstance(o, datetime.datetime):
@@ -36,7 +36,7 @@ class UserBehavior(TaskSet):
     def create_service(self):
        # Post a E2E service instantiation request to SO
         method = "POST"
-       url = self.base
+        url = self.base
        service_instance_name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
        data = self.service_creation_body % service_instance_name
 
index 8b3e84a..27066bf 100755 (executable)
@@ -79,7 +79,7 @@ def find_ingress_ports(v1):
     https_port = 0
     for item in svc.items:
         if item.metadata.name == K8S_INGRESS_NS:
-           for pinfo in item.spec.ports:
+            for pinfo in item.spec.ports:
                 if pinfo and pinfo.name == 'http':
                     http_port = pinfo.node_port
                 elif pinfo and pinfo.name == 'https':
@@ -263,4 +263,4 @@ if __name__ == "__main__":
     v1c = client.Configuration()
     if args.scan_nodeport: check_onap_ports()
     elif args.scan_ingress: check_onap_ingress()
-    else: onap_list_all()
\ No newline at end of file
+    else: onap_list_all()
index 08b34ec..6517fe5 100755 (executable)
@@ -102,9 +102,9 @@ class Preload:
         self.logger.info('Preloading network ' + network_role)
         self.logger.info('template_file:' + template_file)
         if 'networkgra' in template_file:
-              return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_network_gra_url)
+            return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_network_gra_url)
         else:
-              return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_network_url)
+            return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_network_url)
 
     def preload(self, template_file, replace_dict, url):
         self.logger.debug('tempalte_file:'+ template_file)
@@ -165,10 +165,10 @@ class Preload:
                         '${suffix}': name_suffix}
         replace_dict.update(common_dict)
         self.logger.info('Preloading VF Module ' + vfmodule_name)
-       if  gra_api_flag:
-             return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_gra_url)
+        if gra_api_flag:
+            return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_gra_url)
         else:
-             return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_vnf_url)
+            return self.preload(template_file, replace_dict, self.vcpecommon.sdnc_preload_vnf_url)
 
     def preload_all_networks(self, template_file, name_suffix):
         common_dict = {'${' + k + '}': v for k, v in self.vcpecommon.common_preload_config.items()}
index 8d2e56d..6310012 100755 (executable)
@@ -121,7 +121,7 @@ class SoUtils:
     def generate_vnf_or_network_request(self, req_type, instance_name, vnf_or_network_model, service_instance_id,
                                         service_model):
         if self.vcpecommon.gra_api_flag:
-               self.testApi = 'GR_API'
+            self.testApi = 'GR_API'
         req_details = {
             'modelInfo':  vnf_or_network_model,
             'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name,
@@ -139,7 +139,7 @@ class SoUtils:
     def generate_vfmodule_request(self, instance_name, vfmodule_model, service_instance_id,
                                         service_model, vnf_instance_id, vnf_model):
         if self.vcpecommon.gra_api_flag:
-               self.testApi = 'GR_API'
+            self.testApi = 'GR_API'
         req_details = {
             'modelInfo':  vfmodule_model,
             'cloudConfiguration': {"lcpCloudRegionId": self.vcpecommon.os_region_name,
index 4587495..728c293 100644 (file)
@@ -15,4 +15,4 @@ import vcpecommon
 # are included in setuptools configuration
 
 def test_imports():
-  pass
+    pass
index 9ecda81..aa924bc 100755 (executable)
@@ -137,11 +137,11 @@ def deploy_infra():
         vnf_template_file = vcpecommon.find_file(keyword_vnf, 'json', 'preload_templates')
         gra_template_file = vcpecommon.find_file(keyword_gra, 'json', 'preload_templates')
         if vcpecommon.gra_api_flag:
-             svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, gra_template_file, preload_dict,
-                                                        name_suffix, heatbridge)
+            svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, gra_template_file, preload_dict,
+                                                            name_suffix, heatbridge)
         else:
-             svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict,
-                                                        name_suffix, heatbridge)
+            svc_instance_uuid[keyword] = create_one_service(vcpecommon, csar_file, vnf_template_file, preload_dict,
+                                                            name_suffix, heatbridge)
         if not svc_instance_uuid[keyword]:
             sys.exit(1)
 
@@ -310,7 +310,7 @@ if __name__ == '__main__':
         init_so_sdnc()
     elif args.mode == 'infra':
         #if 'y' == raw_input('Ready to deploy infrastructure? y/n: ').lower():
-         deploy_infra()
+        deploy_infra()
     elif args.mode == 'customer':
         if 'y' == raw_input('Ready to deploy customer service? y/n: ').lower():
             deploy_custom_service()
index 932766f..8eeb68e 100755 (executable)
@@ -207,13 +207,13 @@ class VcpeCommon:
         # to conform to openstack cli client
         self.cloud = {}
         for k in os_cloud:
-             if isinstance(os_cloud[k],dict):
-                 for sub_k in os_cloud[k]:
-                     os_setting_name = '--os-' + sub_k.replace('_','-')
-                     self.cloud[os_setting_name] = os_cloud[k][sub_k]
-             else:
-                 os_setting_name = '--os-' + k.replace('_','-')
-                 self.cloud[os_setting_name] = os_cloud[k]
+            if isinstance(os_cloud[k],dict):
+                for sub_k in os_cloud[k]:
+                    os_setting_name = '--os-' + sub_k.replace('_','-')
+                    self.cloud[os_setting_name] = os_cloud[k][sub_k]
+            else:
+                os_setting_name = '--os-' + k.replace('_','-')
+                self.cloud[os_setting_name] = os_cloud[k]
 
     def heatbridge(self, openstack_stack_name, svc_instance_uuid):
         """