diff options
Diffstat (limited to 'sfc/lib/openstack_utils.py')
-rw-r--r-- | sfc/lib/openstack_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index 59ccdaca..c46ff123 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -188,6 +188,12 @@ class OpenStackSFC: return instance, port_list + def get_instance(self, instance_id): + """ + Return a dictionary of metadata for a server instance + """ + return self.conn.compute.get_server_metadata(instance_id) + def get_av_zones(self): ''' Return the availability zone each host belongs to @@ -237,6 +243,17 @@ class OpenStackSFC: raise Exception("There is no VM with name '{}'!!".format(vm_name)) + def get_port_by_ip(self, ip_address): + """ + Return a dictionary of metadata for a port instance + by its ip_address + """ + + ports = self.conn.network.ports() + for port in ports: + if port.fixed_ips[0]['ip_address'] == ip_address: + return self.conn.network.get_port(port.id) + def assign_floating_ip(self, vm, vm_port): ''' Assign floating ips to all the VMs |