From ec258715d6f8d779d79555a7c75ba28d4fef9170 Mon Sep 17 00:00:00 2001 From: Todd Malsbary Date: Fri, 17 Sep 2021 16:44:29 -0700 Subject: [PATCH] Remove stale offline option to scripts Signed-off-by: Todd Malsbary Change-Id: I4d80d0d0d3a809d347b70306bba99dbdd87b867c --- deploy/metal3/scripts/01_metal3.sh | 52 ----- env/lib/common.sh | 5 - env/metal3/01_install_package.sh | 16 +- env/metal3/02_configure.sh | 44 +--- env/metal3/03_launch_prereq.sh | 8 +- .../bootloader-env/01_bootloader_package_req.sh | 224 --------------------- .../02_clean_bootloader_package_req.sh | 38 ---- 7 files changed, 5 insertions(+), 382 deletions(-) delete mode 100755 env/ubuntu/bootloader-env/01_bootloader_package_req.sh diff --git a/deploy/metal3/scripts/01_metal3.sh b/deploy/metal3/scripts/01_metal3.sh index bd7be78..9a8f079 100755 --- a/deploy/metal3/scripts/01_metal3.sh +++ b/deploy/metal3/scripts/01_metal3.sh @@ -31,32 +31,6 @@ function clone_repos { popd } -function get_default_interface_ipaddress { - local _ip=$1 - local _default_interface=$(awk '$2 == 00000000 { print $1 }' /proc/net/route) - local _ipv4address=$(ip addr show dev $_default_interface | awk '$1 == "inet" { sub("/.*", "", $2); print $2 }') - eval $_ip="'$_ipv4address'" -} - -function create_ssh_key { - #ssh key for compute node to communicate back to bootstrap server - mkdir -p $BUILD_DIR/ssh_key - ssh-keygen -C "compute.icn.akraino.lfedge.org" -f $BUILD_DIR/ssh_key/id_rsa - cat $BUILD_DIR/ssh_key/id_rsa.pub >> $HOME/.ssh/authorized_keys -} - -function set_compute_key { - _SSH_LOCAL_KEY=$(cat $BUILD_DIR/ssh_key/id_rsa) - cat << EOF -write_files: -- path: /opt/ssh_id_rsa - owner: root:root - permissions: '0600' - content: | - $_SSH_LOCAL_KEY -EOF -} - function deprovision_compute_node { name="$1" if kubectl get baremetalhost $name -n metal3 &>/dev/null; then @@ -65,25 +39,6 @@ function deprovision_compute_node { fi } -function set_compute_ssh_config { - get_default_interface_ipaddress default_addr - cat << EOF -- path: /root/.ssh/config - owner: root:root - permissions: '0600' - content: | - Host bootstrapmachine $default_addr - HostName $default_addr - IdentityFile /opt/ssh_id_rsa - User $USER -- path: /etc/apt/sources.list - owner: root:root - permissions: '0665' - content: | - deb [trusted=yes] ssh://$USER@$default_addr:$LOCAL_APT_REPO ./ -EOF -} - # documentation for the values below may be found at # https://cloudinit.readthedocs.io/en/latest/topics/modules.html function create_userdata { @@ -338,10 +293,3 @@ echo "deprovision - deprovision baremetal node as specified in common.sh" echo "clean - clean all the bmh resources" echo "remove - remove baremetal operator" exit 1 - -#Following code is tested for the offline mode -#Will be intergrated for the offline mode for ICNi v.0.1.0 beta -#create_ssh_key -#create_userdata -#set_compute_key -#set_compute_ssh_config diff --git a/env/lib/common.sh b/env/lib/common.sh index dd51fb2..c0a1bc9 100755 --- a/env/lib/common.sh +++ b/env/lib/common.sh @@ -4,12 +4,7 @@ set -eu -o pipefail #supported OS version UBUNTU_BIONIC=${UBUNTU_BIONIC:-Ubuntu 18.04.2 LTS} -#offline mode variable DOWNLOAD_PATH=${DOWNLOAD_PATH:-/opt/icn} -LOCAL_APT_REPO=${LOCAL_APT_REPO:-$DOWNLOAD_PATH/apt} -PIP_CACHE_DIR=${PIP_CACHE_DIR:-$DOWNLOAD_PATH/pip-cache-dir} -BUILD_DIR=${BUILD_DIR:-$DOWNLOAD_PATH/build-dir} -CONTAINER_IMAGES_DIR=${CONTAINER_IMAGES_DIR:-$DOWNLOAD_PATH/docker-dir} #set variables #Todo include over all variables here diff --git a/env/metal3/01_install_package.sh b/env/metal3/01_install_package.sh index 1ea151f..afa3f0b 100755 --- a/env/metal3/01_install_package.sh +++ b/env/metal3/01_install_package.sh @@ -51,12 +51,6 @@ function install_ironic_packages { genisoimage \ whois - if [ "$1" == "offline" ]; then - pip install --no-index - --find-links=file:$PIP_CACHE_DIR locat yq - return - fi - pip install \ lolcat \ yq @@ -64,13 +58,7 @@ function install_ironic_packages { install() { install_essential_packages - install_ironic_packages $1 + install_ironic_packages } -if [ "$#" -eq 0 ]; then - install online -elif [ "$1" == "-o" ]; then - install offline -else - exit 1 -fi +install diff --git a/env/metal3/02_configure.sh b/env/metal3/02_configure.sh index 6ae1c60..8bb1370 100755 --- a/env/metal3/02_configure.sh +++ b/env/metal3/02_configure.sh @@ -66,41 +66,7 @@ function configure_ironic_interfaces { done } -function configure_ironic_offline { - if [ ! -d $CONTAINER_IMAGES_DIR ] && [ ! -d $BUILD_DIR ]; then - exit 1 - fi - - for image in ironic-inspector-image ironic-image \ - baremetal-operator socat; do - if [ ! -f "$CONTAINER_IMAGES_DIR/$image" ]; then - exit 1 - fi - done - - if [ ! -f "$BUILD_DIR/ironic-python-agent.initramfs"] && [ ! -f \ - "$BUILD_DIR/ironic-python-agent.kernel" ] && [ ! -f - "$BUILD_DIR/$BM_IMAGE" ]; then - exit 1 - fi - - docker load --input $CONTAINER_IMAGES_DIR/baremetal-operator.tar - docker load --input $CONTAINER_IMAGES_DIR/socat.tar - - mkdir -p "$IRONIC_DATA_DIR/html/images" - - cp $BUILD_DIR/ironic-python-agent.initramfs $IRONIC_DATA_DIR/html/images/ - cp $BUILD_DIR/ironic-python-agent.kernel $IRONIC_DATA_DIR/html/images/ - cp $BUILD_DIR/$BM_IMAGE $IRONIC_DATA_DIR/html/images/ - md5sum $BUILD_DIR/$BM_IMAGE | awk '{print $1}' > $BUILD_DIR/${BM_IMAGE}.md5sum -} - function configure_ironic { - if [ "$1" == "offline" ]; then - configure_ironic_offline - return - fi - for name in ironic ironic-inspector dnsmasq httpd mariadb ipa-downloader; do sudo docker ps | \ grep -w "$name$" && sudo docker kill "$name" @@ -124,15 +90,9 @@ function configure_ironic { } function configure { - configure_ironic $1 + configure_ironic configure_ironic_bridge configure_ironic_interfaces } -if [ "$#" -eq 0 ]; then - configure online -elif [ "$1" == "-o" ]; then - configure offline -else - exit 1 -fi +configure diff --git a/env/metal3/03_launch_prereq.sh b/env/metal3/03_launch_prereq.sh index e8fa538..93b93c8 100755 --- a/env/metal3/03_launch_prereq.sh +++ b/env/metal3/03_launch_prereq.sh @@ -76,10 +76,4 @@ function install { install_ironic_container } -if [ "$#" -eq 0 ]; then - install online -elif [ "$1" == "-o" ]; then - install offline -else - exit 1 -fi +install diff --git a/env/ubuntu/bootloader-env/01_bootloader_package_req.sh b/env/ubuntu/bootloader-env/01_bootloader_package_req.sh deleted file mode 100755 index d861cb2..0000000 --- a/env/ubuntu/bootloader-env/01_bootloader_package_req.sh +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env bash -set -eux -o pipefail -shopt -s extglob - -source $(dirname $PWD)/../lib/common.sh -source $(dirname $PWD)/../lib/logging.sh - -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" - exit 1 -fi - -if [[ $(lsb_release -d | cut -f2) != $UBUNTU_BIONIC ]]; then - echo "Currently Ubuntu 18.04.2 LTS is only supported" - exit 1 -fi - -function download_essential_packages { - apt-get update - for package in crudini curl dnsmasq figlet golang nmap patch psmisc \ - python3-pip python3-requests python3-setuptools vim wget; do - apt-get -d install $package -y - done - update-alternatives --install /usr/bin/python python /usr/bin/python3 1 - update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 -} - -function download_container_images { - check_docker - pushd $CONTAINER_IMAGES_DIR - #docker images for Kubernetes - for images in kube-apiserver kube-controller-manager kube-scheduler kube-proxy; do - docker pull k8s.gcr.io/$images:v1.15.0; - docker save --output $images.tar k8s.gcr.io/$images; - done - - docker pull k8s.gcr.io/pause:3.1 - docker save --output pause.tar k8s.gcr.io/pause - - docker pull k8s.gcr.io/etcd:3.3.10 - docker save --output etcd.tar k8s.gcr.io/etcd - - docker pull k8s.gcr.io/coredns:1.3.1 - docker save --output coredns.tar k8s.gcr.io/coredns - - popd -} - -function download_build_packages { - check_curl - pushd $BUILD_DIR - if [ ! -f ironic-python-agent.initramfs ]; then - curl --insecure --compressed \ - -L https://images.rdoproject.org/train/rdo_trunk/current-tripleo/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 - fi - - if [ ! -d baremetal-operator ]; then - git clone https://github.com/metal3-io/baremetal-operator.git - pushd ./baremetal-operator - git checkout -b icn_baremetal_operator 11ea02ab5cab8b3ab14972ae7c0e70206bba00b5 - popd - fi - - if [ ! -d ironic-inspector-image ]; then - git clone https://github.com/metal3-io/ironic-inspector-image.git - pushd ./ironic-inspector-image - git checkout -b icn_ironic_inspector_image 25431bd5b7fc87c6f3cfb8b0431fe66b86bbab0e - popd - fi - - if [ ! -d ironic-image ]; then - git clone https://github.com/metal3-io/ironic-image.git - pushd ./ironic-image - git checkout -b icn_ironic_image 329eb4542f0d8d0f0e9cf0d7e550e33b07efe7fb - popd - fi -} - -function check_pip { - if ! which pip ; then - apt-get install python3-pip -y - fi - update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 -} - -function check_curl { - if ! which curl ; then - apt-get install curl -y - fi -} - -function check_apt_tools { - if ! which add-apt-repository ; then - apt-get install software-properties-common -y - fi -} - -function download_ironic_packages { - for package in jq nodejs python3-ironicclient \ - python3-ironic-inspector-client python3-lxml python3-netaddr \ - python3-openstackclient unzip genisoimage; do - apt-get -d install $package -y - done - - check_pip - pip download lolcat yq -d $PIP_CACHE_DIR -} - -function check_docker { - if which docker ; then - return - fi - - apt-get remove -y docker \ - docker-engine \ - docker.io \ - containerd \ - runc \ - docker-ce - apt-get update - for package in apt-transport-https ca-certificates gnupg-agent \ - software-properties-common; do - apt-get -d install $package -y - done - - check_curl - check_apt_tools - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" - apt-get update - apt-get install docker-ce=19.03.15~3-0~ubuntu-bionic -y -} - -function download_docker_packages { - apt-get remove -y docker \ - docker-engine \ - docker.io \ - containerd \ - runc \ - docker-ce - apt-get update - for package in apt-transport-https ca-certificates gnupg-agent \ - software-properties-common; do - apt-get -d install $package -y - done - - check_curl - check_apt_tools - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" - apt-get update - apt-get -d install docker-ce=19.03.15~3-0~ubuntu-bionic -y -} - -function download_kubernetes_packages { - curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - - bash -c 'cat </etc/apt/sources.list.d/kubernetes.list -deb https://apt.kubernetes.io/ kubernetes-xenial main -EOF' - apt-get update - apt-get install -d kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00 -y -} - -function clean_apt_cache { - pushd /var/cache/apt/archives - - if [ $(ls -1q . | wc -l ) -ge 3 ]; then - $(rm !("lock"|"partial")) - fi - popd - -} - -function mv_apt_cache { - pushd /var/cache/apt/archives - - if [ $(ls -1q . | wc -l ) -gt 2 ]; then - $(mv !("lock"|"partial") $LOCAL_APT_REPO) - fi - popd -} - -function check_dir { - if [ ! -d $1 ]; then - mkdir -p $1 - fi -} - -function clean_dir { - pushd $1 - - if [ $(ls -1q . | wc -l ) -ne 0 ]; then - $(rm -r ./*) - fi - popd -} - -clean_apt_cache -check_dir $LOCAL_APT_REPO -clean_dir $LOCAL_APT_REPO -check_dir $PIP_CACHE_DIR -clean_dir $PIP_CACHE_DIR -check_dir $BUILD_DIR -clean_dir $BUILD_DIR -check_dir $CONTAINER_IMAGES_DIR -clean_dir $CONTAINER_IMAGES_DIR -download_essential_packages -download_ironic_packages -download_docker_packages -download_kubernetes_packages -download_build_packages -download_container_images -mv_apt_cache diff --git a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh index 439abea..05e9d44 100755 --- a/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh +++ b/env/ubuntu/bootloader-env/02_clean_bootloader_package_req.sh @@ -111,32 +111,6 @@ function clean_apt_cache { } -function mv_apt_cache { - shopt -s extglob - pushd /var/cache/apt/archives - - if [ $(ls -1q . | wc -l ) -gt 2 ]; then - $(mv !("lock"|"partial") $LOCAL_APT_REPO) - fi - popd -} - -function check_dir { - if [ ! -d $1 ]; then - mkdir -p $1 - fi -} - -function clean_dir { - shopt -s extglob - pushd $1 - - if [ $(ls -1q . | wc -l ) -ne 0 ]; then - $(rm -r ./*) - fi - popd -} - if [ "$1" == "--only-packages" ]; then check_prerequisite clean_docker_packages || true @@ -152,19 +126,7 @@ fi check_prerequisite clean_apt_cache -check_dir $LOCAL_APT_REPO -clean_dir $LOCAL_APT_REPO -check_dir $PIP_CACHE_DIR -clean_dir $PIP_CACHE_DIR -check_dir $BUILD_DIR -clean_dir $BUILD_DIR -check_dir $CONTAINER_IMAGES_DIR -clean_dir $CONTAINER_IMAGES_DIR clean_kubernetes_packages clean_docker_packages clean_ironic_packages clean_essential_packages -rm -rf $LOCAL_APT_REPO -rm -rf $PIP_CACHE_DIR -rm -rf $BUILD_DIR -rm -rf $CONTAINER_IMAGES_DIR -- 2.16.6