Skip to content

Commit d11698e

Browse files
author
Cloud User
committed
Cleaning script
1 parent 08e1c15 commit d11698e

File tree

6 files changed

+74
-36
lines changed

6 files changed

+74
-36
lines changed

Support/Multitenancy/ironic-env/03-images-and-run-local-services.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ REGISTRY_NAME="registry"
33
REGISTRY_PORT="5000"
44
IMAGE_NAMES=(
55
"quay.io/metal3-io/ironic-python-agent"
6-
# "quay.io/metal3-io/sushy-tools"
76
"quay.io/metal3-io/ironic-ipa-downloader"
87
"quay.io/metal3-io/ironic:latest"
98
"quay.io/metal3-io/ironic-client"
@@ -29,12 +28,15 @@ for NAME in "${IMAGE_NAMES[@]}"; do
2928
# Push the image to the local registry
3029
podman push --tls-verify=false 127.0.0.1:5000/localimages/"${NAME##*/}"
3130
done
31+
# build sushytools-fakeipa image
32+
bash build-sushytools-fakeipa-image.sh
33+
podman tag sushytools-fakeipa 127.0.0.1:"$REGISTRY_PORT"/localimages/sushytools-fakeipa
34+
podman push --tls-verify=false 127.0.0.1:5000/localimages/sushytools-fakeipa
3235

3336
# Define variables for repeated values
3437
IRONIC_IMAGE="127.0.0.1:5000/localimages/ironic:latest"
35-
# SUSHY_TOOLS_IMAGE="127.0.0.1:5000/localimages/sushy-tools"
36-
# FAKEIPA_IMAGE="127.0.0.1:5000/localimages/fakeipa"
37-
SUSHY_TOOLS_IMAGE="127.0.0.1:5000/localimages/fakeipa"
38+
FAKEIPA_IMAGE="127.0.0.1:5000/localimages/sushytools-fakeipa"
39+
SUSHY_TOOLS_IMAGE="127.0.0.1:5000/localimages/sushytools-fakeipa"
3840
LIBVIRT_URI="qemu+ssh://[email protected]/system?&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1"
3941
API_URL="http://172.22.0.2:6385"
4042
CALLBACK_URL="http://172.22.0.2:5050/v1/continue"
@@ -67,7 +69,7 @@ macgen(){
6769
rm -f nodes.json
6870
echo [] > nodes.json
6971

70-
for i in $(seq 1 ${NUM_NODES:-100}); do
72+
for i in $(seq 1 "${NUM_NODES:-100}"); do
7173
uuid=$(uuidgen)
7274
macaddr=$(macgen)
7375
name="fake${i}"
@@ -126,4 +128,4 @@ podman run --entrypoint='["sushy-fake-ipa", "--config", "/root/sushy/conf.py"]'
126128
-d --net host --name fake-ipa --pod infra-pod \
127129
-v /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools:/root/sushy \
128130
-v /root/.ssh:/root/ssh \
129-
"${SUSHY_TOOLS_IMAGE}"
131+
"${FAKEIPA_IMAGE}"

Support/Multitenancy/ironic-env/06-create-nodes.sh

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,55 @@
11
#!/bin/bash
22

3-
# for node in $(jq -c '.[]' nodes.json); do
4-
# uuid=$(echo ${node} | jq -r '.uuid')
5-
# node_name=$(echo ${node} | jq -r '.name')
6-
# baremetal node create --driver redfish --driver-info \
7-
# redfish_address=http://192.168.111.1:8000 --driver-info \
8-
# redfish_system_id=/redfish/v1/Systems/${uuid} --driver-info \
9-
# redfish_username=admin --driver-info redfish_password=password \
10-
# --uuid ${uuid} \
11-
# --name ${node_name}
12-
# done
13-
#
14-
# sleep 10
3+
for node in $(jq -c '.[]' nodes.json); do
4+
uuid=$(echo "${node}" | jq -r '.uuid')
5+
node_name=$(echo "${node}" | jq -r '.name')
6+
baremetal node create --driver redfish --driver-info \
7+
redfish_address=http://192.168.111.1:8000 --driver-info \
8+
redfish_system_id=/redfish/v1/Systems/"${uuid}" --driver-info \
9+
redfish_username=admin --driver-info redfish_password=password \
10+
--uuid "${uuid}" \
11+
--name "${node_name}"
12+
done
13+
14+
sleep 10
1515
nodes=$(baremetal node list -f json)
16-
n_nodes=$(echo ${nodes} | jq -c '.[]' | wc -l)
16+
n_nodes=$(echo "${nodes}" | jq -c '.[]' | wc -l)
1717
inspected_nodes=""
1818
while true; do
1919
nodes=$(baremetal node list -f json)
20-
for row in $(echo $nodes | jq -c -r '.[] | @base64'); do
21-
node=$(echo ${row} | base64 --decode)
22-
node_name=$(echo ${node} | jq -r '.Name')
23-
provisioning_state=$(echo ${node} | jq -r '."Provisioning State"')
20+
for row in $(echo "$nodes" | jq -c -r '.[] | @base64'); do
21+
node=$(echo "${row}" | base64 --decode)
22+
node_name=$(echo "${node}" | jq -r '.Name')
23+
provisioning_state=$(echo "${node}" | jq -r '."Provisioning State"')
2424
if [[ $provisioning_state == "enroll" ]]; then
25-
baremetal node manage ${node_name}
25+
baremetal node manage "${node_name}"
2626
continue
2727
fi
2828
if [[ $provisioning_state == "verifying" ]]; then
2929
continue
3030
fi
31-
power_state=$(echo ${node} | jq -r '."Power State"')
32-
if [[ $power_state == "power off" ]]; then
33-
baremetal node power on ${node_name}
34-
continue
35-
fi
3631
if [[ $provisioning_state == "inspect wait" ]]; then
3732
continue
3833
fi
3934
if [[ $provisioning_state == "manageable" ]]; then
40-
inspection_info=$(baremetal node show $node_name -f json | jq -r '.inspection_finished_at')
35+
inspection_info=$(baremetal node show "$node_name" -f json | jq -r '.inspection_finished_at')
4136
if [[ $inspection_info == "null" ]]; then
42-
baremetal node inspect ${node_name}
37+
baremetal node inspect "${node_name}"
4338
else
4439
if [[ $inspected_nodes == *$node_name* ]]; then
4540
continue
4641
fi
4742
inspected_nodes="${inspected_nodes} ${node_name}"
4843
echo "${node_name} was inspected at ${inspection_info}"
49-
if [[ $(echo $inspected_nodes | wc -w) == $n_nodes ]]; then
44+
if [[ $(echo "$inspected_nodes" | wc -w) == "$n_nodes" ]]; then
5045
exit 0
5146
fi
5247
fi
5348
fi
5449
if [[ $provisioning_state == "inspect failed" ]]; then
5550
inspected_nodes="${inspected_nodes} ${node_name}"
5651
echo "Failed to inspect ${node_name}"
57-
if [[ $(echo $inspected_nodes | wc -w) == $n_nodes ]]; then
52+
if [[ $(echo "$inspected_nodes" | wc -w) == "$n_nodes" ]]; then
5853
exit 0
5954
fi
6055
fi
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
mkdir fakeipa && cd fakeipa || exit
2+
3+
# clone repo
4+
git clone https://opendev.org/openstack/sushy-tools.git && cd sushy-tools || exit
5+
git fetch https://review.opendev.org/openstack/sushy-tools refs/changes/66/875366/16 && git checkout FETCH_HEAD && cd ..
6+
# create dockerfile
7+
cat <<EOF >Dockerfile
8+
FROM docker.io/library/python:3.9
9+
10+
ARG DEBIAN_FRONTEND=noninteractive
11+
ADD sushy-tools ./sushy-tools
12+
WORKDIR sushy-tools
13+
RUN apt-get update && apt-get install -y libvirt-dev && apt-get clean && pip3 install --no-cache-dir libvirt-python
14+
RUN pip install -r requirements.txt
15+
RUN python setup.py install
16+
17+
CMD /usr/local/bin/sushy-emulator -i :: \
18+
--config /root/sushy/conf.py --debug
19+
EOF
20+
21+
22+
# build image
23+
sudo podman build -t sushytools-fakeipa .
24+
cd .. && rm -rf fakeipa

Support/Multitenancy/ironic-env/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ minikube stop
2828
minikube delete --all --purge
2929

3030
# Stop and delete containers
31-
containers=("sushy-tools" "ironic-ipa-downloader" "ironic" "keepalived" "registry" "ironic-client", "fake-ipa")
31+
containers=("sushy-tools" "ironic-ipa-downloader" "ironic" "keepalived" "registry" "ironic-client" "fake-ipa")
3232
for container in "${containers[@]}"; do
3333
echo "Deleting the container: $container"
3434
sudo podman stop "$container" &>/dev/null
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
NS="baremetal-operator-system"
4-
podName=$(kubectl -n $NS get pod -o json | jq -r '.items | .[].metadata.name' | grep "ironic" )
4+
podName=$(kubectl -n "$NS" get pod -o json | jq -r '.items | .[].metadata.name' | grep "ironic" )
55

66
rm -f ironic.log
7-
kubectl -n $NS logs $podName -c ironic > ironic.log
7+
kubectl -n "$NS" logs "$podName" -c ironic > ironic.log
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [ -d "${PWD}/_clouds_yaml" ]; then
4+
MOUNTDIR="${PWD}/_clouds_yaml"
5+
else
6+
echo "cannot find _clouds_yaml"
7+
exit 1
8+
fi
9+
10+
if [ "$1" == "baremetal" ] ; then
11+
shift 1
12+
fi
13+
14+
# shellcheck disable=SC2086
15+
sudo podman run --net=host --tls-verify=false \
16+
-v "${MOUNTDIR}:/etc/openstack" --rm \
17+
-e OS_CLOUD="${OS_CLOUD:-metal3}" "172.22.0.1:5000/localimages/ironic-client" "$@"

0 commit comments

Comments
 (0)