aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/common/openstack_utils.py
diff options
context:
space:
mode:
authorShobhi Jain <shobhi.jain@intel.com>2018-02-23 14:59:09 +0000
committerShobhi Jain <shobhi.jain@intel.com>2018-03-20 17:32:26 +0000
commit221da2200131f617d36f3143e730f9dcfab530d0 (patch)
tree32ded0b52954b921ba074a5fbdb65deec6f0c5ae /yardstick/common/openstack_utils.py
parent68c934be759962d18d109fde35726f416088a126 (diff)
Replace neutron floating ip creation with shade.
Function create_floating_ip now uses shade client instead of neutron client. JIRA: YARDSTICK-890 Change-Id: I3defd691dad998cebf98442b52f0555b176f1af4 Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/common/openstack_utils.py')
-rw-r--r--yardstick/common/openstack_utils.py46
1 files changed, 31 insertions, 15 deletions
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index e1a133fe9..591a1b313 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -429,12 +429,6 @@ def delete_keypair(nova_client, key): # pragma: no cover
# *********************************************
# NEUTRON
# *********************************************
-def get_network_id(shade_client, network_name):
- networks = shade_client.list_networks({'name': network_name})
- if networks:
- return networks[0]['id']
-
-
def create_neutron_net(shade_client, network_name, shared=False,
admin_state_up=True, external=False, provider=None,
project_id=None):
@@ -587,16 +581,38 @@ def remove_router_interface(shade_client, router, subnet_id=None,
return False
-def create_floating_ip(neutron_client, extnet_id): # pragma: no cover
- props = {'floating_network_id': extnet_id}
+def create_floating_ip(shade_client, network_name_or_id=None, server=None,
+ fixed_address=None, nat_destination=None,
+ port=None, wait=False, timeout=60):
+ """Allocate a new floating IP from a network or a pool.
+
+ :param network_name_or_id: Name or ID of the network
+ that the floating IP should come from.
+ :param server: Server dict for the server to create
+ the IP for and to which it should be attached.
+ :param fixed_address: Fixed IP to attach the floating ip to.
+ :param nat_destination: Name or ID of the network
+ that the fixed IP to attach the floating
+ IP to should be on.
+ :param port: The port ID that the floating IP should be
+ attached to. Specifying a port conflicts with specifying a
+ server,fixed_address or nat_destination.
+ :param wait: Whether to wait for the IP to be active.Only applies
+ if a server is provided.
+ :param timeout: How long to wait for the IP to be active.Only
+ applies if a server is provided.
+
+ :returns:Floating IP id and address
+ """
try:
- ip_json = neutron_client.create_floatingip({'floatingip': props})
- fip_addr = ip_json['floatingip']['floating_ip_address']
- fip_id = ip_json['floatingip']['id']
- except Exception: # pylint: disable=broad-except
- log.error("Error [create_floating_ip(neutron_client)]")
- return None
- return {'fip_addr': fip_addr, 'fip_id': fip_id}
+ fip = shade_client.create_floating_ip(
+ network=network_name_or_id, server=server,
+ fixed_address=fixed_address, nat_destination=nat_destination,
+ port=port, wait=wait, timeout=timeout)
+ return {'fip_addr': fip['floating_ip_address'], 'fip_id': fip['id']}
+ except exc.OpenStackCloudException as o_exc:
+ log.error("Error [create_floating_ip(shade_client)]. "
+ "Exception message: %s", o_exc.orig_message)
def delete_floating_ip(nova_client, floatingip_id): # pragma: no cover