Merge "Add kubevirt to e2e tested addons"
[icn.git] / env / metal3 / 02_configure.sh
index 490c438..d2842d2 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
-set -xe
+set -eux -o pipefail
+
 LIBDIR="$(dirname "$PWD")"
 
 source $LIBDIR/lib/logging.sh
@@ -10,11 +11,12 @@ if [[ $EUID -ne 0 ]]; then
     exit 1
 fi
 
-function check_inteface_ip {
+function check_interface_ip {
     local interface=$1
     local ipaddr=$2
 
-    if [ ! $(ip addr show dev $interface) ]; then
+    ip addr show dev $interface
+    if [ $? -ne 0 ]; then
         exit 1
     fi
 
@@ -62,13 +64,13 @@ function configure_ironic_interfaces {
     #Todo later to change the CNI networking for podman networking
     # Add firewall rules to ensure the IPA ramdisk can reach httpd, Ironic and the Inspector API on the host
     if [ "$IRONIC_PROVISIONING_INTERFACE" ]; then
-        check_inteface_ip $IRONIC_PROVISIONING_INTERFACE $IRONIC_PROVISIONING_INTERFACE_IP
+        check_interface_ip $IRONIC_PROVISIONING_INTERFACE $IRONIC_PROVISIONING_INTERFACE_IP
     else
         exit 1
     fi
 
     if [ "$IRONIC_IPMI_INTERFACE" ]; then
-        check_inteface_ip $IRONIC_IPMI_INTERFACE $IRONIC_IPMI_INTERFACE_IP
+        check_interface_ip $IRONIC_IPMI_INTERFACE $IRONIC_IPMI_INTERFACE_IP
     else
         exit 1
     fi
@@ -131,19 +133,21 @@ function configure_ironic {
        return
     fi
 
-    #Podman usage is deprecated for v1.0.0 release
-    #podman pull $IRONIC_IMAGE
+    for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader; do
+        sudo docker ps | \
+            grep -w "$name$" && sudo docker kill "$name"
+        sudo docker ps --all | \
+            grep -w "$name$" && sudo docker rm "$name" -f
+    done
+    rm -rf "$IRONIC_DATA_DIR"
+
     docker pull $IRONIC_IMAGE
-    #podman pull $IRONIC_INSPECTOR_IMAGE
     docker pull $IRONIC_INSPECTOR_IMAGE
+    docker pull $IPA_DOWNLOADER_IMAGE
 
     mkdir -p "$IRONIC_DATA_DIR/html/images"
     pushd $IRONIC_DATA_DIR/html/images
 
-    if [ ! -f ironic-python-agent.initramfs ]; then
-       curl --insecure --compressed -L https://images.rdoproject.org/master/rdo_trunk/current-tripleo-rdo/ironic-python-agent.tar | tar -xf -
-    fi
-
     if [[ "$BM_IMAGE_URL" && "$BM_IMAGE" ]]; then
        curl -o ${BM_IMAGE} --insecure --compressed -O -L ${BM_IMAGE_URL}
        md5sum ${BM_IMAGE} | awk '{print $1}' > ${BM_IMAGE}.md5sum
@@ -161,9 +165,10 @@ function configure {
     configure_ironic_interfaces
 }
 
-if [ "$1" == "-o" ]; then
+if [ "$#" -eq 0 ]; then
+    configure online
+elif [ "$1" == "-o" ]; then
     configure offline
-    exit 0
+else
+    exit 1
 fi
-
-configure