summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/functest_utils.py30
-rwxr-xr-xutils/openstack_utils.py42
2 files changed, 67 insertions, 5 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index b916ab129..199088b9c 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -200,11 +200,30 @@ def push_results_to_db(project, case_name, logger,
"""
# Retrieve params from CI and conf
url = get_db_url(logger) + "/results"
- installer = get_installer_type(logger)
- scenario = get_scenario(logger)
- version = get_version(logger)
- pod_name = get_pod_name(logger)
- build_tag = get_build_tag(logger)
+
+ try:
+ installer = os.environ['INSTALLER_TYPE']
+ scenario = os.environ['DEPLOY_SCENARIO']
+ pod_name = os.environ['NODE_NAME']
+ build_tag = os.environ['BUILD_TAG']
+ except KeyError as e:
+ msg = "Please set env var: " + str(e)
+ if logger:
+ logger.error(msg)
+ else:
+ print(msg)
+ return False
+ rule = "daily-(.+?)-[0-9]*"
+ m = re.search(rule, build_tag)
+ if m:
+ version = m.group(1)
+ else:
+ msg = "Please fix BUILD_TAG env var: " + build_tag
+ if logger:
+ logger.error(msg)
+ else:
+ print(msg)
+ return False
test_start = dt.fromtimestamp(start_date).strftime('%Y-%m-%d %H:%M:%S')
test_stop = dt.fromtimestamp(stop_date).strftime('%Y-%m-%d %H:%M:%S')
@@ -320,6 +339,7 @@ def execute_command(cmd, logger=None,
logger.debug(line)
else:
print line
+ sys.stdout.flush()
p.stdout.close()
returncode = p.wait()
if returncode != 0:
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index d30ca629c..bc718bb2b 100755
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -671,6 +671,28 @@ def create_network_full(neutron_client,
return network_dic
+def create_shared_network_full(net_name, subnt_name, router_name, subnet_cidr):
+ neutron_client = get_neutron_client()
+
+ network_dic = create_network_full(neutron_client,
+ net_name,
+ subnt_name,
+ router_name,
+ subnet_cidr)
+ if network_dic:
+ if not update_neutron_net(neutron_client,
+ network_dic['net_id'],
+ shared=True):
+ logger.error("Failed to update network %s..." % net_name)
+ return None
+ else:
+ logger.debug("Network '%s' is available..." % net_name)
+ else:
+ logger.error("Network %s creation failed" % net_name)
+ return None
+ return network_dic
+
+
def create_bgpvpn(neutron_client, **kwargs):
# route_distinguishers
# route_targets
@@ -889,6 +911,26 @@ def create_glance_image(glance_client, image_name, file_path, disk="qcow2",
return None
+def get_or_create_image(name, path, format):
+ image_exists = False
+ glance_client = get_glance_client()
+
+ image_id = get_image_id(glance_client, name)
+ if image_id != '':
+ logger.info("Using existing image '%s'..." % name)
+ image_exists = True
+ else:
+ logger.info("Creating image '%s' from '%s'..." % (name, path))
+ image_id = create_glance_image(glance_client, name, path, format)
+ if not image_id:
+ logger.error("Failed to create a Glance image...")
+ else:
+ logger.debug("Image '%s' with ID=%s created successfully."
+ % (name, image_id))
+
+ return image_exists, image_id
+
+
def delete_glance_image(nova_client, image_id):
try:
nova_client.images.delete(image_id)