diff options
author | Venkata Harshavardhan Reddy Allu <venkataharshavardhan_ven@srmuniv.edu.in> | 2019-03-21 20:56:23 +0530 |
---|---|---|
committer | Manuel Buil <mbuil@suse.com> | 2019-03-22 14:12:02 +0000 |
commit | 312bba313681f408461832a8e4fe43b4de56ede0 (patch) | |
tree | fc80ccd7d7adede99769de4f795e3a7502f2f5a2 /sfc/lib/openstack_utils.py | |
parent | 06ed156d9a9eb6cf8f61e7a7b3d9d35f30e6d755 (diff) |
Add new methods to openstack_utils
When we use OSM as MANO_COMPONENT, we don't have methods
to retrieve the object instances of ports and VMs. So, we
need these methods to gather details of a :
- VM using the 'id'
get_instance(id)
- port using their 'ip_address'
get_port_by_ip(ip_address)
Change-Id: Ica45bf49dddb38a3811b049d67c363ac606fde7a
Signed-off-by: Venkata Harshavardhan Reddy Allu <venkataharshavardhan_ven@srmuniv.edu.in>
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 |