Small fixes and improvements: in cleanup, cmp_check, offline scripts
* cmp_check: use the specific vm prefix name
* cleanup.py: check whether Obj Store is present, check if volume
backup service is enabled
* init-workspace: choose the first ext net
* update-openstack-resources: remove the typo line
Related-PROD: PROD-37187
Change-Id: I6053d8e715f7f64425f7952c868e9c0a253fe677
(cherry picked from commit bbe0f445085adfbc73709402e6af2bf5bac46c78)
(cherry picked from commit 66dbe12789e28a09e6e54183aeed1f88ddfdbe3a)
diff --git a/cleanup.py b/cleanup.py
index b69cd62..f641a95 100644
--- a/cleanup.py
+++ b/cleanup.py
@@ -29,10 +29,15 @@
image = cloud.image
network = cloud.network
orchestration = cloud.orchestration
-object_store = cloud.object_store
volume = cloud.volume
load_balancer = cloud.load_balancer
+# Check if Object Storage is present on the cloud, else skip
+object_store_present = any(service.type == 'object-store' for service
+ in list(identity.services()))
+if object_store_present:
+ object_store = cloud.object_store
+
mask = "cvp|s_rally|rally_|tempest-|tempest_|spt|fio"
full_mask = f"^(?!.*(manual|-static-)).*({mask}).*$"
mask_pattern = re.compile(full_mask, re.IGNORECASE)
@@ -454,7 +459,10 @@
cleanup_load_balancers()
cleanup_servers()
cleanup_flavors()
- cleanup_volume_backups()
+ try: # Skip if cinder-backup service is not enabled
+ cleanup_volume_backups()
+ except openstack.exceptions.ResourceNotFound:
+ pass
cleanup_snapshots()
cleanup_volumes()
cleanup_volume_groups()
@@ -469,7 +477,8 @@
cleanup_regions()
cleanup_routers()
cleanup_networks()
- cleanup_containers()
+ if object_store_present:
+ cleanup_containers()
cleanup_floating_ips()
if args.projects:
diff --git a/k8s/workspace/init-workspace.sh b/k8s/workspace/init-workspace.sh
index 84ab960..4f8f00c 100644
--- a/k8s/workspace/init-workspace.sh
+++ b/k8s/workspace/init-workspace.sh
@@ -106,11 +106,11 @@
echo " "
keystone_pod=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml get pod -n openstack -o=custom-columns=NAME:.metadata.name | grep keystone-client)
- echo "# Extracting network"
- cmd="openstack network list --external -c Name -f value"
+ echo "# Extracting network: taking the first found external network"
+ cmd="openstack network list --external -c Name -f value | head -n1"
echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- "${cmd}"'"
vPUBNET=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- ${cmd})
- echo "-> 'openstack network list --external -c Name -f value': '${vPUBNET}'"
+ echo "-> 'openstack network list --external -c Name -f value | head -n1': '${vPUBNET}'"
ewriteln "export TEMPEST_CUSTOM_PUBLIC_NET=${vPUBNET}"
echo "# Extracting volume types"
diff --git a/k8s/workspace/update-openstack-resources.sh b/k8s/workspace/update-openstack-resources.sh
index 23f9c21..c8745d2 100644
--- a/k8s/workspace/update-openstack-resources.sh
+++ b/k8s/workspace/update-openstack-resources.sh
@@ -33,7 +33,6 @@
subnetid=$(kubectl exec toolset --stdin -n qa-space -- openstack subnet list -f value | grep ${netid} | cut -d' ' -f1)
echo "# image_ref_name -> ${cirros51_name}"
sed -i "s/image_ref_name/${cirros51_name}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
-image_ref_name
echo "# image_ref_uuid -> ${cirros51_id}"
sed -i "s/image_ref_uuid/${cirros51_id}/g" $MY_PROJFOLDER/yamls/tempest_custom.yaml
echo "# image_ref_alt_uuid -> ${cirros52_id}"
diff --git a/scripts/cmp_check.sh b/scripts/cmp_check.sh
index 58e841f..4aa5598 100644
--- a/scripts/cmp_check.sh
+++ b/scripts/cmp_check.sh
@@ -5,6 +5,7 @@
fill_mode=false
zone=nova
use_fqdn=false
+vm_name_prefix=cvp_test_vm_
tmp_out=$(mktemp)
trap "rm -f ${tmp_out}" EXIT
@@ -153,7 +154,7 @@
function clean_cmp() {
# #### Cleaning mode
if [ $cleaning = true ]; then
- vmname=vm_${1}
+ vmname=${vm_name_prefix}${1}
vmid=( $(getid ${vmname}) )
if [ ${#vmid[@]} -ne 0 ]; then
[ ! "$silent" = true ] && echo "# ${1}: cleaning ${#vmid[@]} VMs"
@@ -267,7 +268,7 @@
for node in ${cmp_nodes[@]}; do
echo "# ${node}: checking"
cname=$(echo ${node} | cut -d'.' -f1)
- check_cmp_node ${node} vm_${cname}
+ check_cmp_node ${node} ${vm_name_prefix}${cname}
echo "# ${node}: done"
done
errors
@@ -283,7 +284,7 @@
counter=1
while [[ $counter -lt ${vmcount}+1 ]]; do
cname=$(echo ${node} | cut -d'.' -f1)
- vmname_c=vm_${cname}_$(printf "%02d" ${counter})
+ vmname_c=${vm_name_prefix}${cname}_$(printf "%02d" ${counter})
[ ! "$silent" = true ] && echo "# ${node}: creating ${vmname_c}"
vm_create ${node} ${vmname_c}
cmp_stats ${node}