Browse Source

Check return value of get subnets before iterate for ironic

With the update of openstack clients within heat image:
openstack client >= 4.0.0
neutron client >= 6.14.0
neturon lib >= 1.29.1

The command 'openstack network show ${network} -f value -c subnets'
returns '[]' instead of null string if no subnets found in the
specific network. This commit adds a check logic to avoid subsequent
command returns error by using '[]' as subnet input.

Change-Id: I695e504518e1c884c7d66ecc94c9fa8787ce9752
Closes-Bug: 1855319
Signed-off-by: Mingyuan Qi <mingyuan.qi@intel.com>
changes/19/698619/3
Mingyuan Qi 2 years ago
parent
commit
a4503a28ac
  1. 2
      openstack-helm/centos/openstack-helm.spec
  2. 52
      openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch

2
openstack-helm/centos/openstack-helm.spec

@ -26,6 +26,7 @@ Patch04: 0004-Nova-chart-Support-ephemeral-pool-creation.patch
Patch05: 0005-Nova-Add-support-for-disabling-Readiness-Liveness-pr.patch
Patch06: 0006-Add-Placement-Chart.patch
Patch07: 0007-Support-ingress-creation-for-keystone-admin-endpoint.patch
Patch08: 0008-Check-return-value-of-get-subnets-before-iterate-for.patch
BuildRequires: helm
BuildRequires: openstack-helm-infra
@ -43,6 +44,7 @@ Openstack Helm charts
%patch05 -p1
%patch06 -p1
%patch07 -p1
%patch08 -p1
%build
# initialize helm and build the toolkit

52
openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch

@ -0,0 +1,52 @@
From 29a7eea2465284bc5ed5a8f95bc14d6c6c9f0e5e Mon Sep 17 00:00:00 2001
From: Mingyuan Qi <mingyuan.qi@intel.com>
Date: Wed, 11 Dec 2019 08:48:09 +0000
Subject: [PATCH] Check return value of get subnets before iterate for ironic
With the update of openstack clients:
openstack client >= 4.0.0
neutron client >= 6.14.0
neturon lib >= 1.29.1
The command 'openstack network show ${network} -f value -c subnets'
returns '[]' instead of null string if no subnets found in the
specific network. This commit adds a check logic to avoid subsequent
command returns error by using '[]' as subnet input.
Change-Id: I7e7d5209227b0e34131b7715dbd3faa6066a94b7
Signed-off-by: Mingyuan Qi <mingyuan.qi@intel.com>
---
ironic/templates/bin/_manage-cleaning-network.sh.tpl | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/ironic/templates/bin/_manage-cleaning-network.sh.tpl b/ironic/templates/bin/_manage-cleaning-network.sh.tpl
index 47381a1..2a2af3a 100644
--- a/ironic/templates/bin/_manage-cleaning-network.sh.tpl
+++ b/ironic/templates/bin/_manage-cleaning-network.sh.tpl
@@ -28,13 +28,16 @@ else
IRONIC_NEUTRON_CLEANING_NET_ID=$(openstack network show ${neutron_network_name} -f value -c id)
fi
-for SUBNET in $(openstack network show $IRONIC_NEUTRON_CLEANING_NET_ID -f value -c subnets); do
- CURRENT_SUBNET=$(openstack subnet show $SUBNET -f value -c name)
- if [ "x${CURRENT_SUBNET}" == "x${neutron_subnet_name}" ]; then
- openstack subnet show ${neutron_subnet_name}
- SUBNET_EXISTS=true
- fi
-done
+SUBNETS=$(openstack network show $IRONIC_NEUTRON_CLEANING_NET_ID -f value -c subnets)
+if [ "x${SUBNETS}" != "x[]" ]; then
+ for SUBNET in ${SUBNETS}; do
+ CURRENT_SUBNET=$(openstack subnet show $SUBNET -f value -c name)
+ if [ "x${CURRENT_SUBNET}" == "x${neutron_subnet_name}" ]; then
+ openstack subnet show ${neutron_subnet_name}
+ SUBNET_EXISTS=true
+ fi
+ done
+fi
if [ "x${SUBNET_EXISTS}" != "xtrue" ]; then
openstack subnet create \
--
1.8.3.1
Loading…
Cancel
Save