|
1 | | -set -e |
2 | | -virsh attach-interface --domain minikube --model virtio --source provisioning --type network --config |
| 1 | +# Set variables |
| 2 | +REGISTRY_NAME="registry" |
| 3 | +REGISTRY_PORT="5000" |
| 4 | +IMAGE_NAMES=( |
| 5 | + "quay.io/metal3-io/sushy-tools" |
| 6 | + "quay.io/metal3-io/ironic-ipa-downloader" |
| 7 | + "quay.io/metal3-io/ironic:latest" |
| 8 | + "quay.io/metal3-io/ironic-client" |
| 9 | + "quay.io/metal3-io/keepalived" |
| 10 | +) |
| 11 | + |
| 12 | +# Attach provisioning and baremetal network interfaces to minikube domain |
3 | 13 | virsh attach-interface --domain minikube --model virtio --source provisioning --type network --config |
4 | 14 | virsh attach-interface --domain minikube --model virtio --source baremetal --type network --config |
5 | | -# Download images |
6 | | -podman run -d -p 5000:5000 --name registry docker.io/library/registry:2.7.1 |
7 | | -# Create pods |
8 | | -podman pod create -n infra-pod || true |
9 | | -podman pod create -n ironic-pod || true |
10 | | -# Pull images |
11 | | -mkdir -p /opt/metal3-dev-env/ironic/html/images |
12 | | -podman pull quay.io/metal3-io/sushy-tools |
13 | | -podman pull quay.io/metal3-io/ironic-ipa-downloader |
14 | | -podman pull quay.io/metal3-io/ironic:latest |
15 | | -podman pull quay.io/metal3-io/ironic-client |
16 | | -podman pull quay.io/metal3-io/keepalived |
17 | | -podman tag quay.io/metal3-io/sushy-tools 127.0.0.1:5000/localimages/sushy-tools |
18 | | -podman tag quay.io/metal3-io/ironic-ipa-downloader 127.0.0.1:5000/localimages/ironic-ipa-downloader |
19 | | -podman tag quay.io/metal3-io/ironic-client 127.0.0.1:5000/localimages/ironic-client |
20 | | -podman tag quay.io/metal3-io/keepalived 127.0.0.1:5000/localimages/keepalived |
21 | | -podman tag quay.io/metal3-io/ironic:latest 127.0.0.1:5000/localimages/ironic:latest |
22 | | -podman push --tls-verify=false 127.0.0.1:5000/localimages/keepalived |
23 | | -podman push --tls-verify=false 127.0.0.1:5000/localimages/ironic-client |
24 | | -podman push --tls-verify=false 127.0.0.1:5000/localimages/ironic:latest |
25 | | -podman push --tls-verify=false 127.0.0.1:5000/localimages/ironic-ipa-downloader |
26 | | -podman push --tls-verify=false 127.0.0.1:5000/localimages/sushy-tools |
27 | | -# Run host services |
28 | | -# Run httpd |
29 | | -podman run -d --net host --name httpd-infra --pod infra-pod -v /opt/metal3-dev-env/ironic:/shared -e PROVISIONING_INTERFACE=provisioning -e LISTEN_ALL_INTERFACES=false --entrypoint /bin/runhttpd 127.0.0.1:5000/localimages/ironic:latest |
30 | | -# Run sushy-tools |
31 | | -mkdir /opt/metal3-dev-env/ironic/virtualbmc |
32 | | -mkdir /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools |
33 | | -chmod -R 755 /opt/metal3-dev-env/ironic/virtualbmc |
34 | | - |
35 | | -cat <<EOF > /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools/conf.py |
36 | | -SUSHY_EMULATOR_LIBVIRT_URI = "qemu+ssh://[email protected]/system?&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1" |
| 15 | + |
| 16 | +# Start podman registry if it's not already running |
| 17 | +if ! podman ps | grep -q "$REGISTRY_NAME"; then |
| 18 | + podman run -d -p "$REGISTRY_PORT":"$REGISTRY_PORT" --name "$REGISTRY_NAME" docker.io/library/registry:2.7.1 |
| 19 | +fi |
| 20 | + |
| 21 | +# Pull images, tag to local registry, and push to registry |
| 22 | +for NAME in "${IMAGE_NAMES[@]}"; do |
| 23 | + # Pull and tag the image |
| 24 | + if ! podman images | grep -q "${NAME##*/}"; then |
| 25 | + podman pull "$NAME" |
| 26 | + podman tag "$NAME" 127.0.0.1:"$REGISTRY_PORT"/localimages/"${NAME##*/}" |
| 27 | + fi |
| 28 | + |
| 29 | + # Push the image to the local registry |
| 30 | + if ! podman images | grep -q 127.0.0.1:"$REGISTRY_PORT"/localimages; then |
| 31 | + podman push --tls-verify=false 127.0.0.1:5000/localimages/"${NAME##*/}" |
| 32 | + fi |
| 33 | +done |
| 34 | + |
| 35 | +# Define variables for repeated values |
| 36 | +IRONIC_IMAGE="127.0.0.1:5000/localimages/ironic:latest" |
| 37 | +SUSHY_TOOLS_IMAGE="127.0.0.1:5000/localimages/sushy-tools" |
| 38 | +LIBVIRT_URI= "qemu+ssh://[email protected]/system?&keyfile=/root/ssh/id_rsa_virt_power&no_verify=1&no_tty=1" |
| 39 | +API_URL="http://172.22.0.2:6385" |
| 40 | +CALLBACK_URL="http://172.22.0.2:5050/v1/continue" |
| 41 | +ADVERTISE_HOST="192.168.111.1" |
| 42 | +ADVERTISE_PORT="9999" |
| 43 | + |
| 44 | +# Create directories |
| 45 | +DIRECTORIES=( |
| 46 | + "/opt/metal3-dev-env/ironic/virtualbmc" |
| 47 | + "/opt/metal3-dev-env/ironic/virtualbmc/sushy-tools" |
| 48 | +) |
| 49 | +for DIR in "${DIRECTORIES[@]}"; do |
| 50 | + mkdir -p "$DIR" |
| 51 | + chmod -R 755 "$DIR" |
| 52 | +done |
| 53 | + |
| 54 | +# Generate SSH key |
| 55 | +sudo ssh-keygen -f /root/.ssh/id_rsa_virt_power -P "" -q |
| 56 | +sudo cat /root/.ssh/id_rsa_virt_power.pub | sudo tee -a /root/.ssh/authorized_keys |
| 57 | + |
| 58 | +# Run httpd container |
| 59 | +podman run -d --net host --name httpd-infra \ |
| 60 | + --pod infra-pod \ |
| 61 | + -v /opt/metal3-dev-env/ironic:/shared \ |
| 62 | + -e PROVISIONING_INTERFACE=provisioning \ |
| 63 | + -e LISTEN_ALL_INTERFACES=false \ |
| 64 | + --entrypoint /bin/runhttpd \ |
| 65 | + "$IRONIC_IMAGE" |
| 66 | +# Set configuration options |
| 67 | +cat <<EOF >/opt/metal3-dev-env/ironic/virtualbmc/sushy-tools/conf.py |
| 68 | +import collections |
| 69 | +
|
| 70 | +Host = collections.namedtuple('Host', ['hostname', 'port']) |
| 71 | +
|
| 72 | +SUSHY_EMULATOR_LIBVIRT_URI = "${LIBVIRT_URI}" |
37 | 73 | SUSHY_EMULATOR_IGNORE_BOOT_DEVICE = False |
38 | 74 | SUSHY_EMULATOR_VMEDIA_VERIFY_SSL = False |
39 | 75 | SUSHY_EMULATOR_AUTH_FILE = "/root/sushy/htpasswd" |
40 | 76 | SUSHY_EMULATOR_FAKE_DRIVER = True |
| 77 | +
|
| 78 | +FAKE_IPA_API_URL = "${API_URL}" |
| 79 | +FAKE_IPA_INSPECTION_CALLBACK_URL = "${CALLBACK_URL}" |
| 80 | +FAKE_IPA_ADVERTISE_ADDRESS = Host(hostname="${ADVERTISE_HOST}", port="${ADVERTISE_PORT}") |
41 | 81 | EOF |
42 | | -cat <<'EOF' > /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools/htpasswd |
43 | | -admin:$2b$12$/dVOBNatORwKpF.ss99KB.vESjfyONOxyH.UgRwNyZi1Xs/W2pGVS |
| 82 | + |
| 83 | +# Create an htpasswd file |
| 84 | +cat <<EOF >/opt/metal3-dev-env/ironic/virtualbmc/sushy-tools/htpasswd |
| 85 | +admin:$2b${12}$/dVOBNatORwKpF.ss99KB.vESjfyONOxyH.UgRwNyZi1Xs/W2pGVS |
44 | 86 | EOF |
45 | | -ssh-keygen -f /root/.ssh/id_rsa_virt_power -P "" |
46 | | -/root/.ssh/id_rsa_virt_power.pub | tee -a /root/.ssh/authorized_keys |
47 | | -podman run -d --net host --name sushy-tools --pod infra-pod -v /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools:/root/sushy -v "/root/.ssh":/root/ssh 127.0.0.1:5000/localimages/sushy-tools |
| 87 | + |
| 88 | +# Generate ssh keys to use for virtual power and add them to authorized_keys |
| 89 | +ssh-keygen -f /root/.ssh/id_rsa_virt_power -P "" -q |
| 90 | +cat /root/.ssh/id_rsa_virt_power.pub >>/root/.ssh/authorized_keys |
| 91 | + |
| 92 | +# Create and start a container for sushy-tools |
| 93 | +podman run -d --net host --name sushy-tools --pod infra-pod \ |
| 94 | + -v /opt/metal3-dev-env/ironic/virtualbmc/sushy-tools:/root/sushy \ |
| 95 | + -v /root/.ssh:/root/ssh \ |
| 96 | + "${SUSHY_TOOLS_IMAGE}" |
0 commit comments