summaryrefslogtreecommitdiffstats
path: root/vnfmgr/vnfmgr_os
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-11-15 00:18:32 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-11-15 00:20:33 +0100
commit73c4d745bf2bba060dc8301a9127482f01318de1 (patch)
treed0f37c2e819b518f952dcfe743672f2be45685d4 /vnfmgr/vnfmgr_os
parent55649ff33c7c92a0ba2d08ebf15a21f3df9ae781 (diff)
Fix all the flake8 violations in the repo
Change-Id: I05109298835c26a1927a490f8c21dd2ca7f77947 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'vnfmgr/vnfmgr_os')
-rwxr-xr-xvnfmgr/vnfmgr_os/vnfmgr_os.py65
1 files changed, 37 insertions, 28 deletions
diff --git a/vnfmgr/vnfmgr_os/vnfmgr_os.py b/vnfmgr/vnfmgr_os/vnfmgr_os.py
index 00678503..109bc0e2 100755
--- a/vnfmgr/vnfmgr_os/vnfmgr_os.py
+++ b/vnfmgr/vnfmgr_os/vnfmgr_os.py
@@ -1,67 +1,76 @@
#################################################################
-# #
-# Copyright 2015 Ericsson AB #
-# All Rights Reserved #
-# #
-# Author: Manuel Buil <Manuel.Buil@ericsson.com> #
-# Version: 0.1 #
-# #
+#
+# Copyright 2015 Ericsson AB
+# All Rights Reserved
+#
+# Author: Manuel Buil <Manuel.Buil@ericsson.com>
+# Version: 0.1
+#
#################################################################
-import pdb
-
from novaclient.v2 import client as nova
-from novaclient import exceptions as novaexceptions
from keystoneclient.v2_0 import client as keystone
from glanceclient import client as glance
class OpenStack_API:
+
def __init__(self, authurl, tenantName, tenantUser, tenantPass):
- self.authurl=authurl
- self.tenantName=tenantName
- self.tenantUser=tenantUser
- self.tenantPass=tenantPass
+ self.authurl = authurl
+ self.tenantName = tenantName
+ self.tenantUser = tenantUser
+ self.tenantPass = tenantPass
def get_token(self):
# Establish connection to Openstack controller
- osconn = keystone.Client(username=self.tenantUser, password=self.tenantPass, tenant_name=self.tenantName, auth_url=self.authurl)
+ osconn = keystone.Client(username=self.tenantUser,
+ password=self.tenantPass,
+ tenant_name=self.tenantName,
+ auth_url=self.authurl)
token = osconn.auth_token
return token
- def get_endpoint(self,service_type, endpoint_type):
+ def get_endpoint(self, service_type, endpoint_type):
# Establish connection to Openstack controller
- osconn = keystone.Client(username=self.tenantUser, password=self.tenantPass, tenant_name=self.tenantName, auth_url=self.authurl)
- endpoint = osconn.service_catalog.url_for(service_type=service_type, endpoint_type=endpoint_type)
+ osconn = keystone.Client(username=self.tenantUser,
+ password=self.tenantPass,
+ tenant_name=self.tenantName,
+ auth_url=self.authurl)
+ endpoint = osconn.service_catalog.url_for(
+ service_type=service_type, endpoint_type=endpoint_type)
return endpoint
-
- def find_image(self,SF_type):
- # Find in glance the image that matches the SF we want to deploy
+
+ def find_image(self, SF_type):
+ # Find in glance the image that matches the SF we want to deploy
token = self.get_token()
- endpoint = self.get_endpoint('image','publicURL')
- osconn = glance.Client('1',endpoint=endpoint,token=token)
+ endpoint = self.get_endpoint('image', 'publicURL')
+ osconn = glance.Client('1', endpoint=endpoint, token=token)
image_list = osconn.images.list()
for item in image_list:
try:
image_type = item.properties.get('image_type', None)
- image_id=None
+ image_id = None
if (image_type == SF_type):
image_id = item.id
break
except:
print("Errrorr")
- #Search image which matches the SF type
+ # Search image which matches the SF type
return image_id
def create_vm(self, name, image, flavor, nics=None):
# Establish connection to Openstack controller
- osconn = nova.Client(self.tenantUser, self.tenantPass, self.tenantName, self.authurl, service_type="compute")
+ osconn = nova.Client(self.tenantUser,
+ self.tenantPass,
+ self.tenantName,
+ self.authurl,
+ service_type="compute")
try:
if nics is None:
- vm = osconn.servers.create(name,image,flavor)
+ vm = osconn.servers.create(name, image, flavor)
else:
- vm = osconn.servers.create(name,image,flavor,nics)
+ vm = osconn.servers.create(name, image, flavor, nics)
except:
print("Something wrong happened while creating the VM")
vm = None