Skip to content

Commit b650e14

Browse files
committed
Add certificate check to deprov vsphere
1 parent ce8a760 commit b650e14

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

ci-operator/step-registry/ipi/deprovision/vsphere/diags/vcm/ipi-deprovision-vsphere-diags-vcm-commands.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ if ! whoami &> /dev/null; then
3737
fi
3838
fi
3939

40+
# if curl is ever updated we can use this instead
41+
#curl -o /dev/null -s -k -w "\n%{certs}\n" "https://api-int.${NAMESPACE}-${UNIQUE_HASH}.vmc-ci.devcluster.openshift.com:6443"
42+
43+
44+
45+
curl -kv "https://api-int.${NAMESPACE}-${UNIQUE_HASH}.vmc-ci.devcluster.openshift.com:6443" > ${ARTIFACT_DIR}/cluster-cert.txt
46+
47+
4048
function collect_sosreport {
4149
ADDRESS=$1
4250
echo "$(date -u --rfc-3339=seconds) - executing sos report at $ADDRESS"
@@ -67,7 +75,7 @@ function collect_sosreport_from_unprovisioned_machines {
6775
for MACHINE in ${MACHINES}; do
6876
echo "$(date -u --rfc-3339=seconds) - checking if machine $MACHINE lacks a nodeRef"
6977
NODEREF=$(oc get machines.machine.openshift.io -n openshift-machine-api $MACHINE -o=jsonpath='{.status.nodeRef}')
70-
78+
7179
if [ -z "$NODEREF" ]; then
7280
echo "$(date -u --rfc-3339=seconds) - attempting to collect sos report"
7381
ADDRESS=$(oc get machines.machine.openshift.io -n openshift-machine-api $MACHINE -o=jsonpath='{.status.addresses[0].address}')
@@ -170,7 +178,7 @@ function collect_diagnostic_data {
170178
VCENTER_COUNT=$(jq '.vcenters | length' "$SHARED_DIR"/platform.json)
171179
v_idx=0
172180

173-
181+
174182
while [[ $v_idx -lt $VCENTER_COUNT ]]; do
175183
VCENTER=$(jq -c -r '.vcenters['${v_idx}']' "$SHARED_DIR"/platform.json)
176184
GOVC_URL=$(echo $VCENTER | jq -r '.server')
@@ -183,7 +191,7 @@ function collect_diagnostic_data {
183191

184192
IFS=$'\n' read -d '' -r -a all_hosts <<< "$(govc find . -type h -runtime.powerState poweredOn)"
185193
IFS=$'\n' read -d '' -r -a PORTGROUPS <<< "$(jq -r -c --arg vcenter "${GOVC_URL}" '[.failureDomains[] | select(.server == $vcenter) | .topology.networks[]] | unique | .[]' < "$SHARED_DIR"/platform.json)"
186-
194+
187195
if [ -z ${PORTGROUPS:-} ]; then
188196
echo "${GOVC_URL}; port groups in failure domain: ${#PORTGROUPS[@]}"
189197
v_idx=$((v_idx+1));
@@ -197,17 +205,17 @@ function collect_diagnostic_data {
197205

198206
IFS=$'\n' read -d '' -r -a networks <<< "$(govc find -type=n -i=true -name ${PORTGROUP})"
199207

200-
if [ -z ${networks:-} ]; then
208+
if [ -z ${networks:-} ]; then
201209
echo "No networks found associated with port group ${PORTGROUP}: $(govc find -type=n -i=true -name ${PORTGROUP})"
202210
v_idx=$((v_idx+1));
203211
continue
204212
fi
205-
213+
206214
echo "${GOVC_URL}; ${PORTGROUP}; found networks: ${#networks[@]}"
207215

208216
for network in "${networks[@]}"; do
209217
IFS=$'\n' read -d '' -r -a vms <<< "$(govc find . -type m -runtime.powerState poweredOn -network $network)"
210-
if [ -z ${vms:-} ]; then
218+
if [ -z ${vms:-} ]; then
211219
echo "No VMs found associated with network ${network} $(govc find . -type m -runtime.powerState poweredOn -network $network)"
212220
continue
213221
fi
@@ -251,16 +259,16 @@ function collect_diagnostic_data {
251259
done
252260
done
253261
done
254-
262+
255263
if [ -n "${vms:-}" ]; then
256264
target_hw_version=$(govc vm.info -json=true "${vms[0]}" | jq -r .VirtualMachines[0].Config.Version)
257-
echo "{\"hw_version\": \"${target_hw_version}\", \"cloud\": \"${cloud_where_run}\"}" > "${ARTIFACT_DIR}/runtime-config.json"
265+
echo "{\"hw_version\": \"${target_hw_version}\", \"cloud\": \"${cloud_where_run}\"}" > "${ARTIFACT_DIR}/runtime-config.json"
258266
fi
259267

260268
if [ -n "${JSON_DATA:-}" ]; then
261269
echo ${JSON_DATA} > "${vcenter_state}/metric-files.json"
262-
fi
263-
270+
fi
271+
264272
v_idx=$((v_idx+1));
265273
done
266274

@@ -314,7 +322,7 @@ function embed_topology_data() {
314322
POD=$(jq --compact-output -r .spec.podName < "${NETWORK}")
315323
DATACENTER=$(jq --compact-output -r .spec.datacenterName < "${NETWORK}")
316324
CIDR=$(jq --compact-output -r .spec.machineNetworkCidr < "${NETWORK}")
317-
GATEWAY=$(jq --compact-output -r .spec.gateway < "${NETWORK}")
325+
GATEWAY=$(jq --compact-output -r .spec.gateway < "${NETWORK}")
318326

319327
echo "Network: ${NAME}<br>" >> "${RESULT_HTML}"
320328
echo "- VLAN: ${VLAN}<br>" >> "${RESULT_HTML}"
@@ -363,7 +371,7 @@ function embed_vm_data() {
363371
echo "<script type='application/json' id='${VM}-screenshot'>" >> ${RESULT_HTML}
364372
SCREENSHOT_BASE64=$(jq -r --arg VM "${VM}" '.vms[] | select(.name == $VM) | .screenshot' ${vcenter_state}/metric-files.json)
365373
echo $SCREENSHOT_BASE64 >> ${RESULT_HTML}
366-
echo "</script>" >> ${RESULT_HTML}
374+
echo "</script>" >> ${RESULT_HTML}
367375
done
368376
}
369377

@@ -446,7 +454,7 @@ EOF
446454

447455
embed_topology_data
448456

449-
cat >> "${RESULT_HTML}" << EOF
457+
cat >> "${RESULT_HTML}" << EOF
450458
</data>
451459
<data id="vm-data">
452460
<div id="vm-data-content">

0 commit comments

Comments
 (0)