Move virsh calls to generic container
Relates-To: #517 Change-Id: I96178dfb9addbe76b8897bbe4cd58f150563b81a
This commit is contained in:
parent
a7cbd6bddc
commit
e88a5c5c1f
@ -7,3 +7,5 @@ resources:
|
|||||||
- wait_pods
|
- wait_pods
|
||||||
- pause_bmh
|
- pause_bmh
|
||||||
- wait_cluster
|
- wait_cluster
|
||||||
|
- virsh-eject-cdrom-images
|
||||||
|
- virsh-destroy-vms
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
configMapGenerator:
|
||||||
|
- name: virsh-destroy-vms
|
||||||
|
options:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
files:
|
||||||
|
- script=virsh_destroy_vms.sh
|
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
EPHEMERAL_DOMAIN_NAME="air-ephemeral"
|
||||||
|
|
||||||
|
if type "virsh" > /dev/null; then
|
||||||
|
for vm in $(virsh list --all --name --state-running |grep ${EPHEMERAL_DOMAIN_NAME})
|
||||||
|
do
|
||||||
|
echo "Stop ephemeral node '$vm'" 1>&2
|
||||||
|
virsh destroy $vm 1>&2
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Can't find virsh" 1>&2
|
||||||
|
fi
|
@ -0,0 +1,6 @@
|
|||||||
|
configMapGenerator:
|
||||||
|
- name: virsh-eject-cdrom-images
|
||||||
|
options:
|
||||||
|
disableNameSuffixHash: true
|
||||||
|
files:
|
||||||
|
- script=virsh_eject_cdrom_images.sh
|
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
EPHEMERAL_DOMAIN_NAME="air-ephemeral"
|
||||||
|
|
||||||
|
if type "virsh" > /dev/null; then
|
||||||
|
echo "Ensure all cdrom images are ejected." 1>&2
|
||||||
|
for vm in $(virsh list --all --name |grep -v ${EPHEMERAL_DOMAIN_NAME})
|
||||||
|
do
|
||||||
|
virsh domblklist $vm |
|
||||||
|
awk 'NF==2 {print $1}' |
|
||||||
|
grep -v Target |
|
||||||
|
xargs -I{} virsh change-media $vm {} --eject || : 1>&2
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Can't find virsh" 1>&2
|
||||||
|
fi
|
@ -423,3 +423,40 @@ configRef:
|
|||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
name: kubectl-wait-cluster
|
name: kubectl-wait-cluster
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: GenericContainer
|
||||||
|
metadata:
|
||||||
|
name: virsh-eject-cdrom-images
|
||||||
|
labels:
|
||||||
|
airshipit.org/deploy-k8s: "false"
|
||||||
|
spec:
|
||||||
|
image: quay.io/airshipit/toolbox-virsh:latest
|
||||||
|
hostNetwork: true
|
||||||
|
mounts:
|
||||||
|
- type: bind
|
||||||
|
src: /var/run/libvirt/libvirt-sock
|
||||||
|
dst: /var/run/libvirt/libvirt-sock
|
||||||
|
configRef:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: virsh-eject-cdrom-images
|
||||||
|
apiVersion: v1
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: GenericContainer
|
||||||
|
metadata:
|
||||||
|
name: virsh-destroy-vms
|
||||||
|
labels:
|
||||||
|
airshipit.org/deploy-k8s: "false"
|
||||||
|
spec:
|
||||||
|
image: quay.io/airshipit/toolbox-virsh:latest
|
||||||
|
hostNetwork: true
|
||||||
|
mounts:
|
||||||
|
- type: bind
|
||||||
|
src: /var/run/libvirt/libvirt-sock
|
||||||
|
dst: /var/run/libvirt/libvirt-sock
|
||||||
|
configRef:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: virsh-destroy-vms
|
||||||
|
apiVersion: v1
|
||||||
|
|
||||||
|
@ -390,3 +390,23 @@ config:
|
|||||||
kind: GenericContainer
|
kind: GenericContainer
|
||||||
name: kubectl-wait-cluster
|
name: kubectl-wait-cluster
|
||||||
documentEntryPoint: ephemeral/controlplane
|
documentEntryPoint: ephemeral/controlplane
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Phase
|
||||||
|
metadata:
|
||||||
|
name: virsh-eject-cdrom-images
|
||||||
|
config:
|
||||||
|
executorRef:
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: GenericContainer
|
||||||
|
name: virsh-eject-cdrom-images
|
||||||
|
---
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: Phase
|
||||||
|
metadata:
|
||||||
|
name: virsh-destroy-vms
|
||||||
|
config:
|
||||||
|
executorRef:
|
||||||
|
apiVersion: airshipit.org/v1alpha1
|
||||||
|
kind: GenericContainer
|
||||||
|
name: virsh-destroy-vms
|
||||||
|
@ -18,16 +18,10 @@ EPHEMERAL_DOMAIN_NAME="air-ephemeral"
|
|||||||
|
|
||||||
# TODO (dukov) this is needed due to sushy tools inserts cdrom image to
|
# TODO (dukov) this is needed due to sushy tools inserts cdrom image to
|
||||||
# all vms. This can be removed once sushy tool is fixed
|
# all vms. This can be removed once sushy tool is fixed
|
||||||
if type "virsh" > /dev/null; then
|
# Scripts for this phase placed in manifests/function/phase-helpers/virsh-eject-cdrom-images/
|
||||||
echo "Ensure all cdrom images are ejected."
|
# To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap`
|
||||||
for vm in $(sudo virsh list --all --name |grep -v ${EPHEMERAL_DOMAIN_NAME})
|
# and find ConfigMap with name virsh-eject-cdrom-images
|
||||||
do
|
airshipctl phase run virsh-eject-cdrom-images --debug
|
||||||
sudo virsh domblklist $vm |
|
|
||||||
awk 'NF==2 {print $1}' |
|
|
||||||
grep -v Target |
|
|
||||||
xargs -I{} sudo virsh change-media $vm {} --eject || :
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Create target k8s cluster resources"
|
echo "Create target k8s cluster resources"
|
||||||
airshipctl phase run controlplane-ephemeral --debug
|
airshipctl phase run controlplane-ephemeral --debug
|
||||||
|
@ -22,13 +22,10 @@ WORKER_NODE=${WORKER_NODE:-"node03"}
|
|||||||
EPHEMERAL_DOMAIN_NAME="air-ephemeral"
|
EPHEMERAL_DOMAIN_NAME="air-ephemeral"
|
||||||
|
|
||||||
# all vms. This can be removed once sushy tool is fixed
|
# all vms. This can be removed once sushy tool is fixed
|
||||||
if type "virsh" > /dev/null; then
|
# Scripts for this phase placed in manifests/function/phase-helpers/virsh-destroy-vms/
|
||||||
for vm in $(sudo virsh list --all --name --state-running |grep ${EPHEMERAL_DOMAIN_NAME})
|
# To get ConfigMap for this phase, execute `airshipctl phase render --source config -k ConfigMap`
|
||||||
do
|
# and find ConfigMap with name virsh-destroy-vms
|
||||||
echo "Stop ephemeral node '$vm'"
|
airshipctl phase run virsh-destroy-vms --debug
|
||||||
sudo virsh destroy $vm
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
node_timeout () {
|
node_timeout () {
|
||||||
end=$(($(date +%s) + $TIMEOUT))
|
end=$(($(date +%s) + $TIMEOUT))
|
||||||
|
Loading…
Reference in New Issue
Block a user