Remove logger as input parameter of functions in openstack_utils 21/17221/2
authorjose.lausuch <jose.lausuch@ericsson.com>
Wed, 20 Jul 2016 11:37:41 +0000 (13:37 +0200)
committerjose.lausuch <jose.lausuch@ericsson.com>
Wed, 20 Jul 2016 11:58:18 +0000 (13:58 +0200)
JIRA: FUNCTEST-376

Also some fixes to get rid of flake8 violations in onos-sfc

Change-Id: I52c2fd30a6b81af20ea779db2d73b9386524f7ce
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
testcases/Controllers/ONOS/Sfc/Sfc_fun.py
testcases/OpenStack/examples/create_instance_and_ip.py
testcases/OpenStack/rally/run_rally-cert.py
testcases/OpenStack/tempest/run_tempest.py
testcases/OpenStack/vPing/vPing_ssh.py
testcases/OpenStack/vPing/vPing_userdata.py
testcases/features/promise.py
testcases/features/sfc/sfc.py
utils/openstack_utils.py

index 28d83bb..b94eedc 100644 (file)
@@ -1,13 +1,14 @@
 """SFC functions."""
-import functest.utils.functest_logger as ft_logger
 import json
 from multiprocessing import Process
 from multiprocessing import Queue
-from pexpect import pxssh
+import os
 import re
-import requests
 import time
-import os
+
+import functest.utils.functest_logger as ft_logger
+from pexpect import pxssh
+import requests
 
 
 class Sfc_fun:
@@ -101,7 +102,8 @@ class Sfc_fun:
 
     def getToken(self):
         """Get the keystone token value from Openstack ."""
-        url = 'http://'+self.keystone_hostname+':5000/'+self.osver+'/tokens'
+        url = 'http://' + self.keystone_hostname + \
+            ':5000/' + self.osver + '/tokens'
         data = '{"auth": {"tenantName": "admin",  "passwordCredentials":\
                 { "username": "admin", "password": "console"}}}'
         headers = {"Accept": "application/json"}
