aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
Diffstat (limited to 'functest/utils')
-rwxr-xr-xfunctest/utils/openstack_clean.py10
-rwxr-xr-xfunctest/utils/openstack_snapshot.py9
-rw-r--r--functest/utils/openstack_utils.py26
3 files changed, 21 insertions, 24 deletions
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index 29ebb336..b5167893 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -138,9 +138,9 @@ def remove_volumes(cinder_client, default_volumes):
"NOT be deleted.")
-def remove_floatingips(nova_client, default_floatingips):
+def remove_floatingips(neutron_client, default_floatingips):
logger.debug("Removing floating IPs...")
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if floatingips is None or len(floatingips) == 0:
logger.debug("No floating IPs found.")
return
@@ -154,7 +154,7 @@ def remove_floatingips(nova_client, default_floatingips):
if (fip_id not in default_floatingips and
fip_ip not in default_floatingips.values()):
logger.debug("Removing floating IP %s ..." % fip_id)
- if os_utils.delete_floating_ip(nova_client, fip_id):
+ if os_utils.delete_floating_ip(neutron_client, fip_id):
logger.debug(" > Done!")
deleted += 1
else:
@@ -166,7 +166,7 @@ def remove_floatingips(nova_client, default_floatingips):
timeout = 50
while timeout > 0:
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
@@ -419,7 +419,7 @@ def main():
separator()
remove_volumes(cinder_client, default_volumes)
separator()
- remove_floatingips(nova_client, default_floatingips)
+ remove_floatingips(neutron_client, default_floatingips)
separator()
remove_networks(neutron_client, default_networks, default_routers)
separator()
diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py
index c6c1615a..f4ef751c 100755
--- a/functest/utils/openstack_snapshot.py
+++ b/functest/utils/openstack_snapshot.py
@@ -98,13 +98,14 @@ def get_security_groups(neutron_client):
return {'secgroups': dic_secgroups}
-def get_floatinips(nova_client):
+def get_floatingips(neutron_client):
logger.debug("Getting Floating IPs...")
dic_floatingips = {}
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if not (floatingips is None or len(floatingips) == 0):
for floatingip in floatingips:
- dic_floatingips.update({floatingip.id: floatingip.ip})
+ dic_floatingips.update({floatingip['id']:
+ floatingip['floating_ip_address']})
return {'floatingips': dic_floatingips}
@@ -150,7 +151,7 @@ def main():
snapshot.update(get_networks(neutron_client))
snapshot.update(get_routers(neutron_client))
snapshot.update(get_security_groups(neutron_client))
- snapshot.update(get_floatinips(nova_client))
+ snapshot.update(get_floatingips(neutron_client))
snapshot.update(get_users(keystone_client))
snapshot.update(get_tenants(keystone_client))
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index 3e27d672..a50bf179 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -181,14 +181,10 @@ def get_endpoint(service_type, endpoint_type='publicURL'):
def get_session(other_creds={}):
auth = get_session_auth(other_creds)
- cacert = os.getenv('OS_CACERT')
- if cacert is not None:
- if not os.path.isfile(cacert):
- raise Exception("The 'OS_CACERT' environment"
- "variable is set to %s but the file"
- "does not exist.", cacert)
-
- return session.Session(auth=auth, verify=cacert)
+ https_cacert = os.getenv('OS_CACERT', '')
+ https_insecure = os.getenv('OS_INSECURE', '').lower() == 'true'
+ return session.Session(auth=auth,
+ verify=(https_cacert or not https_insecure))
# *********************************************
@@ -426,12 +422,12 @@ def get_or_create_flavor(flavor_name, ram, disk, vcpus, public=True):
return flavor_exists, flavor_id
-def get_floating_ips(nova_client):
+def get_floating_ips(neutron_client):
try:
- floating_ips = nova_client.floating_ips.list()
- return floating_ips
+ floating_ips = neutron_client.list_floatingips()
+ return floating_ips['floatingips']
except Exception as e:
- logger.error("Error [get_floating_ips(nova_client)]: %s" % e)
+ logger.error("Error [get_floating_ips(neutron_client)]: %s" % e)
return None
@@ -594,12 +590,12 @@ def delete_instance(nova_client, instance_id):
return False
-def delete_floating_ip(nova_client, floatingip_id):
+def delete_floating_ip(neutron_client, floatingip_id):
try:
- nova_client.floating_ips.delete(floatingip_id)
+ neutron_client.delete_floatingip(floatingip_id)
return True
except Exception as e:
- logger.error("Error [delete_floating_ip(nova_client, '%s')]: %s"
+ logger.error("Error [delete_floating_ip(neutron_client, '%s')]: %s"
% (floatingip_id, e))
return False