aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/VIM
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/VIM')
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/check_os.sh12
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/clean_openstack.py91
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/generate_defaults.py34
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/run_tempest.py1
4 files changed, 92 insertions, 46 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/check_os.sh b/testcases/VIM/OpenStack/CI/libraries/check_os.sh
index 63d4ea69..ab3d2192 100755
--- a/testcases/VIM/OpenStack/CI/libraries/check_os.sh
+++ b/testcases/VIM/OpenStack/CI/libraries/check_os.sh
@@ -37,7 +37,7 @@ if [ $RETVAL -ne 0 ]; then
fi
echo " ...OK"
-adminURL=$(keystone catalog --service identity 2>/dev/null|grep adminURL|awk '{print $4}')
+adminURL=$(openstack catalog show identity |grep adminURL|awk '{print $4}')
adminIP=$(echo $adminURL|sed 's/^.*http\:\/\///'|sed 's/.[^:]*$//')
adminPort=$(echo $adminURL|sed 's/^.*://'|sed 's/.[^\/]*$//')
echo ">>Verifying connectivity to the admin endpoint $adminIP:$adminPort..."
@@ -52,7 +52,7 @@ echo " ...OK"
echo "Checking OpenStack basic services:"
-commands=('keystone endpoint-list' 'nova list' 'neutron net-list' \
+commands=('openstack endpoint list' 'nova list' 'neutron net-list' \
'glance image-list' 'cinder list')
for cmd in "${commands[@]}"
do
@@ -105,9 +105,9 @@ echo "neutron router-list:"
neutron router-list
echo "neutron security-group-list:"
neutron security-group-list
-echo "keystone tenant-list:"
-keystone tenant-list
-echo "keystone user-list:"
-keystone user-list
+echo "openstack project list:"
+openstack project list
+echo "openstack user list:"
+openstack user list
exit 0
diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
index 464defcc..e4775005 100644
--- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
+++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
@@ -59,20 +59,26 @@ if not os.path.exists(REPO_PATH):
sys.path.append(REPO_PATH + "testcases/")
import functest_utils
-with open(REPO_PATH+"testcases/VIM/OpenStack/CI/libraries/os_defaults.yaml") as f:
- defaults_yaml = yaml.safe_load(f)
-f.close()
-
-installer = os.environ["INSTALLER_TYPE"]
+DEFAULTS_FILE = '/home/opnfv/functest/conf/os_defaults.yaml'
+
+try:
+ with open(DEFAULTS_FILE) as f:
+ defaults_yaml = yaml.safe_load(f)
+except Exception, e:
+ logger.info("The file %s does not exist. Please run generate_defaults.py "
+ "to create the OpenStack defaults. "
+ "Aborting cleanup..." % DEFAULTS_FILE)
+ exit(0)
-default_images = defaults_yaml.get(installer).get("images")
-default_networks = defaults_yaml.get(installer).get("networks") +\
- defaults_yaml.get("common").get("networks")
-default_routers = defaults_yaml.get(installer).get("routers") +\
- defaults_yaml.get("common").get("routers")
-default_security_groups = defaults_yaml.get(installer).get("security_groups")
-default_users = defaults_yaml.get(installer).get("users")
-default_tenants = defaults_yaml.get(installer).get("tenants")
+default_images = defaults_yaml.get('images')
+default_instances = defaults_yaml.get('instances')
+default_volumes = defaults_yaml.get('volumes')
+default_networks = defaults_yaml.get('networks')
+default_routers = defaults_yaml.get('routers')
+default_security_groups = defaults_yaml.get('secgroups')
+default_floatingips = defaults_yaml.get('floatingips')
+default_users = defaults_yaml.get('users')
+default_tenants = defaults_yaml.get('tenants')
def separator():
logger.info("-------------------------------------------")
@@ -116,7 +122,7 @@ def remove_images(nova_client):
image_name = getattr(image, 'name')
image_id = getattr(image, 'id')
logger.debug("'%s', ID=%s " %(image_name,image_id))
- if image_name not in default_images:
+ if image_id not in default_images:
logger.debug("Removing image '%s', ID=%s ..." % (image_name,image_id))
if functest_utils.delete_glance_image(nova_client, image_id):
logger.debug(" > Done!")
@@ -136,19 +142,23 @@ def remove_volumes(cinder_client):
for volume in volumes:
volume_id = getattr(volume, 'id')
- logger.debug("Removing cinder volume %s ..." % volume_id)
- if functest_utils.delete_volume(cinder_client, volume_id):
- logger.debug(" > Done!")
- else:
- logger.debug("Trying forced removal...")
- if functest_utils.delete_volume(cinder_client,
- volume_id,
- forced=True):
+ volume_name = getattr(volume, 'display_name')
+ logger.debug("'%s', ID=%s " %(volume_name,volume_id))
+ if volume_id not in default_volumes:
+ logger.debug("Removing cinder volume %s ..." % volume_id)
+ if functest_utils.delete_volume(cinder_client, volume_id):
logger.debug(" > Done!")
else:
- logger.error("There has been a problem removing the "
- "volume %s..." % volume_id)
-
+ logger.debug("Trying forced removal...")
+ if functest_utils.delete_volume(cinder_client,
+ volume_id,
+ forced=True):
+ logger.debug(" > Done!")
+ else:
+ logger.error("There has been a problem removing the "
+ "volume %s..." % volume_id)
+ else:
+ logger.debug(" > this is a default volume and will NOT be deleted.")
def remove_floatingips(nova_client):
logger.info("Removing floating IPs...")
@@ -157,19 +167,28 @@ def remove_floatingips(nova_client):
logger.debug("No floating IPs found.")
return
+ init_len = len(floatingips)
+ deleted = 0
for fip in floatingips:
fip_id = getattr(fip, 'id')
- logger.debug("Removing floating IP %s ..." % fip_id)
- if functest_utils.delete_floating_ip(nova_client, fip_id):
- logger.debug(" > Done!")
+ fip_ip = getattr(fip, 'ip')
+ logger.debug("'%s', ID=%s " %(fip_ip,fip_id))
+ if fip_id not in default_floatingips:
+ logger.debug("Removing floating IP %s ..." % fip_id)
+ if functest_utils.delete_floating_ip(nova_client, fip_id):
+ logger.debug(" > Done!")
+ deleted += 1
+ else:
+ logger.error("There has been a problem removing the "
+ "floating IP %s..." % fip_id)
else:
- logger.error("There has been a problem removing the "
- "floating IP %s..." % fip_id)
+ logger.debug(" > this is a default floating IP and will NOT be deleted.")
+
timeout = 50
while timeout > 0:
floatingips = functest_utils.get_floating_ips(nova_client)
- if floatingips is None or len(floatingips) == 0:
+ if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
logger.debug("Waiting for floating ips to be released...")
@@ -189,7 +208,7 @@ def remove_networks(neutron_client):
net_id = network['id']
net_name = network['name']
logger.debug(" '%s', ID=%s " %(net_name,net_id))
- if net_name in default_networks:
+ if net_id in default_networks:
logger.debug(" > this is a default network and will NOT be deleted.")
elif network['router:external'] == True:
logger.debug(" > this is an external network and will NOT be deleted.")
@@ -273,7 +292,7 @@ def remove_routers(neutron_client, routers):
for router in routers:
router_id = router['id']
router_name = router['name']
- if router_name not in default_routers:
+ if router_id not in default_routers:
logger.debug("Checking '%s' with ID=(%s) ..." % (router_name,router_id))
if router['external_gateway_info'] != None:
logger.debug("Router has gateway to external network. Removing link...")
@@ -303,7 +322,7 @@ def remove_security_groups(neutron_client):
secgroup_name = secgroup['name']
secgroup_id = secgroup['id']
logger.debug("'%s', ID=%s " %(secgroup_name,secgroup_id))
- if secgroup_name not in default_security_groups:
+ if secgroup_id not in default_security_groups:
logger.debug(" Removing '%s'..." % secgroup_name)
if functest_utils.delete_security_group(neutron_client, secgroup_id):
logger.debug(" > Done!")
@@ -326,7 +345,7 @@ def remove_users(keystone_client):
user_name = getattr(user, 'name')
user_id = getattr(user, 'id')
logger.debug("'%s', ID=%s " %(user_name,user_id))
- if user_name not in default_users:
+ if user_id not in default_users:
logger.debug(" Removing '%s'..." % user_name)
if functest_utils.delete_user(keystone_client,user_id):
logger.debug(" > Done!")
@@ -348,7 +367,7 @@ def remove_tenants(keystone_client):
tenant_name=getattr(tenant, 'name')
tenant_id = getattr(tenant, 'id')
logger.debug("'%s', ID=%s " %(tenant_name,tenant_id))
- if tenant_name not in default_tenants:
+ if tenant_id not in default_tenants:
logger.debug(" Removing '%s'..." % tenant_name)
if functest_utils.delete_tenant(keystone_client,tenant_id):
logger.debug(" > Done!")
diff --git a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
index 0c88c2fd..72987ddd 100644
--- a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
+++ b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
@@ -39,7 +39,7 @@ args = parser.parse_args()
""" logging configuration """
-logger = logging.getLogger('clean_openstack')
+logger = logging.getLogger('generate_defaults')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
@@ -85,8 +85,18 @@ def get_images(nova_client):
return {'images': dic_images}
+def get_volumes(cinder_client):
+ logger.debug("Getting volumes...")
+ dic_volumes = {}
+ volumes = functest_utils.get_volumes(cinder_client)
+ if volumes != None:
+ for volume in volumes:
+ dic_volumes.update({volume.id:volume.display_name})
+ return {'volumes': dic_volumes}
+
+
def get_networks(neutron_client):
- logger.info("Getting networks")
+ logger.debug("Getting networks")
dic_networks = {}
networks = functest_utils.get_network_list(neutron_client)
if networks != None:
@@ -94,8 +104,9 @@ def get_networks(neutron_client):
dic_networks.update({network['id']:network['name']})
return {'networks': dic_networks}
+
def get_routers(neutron_client):
- logger.info("Getting routers")
+ logger.debug("Getting routers")
dic_routers = {}
routers = functest_utils.get_router_list(neutron_client)
if routers != None:
@@ -105,7 +116,7 @@ def get_routers(neutron_client):
def get_security_groups(neutron_client):
- logger.info("Getting Security groups...")
+ logger.debug("Getting Security groups...")
dic_secgroups = {}
secgroups = functest_utils.get_security_groups(neutron_client)
if not (secgroups is None or len(secgroups) == 0):
@@ -114,6 +125,16 @@ def get_security_groups(neutron_client):
return {'secgroups': dic_secgroups}
+def get_floatinips(nova_client):
+ logger.debug("Getting Floating IPs...")
+ dic_floatingips = {}
+ floatingips = functest_utils.get_floating_ips(nova_client)
+ if not (floatingips is None or len(floatingips) == 0):
+ for floatingip in floatingips:
+ dic_floatingips.update({floatingip.id:floatingip.ip})
+ return {'floatingips': dic_floatingips}
+
+
def get_users(keystone_client):
logger.debug("Getting users...")
dic_users = {}
@@ -158,16 +179,21 @@ def main():
defaults = {}
defaults.update(get_instances(nova_client))
defaults.update(get_images(nova_client))
+ defaults.update(get_volumes(cinder_client))
defaults.update(get_networks(neutron_client))
defaults.update(get_routers(neutron_client))
defaults.update(get_security_groups(neutron_client))
+ defaults.update(get_floatinips(nova_client))
defaults.update(get_users(keystone_client))
defaults.update(get_tenants(keystone_client))
with open(DEFAULTS_FILE, 'w+') as yaml_file:
yaml_file.write(yaml.safe_dump(defaults, default_flow_style=False))
yaml_file.seek(0)
+ logger.info("Openstack Defaults found in the deployment:")
print yaml_file.read()
+ logger.debug("NOTE: These objects will NOT be deleted after "+\
+ "running the tests.")
exit(0)
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
index 3b937e92..6b153057 100644
--- a/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_tempest.py
@@ -19,6 +19,7 @@ import logging
import os
import re
import requests
+import shutil
import subprocess
import sys
import time