@@ -126,7 +128,8 @@ class Sfc_fun:
             Dicdata['admin_state_up'] = self.admin_state_up
         Dicdata = {'network': Dicdata}
         data = json.dumps(Dicdata,  indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver+'/networks'
+        url = 'http://' + self.neutron_hostname + \
+            ':9696/' + self.osver + '/networks'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.post(url, headers=headers,  data=data)
@@ -155,7 +158,8 @@ class Sfc_fun:
 
         Dicdata = {'subnet': Dicdata}
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver+'/subnets'
+        url = 'http://' + self.neutron_hostname + \
+            ':9696/' + self.osver + '/subnets'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.post(url, headers=headers,  data=data)
@@ -177,7 +181,7 @@ class Sfc_fun:
             if self.net_id != '':
                 Dicdata['network_id'] = self.net_id
             if self.port != '':
-                Dicdata['name'] = "port"+str(x)
+                Dicdata['name'] = "port" + str(x)
             if self.admin_state_up != '':
                 Dicdata['admin_state_up'] = self.admin_state_up
             if self.security_groups != '':
@@ -187,7 +191,8 @@ class Sfc_fun:
 
             Dicdata = {'port': Dicdata}
             data = json.dumps(Dicdata, indent=4)
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver+'/ports'
+            url = 'http://' + self.neutron_hostname + \
+                ':9696/' + self.osver + '/ports'
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.post(url, headers=headers,  data=data)
@@ -207,7 +212,8 @@ class Sfc_fun:
 
     def createVm(self):
         """Creation of Instance, using  firewall image."""
-        url = 'http://'+self.glance_hostname+':9292/v2/images?name=TestSfcVm'
+        url = 'http://' + self.glance_hostname + \
+            ':9292/v2/images?name=TestSfcVm'
         headers = {"Accept": "application/json", "Content-Type": "application/\
                     octet-stream",  "X-Auth-Token": self.token_id}
         response = requests.get(url, headers=headers)
@@ -226,7 +232,7 @@ class Sfc_fun:
             org_nw_port = []
             org_nw_port.append({'port': self.port_num[y]})
             if self.vm_name != '':
-                Dicdata['name'] = "vm"+str(y)
+                Dicdata['name'] = "vm" + str(y)
             if self.imageRef != '':
                 Dicdata['imageRef'] = self.image_id
             if self.flavorRef != '':
@@ -240,8 +246,8 @@ class Sfc_fun:
             Dicdata = {'server': Dicdata}
             data = json.dumps(Dicdata, indent=4)
 
-            url = 'http://'+self.nova_hostname+':8774/v2.1/'+self.tenant_id + \
-                  '/servers'
+            url = ('http://' + self.nova_hostname + ':8774/v2.1/' +
+                   self.tenant_id + '/servers')
             headers = {"Accept": "application/json", "Content-Type":
                        "application/json", "X-Auth-Token": self.token_id}
             response = requests.post(url, headers=headers,  data=data)
@@ -264,7 +270,8 @@ class Sfc_fun:
         time.sleep(10)
         for y in range(0, 3):
             url = 'http://' + \
-                  self.nova_hostname+':8774/v2.1/servers/detail?name=vm'+str(y)
+                  self.nova_hostname + \
+                ':8774/v2.1/servers/detail?name=vm' + str(y)
             headers = {"Accept": "application/json",  "X-Auth-Token":
                        self.token_id}
             response = requests.get(url, headers=headers)
@@ -275,11 +282,11 @@ class Sfc_fun:
                 self.logger.debug(json1_data)
                 self.vm_active = json1_data['servers'][0]['status']
                 if (self.vm_active == "ACTIVE"):
-                    print ("\t\t\t\t\t\tVM"+str(y)+" is Active : "
-                           self.vm_active)
+                    print ("\t\t\t\t\t\tVM" + str(y) + " is Active : " +
+                           self.vm_active)
                 else:
-                    print ("\t\t\t\t\t\tVM"+str(y)+" is NOT Active : "
-                           self.vm_active)
+                    print ("\t\t\t\t\t\tVM" + str(y) + " is NOT Active : " +
+                           self.vm_active)
             else:
                 return(response.status_code)
         return(response.status_code)
@@ -295,18 +302,18 @@ class Sfc_fun:
                 egress = p
                 Dicdata['egress'] = self.port_num[egress]
             if self.port_pair_name != '':
-                Dicdata['name'] = "PP"+str(p)
+                Dicdata['name'] = "PP" + str(p)
 
             Dicdata = {'port_pair': Dicdata}
             data = json.dumps(Dicdata, indent=4)
 
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
                 '/sfc/port_pairs'
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.post(url, headers=headers,  data=data)
             if (response.status_code == 201):
-                print ("\t\t\t\tCreation of Port Pair PP"+str(p) +
+                print ("\t\t\t\tCreation of Port Pair PP" + str(p) +
                        " is successful")
             else:
                 return(response.status_code)
@@ -316,7 +323,7 @@ class Sfc_fun:
     def getPortPair(self):
         """Query the Portpair id value."""
         for p in range(0, 1):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
                   '/sfc/port_pairs?name=PP1'
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
@@ -339,19 +346,19 @@ class Sfc_fun:
             port_pair_list = []
             port_pair_list.append(self.port_pair_id[p])
             if self.port_group_name != '':
-                Dicdata['name'] = "PG"+str(p)
+                Dicdata['name'] = "PG" + str(p)
             if self.port_pair_id != '':
                 Dicdata['port_pairs'] = port_pair_list
 
             Dicdata = {'port_pair_group': Dicdata}
             data = json.dumps(Dicdata, indent=4)
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
                   '/sfc/port_pair_groups'
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.post(url, headers=headers,  data=data)
             if (response.status_code == 201):
-                print ("\t\t\t\tCreation of Port Group PG"+str(p) +
+                print ("\t\t\t\tCreation of Port Group PG" + str(p) +
                        "is successful")
             else:
                 return(response.status_code)
@@ -361,8 +368,8 @@ class Sfc_fun:
     def getPortGroup(self):
         """Query the PortGroup id."""
         for p in range(0, 1):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/sfc/port_pair_groups?name=PG'+str(p)
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/sfc/port_pair_groups?name=PG' + str(p)
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.get(url, headers=headers)
@@ -393,7 +400,7 @@ class Sfc_fun:
 
         Dicdata = {'flow_classifier': Dicdata}
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
               '/sfc/flow_classifiers'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
@@ -423,7 +430,7 @@ class Sfc_fun:
 
         Dicdata = {'port_chain': Dicdata}
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
               '/sfc/port_chains'
         headers = {"Accept": "application/json",
                    "Content-Type": "application/json",
@@ -467,8 +474,8 @@ class Sfc_fun:
 
         Dicdata = {'router': Dicdata}
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/' + \
-            self.osver+'/routers.json'
+        url = 'http://' + self.neutron_hostname + ':9696/' + \
+            self.osver + '/routers.json'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.post(url, headers=headers,  data=data)
@@ -485,7 +492,7 @@ class Sfc_fun:
 
     def attachInterface(self):
         """Attachment of instance ports to the Router."""
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
               '/networks?name=admin_floating_net'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
@@ -508,8 +515,8 @@ class Sfc_fun:
             Dicdata['subnet_id'] = self.subnetId
 
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-              '/routers/'+self.router_id+'/add_router_interface'
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+              '/routers/' + self.router_id + '/add_router_interface'
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.put(url, headers=headers,  data=data)
@@ -529,7 +536,7 @@ class Sfc_fun:
         Dicdata1 = {'external_gateway_info': Dicdata1}
         Dicdata1 = {'router': Dicdata1}
         data = json.dumps(Dicdata1, indent=4)
-        url = 'http://' + self.neutron_hostname+':9696/'+self.osver + \
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
               '/routers/' + self.router_id
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
@@ -549,7 +556,7 @@ class Sfc_fun:
             Dicdata['pool'] = "admin_floating_net"
 
             data = json.dumps(Dicdata, indent=4)
-            url = 'http://'+self.nova_hostname+':8774/v2.1/os-floating-ips'
+            url = 'http://' + self.nova_hostname + ':8774/v2.1/os-floating-ips'
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.post(url, headers=headers,  data=data)
@@ -571,7 +578,7 @@ class Sfc_fun:
             Dicdata1 = {'addFloatingIp': Dicdata1}
             data = json.dumps(Dicdata1, indent=4)
             url = 'http://' + self.nova_hostname + ':8774/v2.1/servers/' + \
-                  self.vm[ip_num]+'/action'
+                  self.vm[ip_num] + '/action'
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.post(url, headers=headers,  data=data)
@@ -594,7 +601,7 @@ class Sfc_fun:
             username = "cirros"
             password = "cubswin:)"
             s.login(hostname,  username,  password)
-            s.sendline("ping -c 5 "+str(self.port_ip[2]))
+            s.sendline("ping -c 5 " + str(self.port_ip[2]))
             s.prompt()             # match the prompt
 
             ping_re = re.search("transmitted.*received",  s.before).group()
@@ -651,6 +658,7 @@ class Sfc_fun:
 
     """##################################################################"""
     """ ########################  Stats Functions ################# #####"""
+
     def portChainDeviceMap(self):
         """Check the PC Device Stats in the ONOS."""
         response = requests.get('http://' + self.onos_hostname +
@@ -664,7 +672,7 @@ class Sfc_fun:
 
     def portChainSfMap(self):
         """Check the PC SF Map Stats in the ONOS."""
-        response = requests.get('http://'+self.onos_hostname +
+        response = requests.get('http://' + self.onos_hostname +
                                 ':8181/onos/vtn/portChainSfMap/' +
                                 self.PC_id, auth=("karaf",  "karaf"))
         if (response.status_code == 200):
@@ -677,8 +685,8 @@ class Sfc_fun:
 
     def deletePortChain(self):
         """Deletion of PortChain."""
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-              '/sfc/port_chains/'+self.PC_id
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+              '/sfc/port_chains/' + self.PC_id
         headers = {"Accept": "application/json", "Content-Type":
                    "application/json", "X-Auth-Token": self.token_id}
         response = requests.delete(url, headers=headers)
@@ -691,8 +699,8 @@ class Sfc_fun:
 
     def deleteFlowClassifier(self):
         """Deletion of Flow Classifier."""
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-              '/sfc/flow_classifiers/'+self.flow_class_if
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+              '/sfc/flow_classifiers/' + self.flow_class_if
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.delete(url, headers=headers)
@@ -706,8 +714,8 @@ class Sfc_fun:
     def deletePortGroup(self):
         """Deletion of PortGroup."""
         for p in range(0, 1):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/sfc/port_pair_groups/'+self.port_grp_id[p]
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/sfc/port_pair_groups/' + self.port_grp_id[p]
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.delete(url, headers=headers)
@@ -722,8 +730,8 @@ class Sfc_fun:
     def deletePortPair(self):
         """Deletion of Portpair."""
         for p in range(1,  2):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/sfc/port_pairs/'+self.port_pair_id[0]
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/sfc/port_pairs/' + self.port_pair_id[0]
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.delete(url, headers=headers)
@@ -738,21 +746,22 @@ class Sfc_fun:
         """Cleanup."""
         print ("\n\t\tDeleting the VMs")
         for y in range(0, 3):
-            url = 'http://'+self.nova_hostname+':8774/v2.1/servers/'+self.vm[y]
+            url = 'http://' + self.nova_hostname + \
+                ':8774/v2.1/servers/' + self.vm[y]
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.delete(url, headers=headers)
             if (response.status_code == 204):
-                    self.logger.debug(response.status_code)
-                    self.logger.debug(response.content)
-                    print ("\n\t\tVM"+str(y)+" is Deleted : ")
-                    time.sleep(10)
+                self.logger.debug(response.status_code)
+                self.logger.debug(response.content)
+                print ("\n\t\tVM" + str(y) + " is Deleted : ")
+                time.sleep(10)
             else:
                 return(response.status_code)
         print ("\n\t\tDeletion of Ports")
         for x in range(self.i, self.numTerms):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/ports/'+self.port_num[x]
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/ports/' + self.port_num[x]
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.delete(url, headers=headers)
@@ -769,8 +778,8 @@ class Sfc_fun:
         Dicdata['external_gateway_info'] = {}
         Dicdata = {'router': Dicdata}
         data = json.dumps(Dicdata, indent=4)
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-              '/routers/'+self.router_id
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+              '/routers/' + self.router_id
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.put(url, headers=headers,  data=data)
@@ -781,15 +790,15 @@ class Sfc_fun:
             if self.subnetId != '':
                 Dicdata1['subnet_id'] = self.subnetId
             data = json.dumps(Dicdata1, indent=4)
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/routers/'+self.router_id + \
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/routers/' + self.router_id + \
                   '/remove_router_interface.json'
             headers = {"Accept": "application/json",
                        "X-Auth-Token": self.token_id}
             response = requests.put(url, headers=headers,  data=data)
             if (response.status_code == 200):
-                url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                      '/routers/'+self.router_id
+                url = ('http://' + self.neutron_hostname + ':9696/' +
+                       self.osver + '/routers/' + self.router_id)
                 headers = {"Accept": "application/json",  "X-Auth-Token":
                            self.token_id}
                 response = requests.delete(url, headers=headers)
@@ -805,8 +814,8 @@ class Sfc_fun:
             return(response.status_code)
 
         print ("\n\t\tDeletion of Network")
-        url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-              '/networks/'+self.net_id
+        url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+              '/networks/' + self.net_id
         headers = {"Accept": "application/json",
                    "X-Auth-Token": self.token_id}
         response = requests.delete(url, headers=headers)
@@ -819,14 +828,14 @@ class Sfc_fun:
 
         print ("\n\t\tDeletion of Floating ip")
         for ip_num in range(0, 2):
-            url = 'http://'+self.neutron_hostname+':9696/'+self.osver + \
-                  '/floatingips/'+self.vm_public_id[ip_num]
+            url = 'http://' + self.neutron_hostname + ':9696/' + self.osver + \
+                  '/floatingips/' + self.vm_public_id[ip_num]
             headers = {"Accept": "application/json", "X-Auth-Token":
                        self.token_id}
             response = requests.delete(url, headers=headers)
             if (response.status_code == 204):
-                    self.logger.debug(response.status_code)
-                    self.logger.debug(response.content)
+                self.logger.debug(response.status_code)
+                self.logger.debug(response.content)
             else:
-                    return(response.status_code)
+                return(response.status_code)
         return(response.status_code)
index 41f8a9c..92a3df6 100755 (executable)
@@ -73,11 +73,9 @@ def main():
                                             IMAGE_PATH,
                                             disk=IMAGE_FORMAT,
                                             container="bare",
-                                            public=True,
-                                            logger=logger)
+                                            public=True)
 
-    network_dic = os_utils.create_network_full(logger,
-                                               neutron_client,
+    network_dic = os_utils.create_network_full(neutron_client,
                                                NET_NAME,
                                                SUBNET_NAME,
                                                ROUTER_NAME,
@@ -89,7 +87,7 @@ def main():
 
     network_id = network_dic["net_id"]
 
-    sg_id = os_utils.create_security_group_full(logger, neutron_client,
+    sg_id = os_utils.create_security_group_full(neutron_client,
                                                 SECGROUP_NAME, SECGROUP_DESCR)
 
     # boot INTANCE
index c480473..589939b 100755 (executable)
@@ -425,8 +425,7 @@ def main():
         image_exists = True
 
     logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME)
-    network_dict = os_utils.create_network_full(logger,
-                                                neutron_client,
+    network_dict = os_utils.create_network_full(neutron_client,
                                                 PRIVATE_NET_NAME,
                                                 PRIVATE_SUBNET_NAME,
                                                 ROUTER_NAME,
index 452e1fd..9535de1 100755 (executable)
@@ -138,8 +138,7 @@ def create_tempest_resources():
         logger.error("Error : Failed to create %s user" % USER_NAME)
 
     logger.debug("Creating private network for Tempest suite")
-    network_dic = os_utils.create_network_full(logger,
-                                               neutron_client,
+    network_dic = os_utils.create_network_full(neutron_client,
                                                PRIVATE_NET_NAME,
                                                PRIVATE_SUBNET_NAME,
                                                ROUTER_NAME,
index 60e7baa..4aab619 100755 (executable)
@@ -199,8 +199,7 @@ def main():
         logger.debug("Image '%s' with ID=%s created successfully."
                      % (GLANCE_IMAGE_NAME, image_id))
 
-    network_dic = os_utils.create_network_full(logger,
-                                               neutron_client,
+    network_dic = os_utils.create_network_full(neutron_client,
                                                PRIVATE_NET_NAME,
                                                PRIVATE_SUBNET_NAME,
                                                ROUTER_NAME,
index 164aea6..b6e3fe1 100755 (executable)
@@ -199,8 +199,7 @@ def main():
         logger.debug("Image '%s' with ID=%s created successfully."
                      % (GLANCE_IMAGE_NAME, image_id))
 
-    network_dic = os_utils.create_network_full(logger,
-                                               neutron_client,
+    network_dic = os_utils.create_network_full(neutron_client,
                                                PRIVATE_NET_NAME,
                                                PRIVATE_SUBNET_NAME,
                                                ROUTER_NAME,
index fe1547a..564f947 100755 (executable)
@@ -14,16 +14,16 @@ import json
 import os
 import subprocess
 import time
-import yaml
-
-import keystoneclient.v2_0.client as ksclient
-import glanceclient.client as glclient
-import novaclient.client as nvclient
-from neutronclient.v2_0 import client as ntclient
 
 import functest.utils.functest_logger as ft_logger
 import functest.utils.functest_utils as functest_utils
 import functest.utils.openstack_utils as openstack_utils
+import glanceclient.client as glclient
+import keystoneclient.v2_0.client as ksclient
+from neutronclient.v2_0 import client as ntclient
+import novaclient.client as nvclient
+import yaml
+
 
 parser = argparse.ArgumentParser()
 
@@ -168,8 +168,7 @@ def main():
 
     neutron = ntclient.Client(**nt_creds)
 
-    network_dic = openstack_utils.create_network_full(logger,
-                                                      neutron,
+    network_dic = openstack_utils.create_network_full(neutron,
                                                       NET_NAME,
                                                       SUBNET_NAME,
                                                       ROUTER_NAME,
index dedf6e4..99aac66 100755 (executable)
@@ -93,11 +93,9 @@ def main():
                                             IMAGE_PATH,
                                             disk=IMAGE_FORMAT,
                                             container="bare",
-                                            public=True,
-                                            logger=logger)
+                                            public=True)
 
-    network_dic = os_utils.create_network_full(logger,
-                                               neutron_client,
+    network_dic = os_utils.create_network_full(neutron_client,
                                                NET_NAME,
                                                SUBNET_NAME,
                                                ROUTER_NAME,
@@ -109,7 +107,7 @@ def main():
 
     network_id = network_dic["net_id"]
 
-    sg_id = os_utils.create_security_group_full(logger, neutron_client,
+    sg_id = os_utils.create_security_group_full(neutron_client,
                                                 SECGROUP_NAME, SECGROUP_DESCR)
 
     # boot INTANCE
index a0de873..d14828d 100644 (file)
@@ -146,9 +146,8 @@ def get_instance_status(nova_client, instance):
     try:
         instance = nova_client.servers.get(instance.id)
         return instance.status
-    except:
-        # logger.error("Error [get_instance_status(nova_client, '%s')]:" %
-        #        str(instance)), e
+    except Exception, e:
+        logger.error("Error [get_instance_status(nova_client)]: %s" % e)
         return None
 
 
@@ -588,8 +587,7 @@ def remove_gateway_router(neutron_client, router_id):
         return False
 
 
-def create_network_full(logger,
-                        neutron_client,
+def create_network_full(neutron_client,
                         net_name,
                         subnet_name,
                         router_name,
@@ -736,7 +734,7 @@ def create_secgroup_rule(neutron_client, sg_id, direction, protocol,
         return False
 
 
-def create_security_group_full(logger, neutron_client,
+def create_security_group_full(neutron_client,
                                sg_name, sg_description):
     sg_id = get_security_group_id(neutron_client, sg_name)
     if sg_id != '':
@@ -835,7 +833,7 @@ def get_image_id(glance_client, image_name):
 
 
 def create_glance_image(glance_client, image_name, file_path, disk="qcow2",
-                        container="bare", public=True, logger=None):
+                        container="bare", public=True):
     if not os.path.isfile(file_path):
         logger.error("Error: file %s does not exist." % file_path)
         return False