diff options
author | DR695H <dr695h@att.com> | 2019-10-01 11:31:45 -0400 |
---|---|---|
committer | mrichomme <morgan.richomme@orange.com> | 2020-03-19 14:08:25 +0100 |
commit | 54f75f9a94af1ec92176bd9740b6a657fcfbd732 (patch) | |
tree | 4392359de4235b483bf9212fbebcc4173aabc398 | |
parent | 58bf891dffae71a766a89910e6fb01703faae8fa (diff) |
remvoing ; and uneeded imports
Issue-ID: INT-1292
Change-Id: Ib444023db31866e436f43f804f9c38fa00e66b79
Signed-off-by: DR695H <dr695h@att.com>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | heatbridge/heatbridge/AAIManager.py | 207 | ||||
-rw-r--r-- | heatbridge/heatbridge/HeatBridge.py | 75 | ||||
-rw-r--r-- | heatbridge/heatbridge/OpenstackContext.py | 30 | ||||
-rw-r--r-- | heatbridge/heatbridge/OpenstackManager.py | 102 |
5 files changed, 207 insertions, 208 deletions
@@ -3,3 +3,4 @@ /.project /.pydevproject /target/ +/.idea/ diff --git a/heatbridge/heatbridge/AAIManager.py b/heatbridge/heatbridge/AAIManager.py index 057a155..3ef8023 100644 --- a/heatbridge/heatbridge/AAIManager.py +++ b/heatbridge/heatbridge/AAIManager.py @@ -1,122 +1,123 @@ from collections import defaultdict + class AAIManager: """AAIManager manages the connection state and interaction between an aai instance and the heatbridge.""" def __init__(self, context): - self.openstack_context = context; + self.openstack_context = context def get_link(self, links, link_type): for link in links: if link['rel'] == link_type: - return link['href']; + return link['href'] def create_transactions(self, *args): - transactions = defaultdict(list); + transactions = defaultdict(list) for arg in args: - transactions['transactions'].extend(arg); - return transactions; + transactions['transactions'].extend(arg) + return transactions def create_put(self, *args): - put = defaultdict(list); - put['put'].extend(args); - return put; + put = defaultdict(list) + put['put'].extend(args) + return put def create_vserver_put(self, server_info_dict, volumes_dict): - #setup - put = dict(); - body = dict(); - put['body'] = body; + # setup + put = dict() + body = dict() + put['body'] = body - #required fields + # required fields put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \ + "/" + self.openstack_context.region + "/tenants/tenant/" + self.openstack_context.tenant \ - + "/vservers/vserver/" + server_info_dict['id']; - body['vserver-id'] = server_info_dict['id']; - body['vserver-name'] = server_info_dict['name']; - body['vserver-name2'] = server_info_dict['name']; - body['prov-status'] = server_info_dict['status']; - body['vserver-selflink'] = self.get_link(server_info_dict['links'], "self"); - #body['in-maint']; - #body['is-closed-loop-disabled']; - #body['resource-version']; - - #optional fields + + "/vservers/vserver/" + server_info_dict['id'] + body['vserver-id'] = server_info_dict['id'] + body['vserver-name'] = server_info_dict['name'] + body['vserver-name2'] = server_info_dict['name'] + body['prov-status'] = server_info_dict['status'] + body['vserver-selflink'] = self.get_link(server_info_dict['links'], "self") + # body['in-maint']; + # body['is-closed-loop-disabled']; + # body['resource-version']; + + # optional fields volumes = [] body['volumes'] = volumes for volume in volumes_dict: - volumes.append(self.create_volume(volume)); + volumes.append(self.create_volume(volume)) - relations = []; + relations = [] if self.__exists(server_info_dict['metadata'], 'vnf_id'): - data = self.__create_relationship_data("generic-vnf", "vnf-id", server_info_dict['metadata']['vnf_id']); - list = self.__create_relationship_data_list(data); - relations.append(self.__create_relationship("generic-vnf", list)); + data = self.__create_relationship_data("generic-vnf", "vnf-id", server_info_dict['metadata']['vnf_id']) + list = self.__create_relationship_data_list(data) + relations.append(self.__create_relationship("generic-vnf", list)) if self.__exists(server_info_dict['metadata'], 'vf_module_id'): - data = self.__create_relationship_data("vf-module", "vf-module-id", server_info_dict['metadata']['vf_module_id']); - data2 = self.__create_relationship_data("generic-vnf", "vnf-id", server_info_dict['metadata']['vnf_id']); - list = self.__create_relationship_data_list(data, data2); - relations.append(self.__create_relationship("vf-module", list)); + data = self.__create_relationship_data("vf-module", "vf-module-id", server_info_dict['metadata']['vf_module_id']) + data2 = self.__create_relationship_data("generic-vnf", "vnf-id", server_info_dict['metadata']['vnf_id']) + list = self.__create_relationship_data_list(data, data2) + relations.append(self.__create_relationship("vf-module", list)) if self.__exists(server_info_dict['flavor'], 'id'): - data = self.__create_relationship_data("flavor", "flavor-id", server_info_dict['flavor']['id']); - data2 = self.__create_relationship_data("cloud-region", "cloud-owner", self.openstack_context.owner); - data3 = self.__create_relationship_data("cloud-region", "cloud-region-id", self.openstack_context.region); - list = self.__create_relationship_data_list(data, data2, data3); - relations.append(self.__create_relationship("flavor", list)); + data = self.__create_relationship_data("flavor", "flavor-id", server_info_dict['flavor']['id']) + data2 = self.__create_relationship_data("cloud-region", "cloud-owner", self.openstack_context.owner) + data3 = self.__create_relationship_data("cloud-region", "cloud-region-id", self.openstack_context.region) + list = self.__create_relationship_data_list(data, data2, data3) + relations.append(self.__create_relationship("flavor", list)) if self.__exists(server_info_dict['image'], 'id'): - data = self.__create_relationship_data("image", "image-id", server_info_dict['image']['id']); - data2 = self.__create_relationship_data("cloud-region", "cloud-owner", self.openstack_context.owner); - data3 = self.__create_relationship_data("cloud-region", "cloud-region-id", self.openstack_context.region); - list = self.__create_relationship_data_list(data, data2, data3); - relations.append(self.__create_relationship("image", list)); - #Add a relation to VNFC - data = self.__create_relationship_data("vnfc", "vnfc-name", server_info_dict['name']); - list = self.__create_relationship_data_list(data); - relations.append(self.__create_relationship("vnfc", list)); - body['relationship-list'] = self.__create_relationship_list(relations); + data = self.__create_relationship_data("image", "image-id", server_info_dict['image']['id']) + data2 = self.__create_relationship_data("cloud-region", "cloud-owner", self.openstack_context.owner) + data3 = self.__create_relationship_data("cloud-region", "cloud-region-id", self.openstack_context.region) + list = self.__create_relationship_data_list(data, data2, data3) + relations.append(self.__create_relationship("image", list)) + # Add a relation to VNFC + data = self.__create_relationship_data("vnfc", "vnfc-name", server_info_dict['name']) + list = self.__create_relationship_data_list(data) + relations.append(self.__create_relationship("vnfc", list)) + body['relationship-list'] = self.__create_relationship_list(relations) return put def __create_relationship_list(self, items): rel_list = dict() relationship = [] - rel_list['relationship'] = relationship; - relationship.extend(items); - return rel_list; + rel_list['relationship'] = relationship + relationship.extend(items) + return rel_list def __create_relationship_data_list(self, *relationship_data): - relationship_data_list = []; - relationship_data_list.extend(relationship_data); - return relationship_data_list; + relationship_data_list = [] + relationship_data_list.extend(relationship_data) + return relationship_data_list def __create_relationship(self, related_to, relationship_data_list): - relationship = dict(); - relationship['related-to'] = related_to; + relationship = dict() + relationship['related-to'] = related_to relationship['relationship-data'] = relationship_data_list - return relationship; + return relationship def __create_relationship_data(self, parent, key, value): - relationship_data = dict(); - relationship_data['relationship-key'] = parent + "." + key; - relationship_data['relationship-value'] = value; - return relationship_data; + relationship_data = dict() + relationship_data['relationship-key'] = parent + "." + key + relationship_data['relationship-value'] = value + return relationship_data def create_volume(self, volume_dict): - #setup + # setup volume = dict() if 'volume' in volume_dict: volume['volume-id'] = volume_dict['volume']['id'] - #volume['volume-selflink'] - #volume['resource-version'] - #volume['relationship-list'] - return volume; + # volume['volume-selflink'] + # volume['resource-version'] + # volume['relationship-list'] + return volume def create_flavor_put(self, flavor_dict): - #setup - put = dict(); + # setup + put = dict() body = dict() put['body'] = body - #required fields + # required fields put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \ + "/" + self.openstack_context.region + "/flavors/flavor/" + flavor_dict['id'] body['flavor-id'] = flavor_dict['id'] @@ -128,22 +129,22 @@ class AAIManager: body['flavor-ephemeral'] = flavor_dict['OS-FLV-EXT-DATA:ephemeral'] if flavor_dict['swap'] != "": body['flavor-swap'] = flavor_dict['swap'] - body['flavor-selflink'] = self.get_link(flavor_dict['links'], "self"); - #body['flavor-is-public''] - #body['flavor-disabled'] - #body['relationship-list'] + body['flavor-selflink'] = self.get_link(flavor_dict['links'], "self") + # body['flavor-is-public''] + # body['flavor-disabled'] + # body['relationship-list'] return put def create_image_put(self, image_dict, server_info): - #setup - put = dict(); + # setup + put = dict() body = dict() put['body'] = body put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \ + "/" + self.openstack_context.region + "/images/image/" + image_dict['id'] body['image-id'] = image_dict['id'] body['image-name'] = image_dict['name'] - body['image-selflink'] = self.get_link(server_info['image']['links'], "bookmark"); + body['image-selflink'] = self.get_link(server_info['image']['links'], "bookmark") if self.__exists(image_dict, 'org.openstack__1__architecture'): body['image-architecture'] = image_dict['org.openstack__1__architecture'] else: @@ -172,20 +173,20 @@ class AAIManager: body['image-os-distro'] = image_dict['os_distro'] else: body['image-os-distro'] = 'unknown' - #body['metadata'] - #body['relationship-list']; + # body['metadata'] + # body['relationship-list']; return put def __exists(self, the_dict, key): if key in the_dict and the_dict[key] != "": - return True; + return True else: - return False; + return False def create_l_interface_put(self, port_dict, server_info_dict): - #setup + # setup port = port_dict['port'] - put = dict(); + put = dict() body = dict() put['body'] = body put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \ @@ -194,50 +195,50 @@ class AAIManager: body['interface-id'] = port['id'] body['interface-name'] = port['name'] body['macaddr'] = port['mac_address'] - #optional fields + # optional fields v4list = [] v6list = [] body['l3-interface-ipv4-address-list'] = v4list body['l3-interface-ipv6-address-list'] = v6list for ips in port['fixed_ips']: if '.' in ips['ip_address']: - v4list.append(self.create_l3_interface_ipv4_address(port, ips)); + v4list.append(self.create_l3_interface_ipv4_address(port, ips)) if ':' in ips['ip_address']: - v6list.append(self.create_l3_interface_ipv6_address(port, ips)); + v6list.append(self.create_l3_interface_ipv6_address(port, ips)) body['network-name'] = port['network_id'] - #body['selflink'] - #body['interface-role'] - #body['v6-wan-link-ip'] - #body['management-option'] + # body['selflink'] + # body['interface-role'] + # body['v6-wan-link-ip'] + # body['management-option'] - #optional fields + # optional fields return put def create_l3_interface_ipv4_address(self, port_dict, fixed_ip): - #setup + # setup address = dict() address['l3-interface-ipv4-address'] = fixed_ip['ip_address'] address['l3-interface-ipv4-prefix-length'] = '32' address['neutron-network-id'] = port_dict['network_id'] address['neutron-subnet-id'] = fixed_ip['subnet_id'] - #address['vlan-id-inner'] - #address['vlan-id-outer'] - #address['is-floating'] - #address['relationship-list'] - return address; + # address['vlan-id-inner'] + # address['vlan-id-outer'] + # address['is-floating'] + # address['relationship-list'] + return address def create_l3_interface_ipv6_address(self, port_dict, fixed_ip): - #setup + # setup address = dict() address['l3-interface-ipv6-address'] = fixed_ip['ip_address'] address['l3-interface-ipv6-prefix-length'] = '128' address['neutron-network-id'] = port_dict['network_id'] address['neutron-subnet-id'] = fixed_ip['subnet_id'] - #address['vlan-id-inner'] - #address['vlan-id-outer'] - #address['is-floating'] - #address['relationship-list'] - return address; + # address['vlan-id-inner'] + # address['vlan-id-outer'] + # address['is-floating'] + # address['relationship-list'] + return address def load_aai_data(self, request): - return True; + return True diff --git a/heatbridge/heatbridge/HeatBridge.py b/heatbridge/heatbridge/HeatBridge.py index bdf3e64..f236970 100644 --- a/heatbridge/heatbridge/HeatBridge.py +++ b/heatbridge/heatbridge/HeatBridge.py @@ -3,65 +3,66 @@ from OpenstackManager import OpenstackManager from OpenstackContext import OpenstackContext from AAIManager import AAIManager + class HeatBridge: def __init__(self): - pass; + pass def init_bridge(self, openstack_identity_url, username, password, tenant, region, owner, domain_id=None, project_name=None): - self.om = OpenstackManager(openstack_identity_url, OpenstackContext(username, password, tenant, region, owner, domain_id, project_name)); - self.am = AAIManager(OpenstackContext(username, password, tenant, region, owner, domain_id, project_name)); - + self.om = OpenstackManager(openstack_identity_url, OpenstackContext(username, password, tenant, region, owner, domain_id, project_name)) + self.am = AAIManager(OpenstackContext(username, password, tenant, region, owner, domain_id, project_name)) def filterbyvalue(self, seq, key, value): for el in seq: - if el[key]==value: yield el + if el[key] == value: + yield el def build_request(self, heat_stack_id): resources = self.om.get_stack_resources(heat_stack_id) - servers = list(self.filterbyvalue(resources, "resource_type", "OS::Nova::Server")); - #networks = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Net")); - #subnets = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Subnet")); - ports = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Port")); - #keys = list(self.filterbyvalue(resources, "resource_type", "OS::Nova::KeyPair")); + servers = list(self.filterbyvalue(resources, "resource_type", "OS::Nova::Server")) + # networks = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Net")) + # subnets = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Subnet")) + ports = list(self.filterbyvalue(resources, "resource_type", "OS::Neutron::Port")) + # keys = list(self.filterbyvalue(resources, "resource_type", "OS::Nova::KeyPair")) put_blocks = [] - #build the servers and attach them to vnf + # build the servers and attach them to vnf server_put_blocks = [] image_put_blocks = [] flavor_put_blocks = [] for item in servers: - server_info = self.om.get_server_info(item['physical_resource_id']); - server_volumes = self.om.get_server_volumes(item['physical_resource_id']); - volumes = []; + server_info = self.om.get_server_info(item['physical_resource_id']) + server_volumes = self.om.get_server_volumes(item['physical_resource_id']) + volumes = [] for vols in server_volumes: - volumes.append(self.om.get_volume_info(vols['id'])); - aai_vserver = self.am.create_vserver_put(server_info, volumes); - flavor_info = self.om.get_flavor_info(server_info['flavor']['id']); - aai_flavor = self.am.create_flavor_put(flavor_info); - image_info = self.om.get_image_info(server_info['image']['id']); - aai_image = self.am.create_image_put(image_info, server_info); - server_put_blocks.append(self.am.create_put(aai_vserver)); - image_put_blocks.append(self.am.create_put(aai_image)); - flavor_put_blocks.append(self.am.create_put(aai_flavor)); - put_blocks.extend(image_put_blocks); - put_blocks.extend(flavor_put_blocks); - put_blocks.extend(server_put_blocks); + volumes.append(self.om.get_volume_info(vols['id'])) + aai_vserver = self.am.create_vserver_put(server_info, volumes) + flavor_info = self.om.get_flavor_info(server_info['flavor']['id']) + aai_flavor = self.am.create_flavor_put(flavor_info) + image_info = self.om.get_image_info(server_info['image']['id']) + aai_image = self.am.create_image_put(image_info, server_info) + server_put_blocks.append(self.am.create_put(aai_vserver)) + image_put_blocks.append(self.am.create_put(aai_image)) + flavor_put_blocks.append(self.am.create_put(aai_flavor)) + put_blocks.extend(image_put_blocks) + put_blocks.extend(flavor_put_blocks) + put_blocks.extend(server_put_blocks) - #build the ports and attach them to servers + # build the ports and attach them to servers linterface_put_blocks = [] - #all servers have same vnf id - random_server_info = self.om.get_server_info(servers[0]['physical_resource_id']); + # all servers have same vnf id + random_server_info = self.om.get_server_info(servers[0]['physical_resource_id']) for item in ports: - #todo: pass in the networks from above + # todo: pass in the networks from above port_info = self.om.get_port_info(item['physical_resource_id']) - aai_linterface = self.am.create_l_interface_put(port_info, random_server_info); - linterface_put_blocks.append(self.am.create_put(aai_linterface)); - put_blocks.extend(linterface_put_blocks); + aai_linterface = self.am.create_l_interface_put(port_info, random_server_info) + linterface_put_blocks.append(self.am.create_put(aai_linterface)) + put_blocks.extend(linterface_put_blocks) - return json.dumps(self.am.create_transactions(put_blocks)); + return json.dumps(self.am.create_transactions(put_blocks)) def bridge_data(self, heat_stack_id): - request = self.build_request(heat_stack_id); - print(request); - return request; + request = self.build_request(heat_stack_id) + print(request) + return request diff --git a/heatbridge/heatbridge/OpenstackContext.py b/heatbridge/heatbridge/OpenstackContext.py index 55661d3..980c72e 100644 --- a/heatbridge/heatbridge/OpenstackContext.py +++ b/heatbridge/heatbridge/OpenstackContext.py @@ -1,20 +1,20 @@ class OpenstackContext: """OpenstackContext is a simple class that holds the provided information that heatbridge uses.""" - #this holds the info of the openstack clients - username = None; - password = None; - tenant = None; - region = None; - owner = None; - domain_id = None; - project_name = None; + # this holds the info of the openstack clients + username = None + password = None + tenant = None + region = None + owner = None + domain_id = None + project_name = None def __init__(self, username, password, tenant, region, owner, domain_id, project_name): - self.username = username; - self.password = password; - self.tenant = tenant; - self.region = region; - self.owner = owner; - self.domain_id = domain_id; - self.project_name = project_name; + self.username = username + self.password = password + self.tenant = tenant + self.region = region + self.owner = owner + self.domain_id = domain_id + self.project_name = project_name diff --git a/heatbridge/heatbridge/OpenstackManager.py b/heatbridge/heatbridge/OpenstackManager.py index 327978a..df79077 100644 --- a/heatbridge/heatbridge/OpenstackManager.py +++ b/heatbridge/heatbridge/OpenstackManager.py @@ -1,21 +1,17 @@ -from heatclient.v1.client import Client as HeatClient; -from novaclient.v2.client import Client as NovaClient; -from cinderclient.v1.client import Client as CinderClient; -from glanceclient.v2.client import Client as GlanceClient; -from neutronclient.v2_0.client import Client as NeutronClient; import os_client_config import logging + class OpenstackManager: """OpenstackManager manages the connection state and interaction between an openstack cloud and the heatbridge.""" - #this holds the session of the openstack clients - __heat_client = None; - __nova_client = None; - __cinder_client = None; - __glance_client = None; - __neutron_client = None; - __auth_resp = None; + # this holds the session of the openstack clients + __heat_client = None + __nova_client = None + __cinder_client = None + __glance_client = None + __neutron_client = None + __auth_resp = None def __init__(self, identity_url, context): """ OpenstackManager @@ -23,8 +19,8 @@ class OpenstackManager: `identity_url` Base identity_url of the identity server 'context' Instance of OpenstackContext """ - self.openstack_context = context; - self.identity_url = identity_url; + self.openstack_context = context + self.identity_url = identity_url self.authenticate(context.username, context.password, context.tenant, context.region, context.domain_id, context.project_name) logging.basicConfig(level=logging.DEBUG) @@ -46,7 +42,7 @@ class OpenstackManager: project_id=tenant, region_name=region, domain_id=domain_id, - project_name=project_name); + project_name=project_name) self.__nova_client = os_client_config.make_client('compute', auth_url=self.identity_url, username=username, @@ -54,7 +50,7 @@ class OpenstackManager: project_id=tenant, region_name=region, domain_id=domain_id, - project_name=project_name); + project_name=project_name) self.__cinder_client = os_client_config.make_client('volume', auth_url=self.identity_url, username=username, @@ -62,7 +58,7 @@ class OpenstackManager: project_id=tenant, region_name=region, domain_id=domain_id, - project_name=project_name); + project_name=project_name) self.__glance_client = os_client_config.make_client('image', auth_url=self.identity_url, username=username, @@ -70,7 +66,7 @@ class OpenstackManager: project_id=tenant, region_name=region, domain_id=domain_id, - project_name=project_name); + project_name=project_name) self.__neutron_client = os_client_config.make_client('network', auth_url=self.identity_url, username=username, @@ -78,81 +74,81 @@ class OpenstackManager: project_id=tenant, region_name=region, domain_id=domain_id, - project_name=project_name); - #this next line is needed because for v2 apis that are after a certain release stopped providing version info in keytone url but rackspace did not - self.__neutron_client.action_prefix = ""; - self.__auth_resp = True; + project_name=project_name) + # this next line is needed because for v2 apis that are after a certain release stopped providing version info in keytone url but rackspace did not + self.__neutron_client.action_prefix = "" + self.__auth_resp = True def get_stack(self, stack_id): self.__check_authenticated() #: :type client: HeatClient client = self.__heat_client stack = client.stacks.get(stack_id) - return stack.to_dict(); + return stack.to_dict() def get_stack_resources(self, stack_id): self.__check_authenticated() #: :type client: HeatClient - client = self.__heat_client; - stack_resources = client.resources.list(stack_id); - stack_resources_dict = map(lambda x:x.to_dict(),stack_resources) - return stack_resources_dict; + client = self.__heat_client + stack_resources = client.resources.list(stack_id) + stack_resources_dict = map(lambda x: x.to_dict(), stack_resources) + return stack_resources_dict def get_server_volumes(self, server_id): self.__check_authenticated() #: :type client: NovaClient - client = self.__nova_client; - server_volumes = client.volumes.get_server_volumes(server_id); + client = self.__nova_client + server_volumes = client.volumes.get_server_volumes(server_id) server_volumes_dict = map(lambda x:x.to_dict(),server_volumes) - return server_volumes_dict; + return server_volumes_dict def get_server_interfaces(self, server_id): self.__check_authenticated() #: :type client: NovaClient - client = self.__nova_client; - server_interfaces = client.virtual_interfaces.list(server_id); - server_interfaces_dict = map(lambda x:x.to_dict(),server_interfaces) - return server_interfaces_dict; + client = self.__nova_client + server_interfaces = client.virtual_interfaces.list(server_id) + server_interfaces_dict = map(lambda x: x.to_dict(), server_interfaces) + return server_interfaces_dict def get_volume_info(self, volume_id): self.__check_authenticated() #: :type client: CinderClient - client = self.__cinder_client; - volume_info = client.volumes.get(volume_id); - return volume_info.to_dict(); + client = self.__cinder_client + volume_info = client.volumes.get(volume_id) + return volume_info.to_dict() def get_server_info(self, server_id): self.__check_authenticated() #: :type client: NovaClient - client = self.__nova_client; - server_info = client.servers.get(server_id); - return server_info.to_dict(); + client = self.__nova_client + server_info = client.servers.get(server_id) + return server_info.to_dict() def get_image_info(self, image_id): self.__check_authenticated() #: :type client: GlanceClient - client = self.__glance_client; - image_info = client.images.get(image_id); - return image_info; + client = self.__glance_client + image_info = client.images.get(image_id) + return image_info def get_flavor_info(self, flavor_id): self.__check_authenticated() #: :type client: NovaClient - client = self.__nova_client; - flavor_info = client.flavors.get(flavor_id); - return flavor_info.to_dict(); + client = self.__nova_client + flavor_info = client.flavors.get(flavor_id) + return flavor_info.to_dict() def get_port_info(self, port_id): self.__check_authenticated() #: :type client: NeutronClient - client = self.__neutron_client; + client = self.__neutron_client try: - port_info = client.show_port(port_id); + port_info = client.show_port(port_id) except Exception as e: - client.action_prefix = "/v2.0"; - port_info = client.show_port(port_id); - return port_info; + client.action_prefix = "/v2.0" + port_info = client.show_port(port_id) + return port_info def __check_authenticated(self): - if self.__auth_resp == None: - raise AssertionError('__auth_resp should exist before calling operation')
\ No newline at end of file + if self.__auth_resp is None: + raise AssertionError('__auth_resp should exist before calling operation') |