diff --git a/tools/gate/funcs/common.sh b/tools/gate/funcs/common.sh index 6eddaecd2e..7e1c75010e 100644 --- a/tools/gate/funcs/common.sh +++ b/tools/gate/funcs/common.sh @@ -41,6 +41,58 @@ function base_install { fi } +function loopback_support_install { + if [ "x$HOST_OS" == "xubuntu" ]; then + sudo apt-get update -y + sudo apt-get install -y --no-install-recommends \ + targetcli \ + open-iscsi \ + lshw + sudo systemctl restart iscsid + elif [ "x$HOST_OS" == "xcentos" ]; then + sudo yum install -y \ + targetcli \ + iscsi-initiator-utils \ + lshw + elif [ "x$HOST_OS" == "xfedora" ]; then + sudo dnf install -y \ + targetcli \ + iscsi-initiator-utils \ + lshw + fi +} + +function loopback_setup { + sudo mkdir -p ${LOOPBACK_DIR} + for ((LOOPBACK_DEV=1;LOOPBACK_DEV<=${LOOPBACK_DEVS};LOOPBACK_DEV++)); do + if [ "x$HOST_OS" == "xubuntu" ]; then + sudo targetcli backstores/fileio create loopback-${LOOPBACK_DEV} ${LOOPBACK_DIR}/fileio-${LOOPBACK_DEV} ${LOOPBACK_SIZE} + else + sudo targetcli backstores/fileio create loopback-${LOOPBACK_DEV} ${LOOPBACK_DIR}/fileio-${LOOPBACK_DEV} ${LOOPBACK_SIZE} write_back=false + fi + done + sudo targetcli iscsi/ create iqn.2016-01.com.example:target + if ! [ "x$HOST_OS" == "xubuntu" ]; then + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1/portals delete 0.0.0.0 3260 + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1/portals create 127.0.0.1 3260 + else + #NOTE (Portdirect): Frustratingly it appears that Ubuntu's targetcli wont + # let you bind to localhost. + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1/portals create 0.0.0.0 3260 + fi + for ((LOOPBACK_DEV=1;LOOPBACK_DEV<=${LOOPBACK_DEVS};LOOPBACK_DEV++)); do + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1/luns/ create /backstores/fileio/loopback-${LOOPBACK_DEV} + done + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1/acls/ create $(sudo cat /etc/iscsi/initiatorname.iscsi | awk -F '=' '/^InitiatorName/ { print $NF}') + if [ "x$HOST_OS" == "xubuntu" ]; then + sudo targetcli iscsi/iqn.2016-01.com.example:target/tpg1 set attribute authentication=0 + fi + sudo iscsiadm --mode discovery --type sendtargets --portal 127.0.0.1 + sudo iscsiadm -m node -T iqn.2016-01.com.example:target -p 127.0.0.1:3260 -l + # Display disks + sudo lshw -class disk +} + function ceph_support_install { if [ "x$HOST_OS" == "xubuntu" ]; then sudo apt-get update -y @@ -69,3 +121,21 @@ function nfs_support_install { nfs-utils fi } + +function gate_base_setup { + # Install base requirements + base_install + + # Install and setup iscsi loopback devices if required. + if [ "x$LOOPBACK_CREATE" == "xtrue" ]; then + loopback_support_install + loopback_setup + fi + + # Install support packages for pvc backends + if [ "x$PVC_BACKEND" == "xceph" ]; then + ceph_support_install + elif [ "x$PVC_BACKEND" == "xnfs" ]; then + nfs_support_install + fi +} diff --git a/tools/gate/provision_gate_worker_node.sh b/tools/gate/provision_gate_worker_node.sh index 992ad98c96..0e834bfda0 100755 --- a/tools/gate/provision_gate_worker_node.sh +++ b/tools/gate/provision_gate_worker_node.sh @@ -20,13 +20,8 @@ source ${WORK_DIR}/tools/gate/funcs/common.sh source ${WORK_DIR}/tools/gate/funcs/network.sh source ${WORK_DIR}/tools/gate/funcs/kube.sh -# Install base requirements -base_install -if [ "x$PVC_BACKEND" == "xceph" ]; then - ceph_support_install -elif [ "x$PVC_BACKEND" == "xnfs" ]; then - nfs_support_install -fi +# Do the basic node setup for running the gate +gate_base_setup # Install KubeadmAIO requirements and get image kubeadm_aio_reqs_install diff --git a/tools/gate/setup_gate.sh b/tools/gate/setup_gate.sh index 3fa9475ad2..1f014fec8e 100755 --- a/tools/gate/setup_gate.sh +++ b/tools/gate/setup_gate.sh @@ -22,6 +22,11 @@ export KUBEADM_IMAGE=openstackhelm/kubeadm-aio:${KUBE_VERSION} export BASE_KUBE_CONTROLLER_MANAGER_IMAGE=gcr.io/google_containers/kube-controller-manager-amd64:${KUBE_VERSION} export CEPH_KUBE_CONTROLLER_MANAGER_IMAGE=quay.io/attcomdev/kube-controller-manager:${KUBE_VERSION} +export LOOPBACK_CREATE=${LOOPBACK_CREATE:="false"} +export LOOPBACK_DEVS=${LOOPBACK_DEVS:="3"} +export LOOPBACK_SIZE=${LOOPBACK_SIZE:="500M"} +export LOOPBACK_DIR=${LOOPBACK_DIR:="/var/lib/iscsi-loopback"} + export WORK_DIR=$(pwd) source /etc/os-release export HOST_OS=${ID} @@ -44,13 +49,8 @@ if [ "x$INTEGRATION_TYPE" == "xlinter" ]; then bash ${WORK_DIR}/tools/gate/whitespace.sh fi -# Install base requirements -base_install -if [ "x$PVC_BACKEND" == "xceph" ]; then - ceph_support_install -elif [ "x$PVC_BACKEND" == "xnfs" ]; then - nfs_support_install -fi +# Do the basic node setup for running the gate +gate_base_setup # We setup the network for pre kube here, to enable cluster restarts on # development machines diff --git a/tools/gate/setup_gate_worker_nodes.sh b/tools/gate/setup_gate_worker_nodes.sh index c332c40c5e..678216ae80 100755 --- a/tools/gate/setup_gate_worker_nodes.sh +++ b/tools/gate/setup_gate_worker_nodes.sh @@ -34,6 +34,10 @@ for SUB_NODE in $SUB_NODE_IPS ; do export PRIMARY_NODE_IP=${PRIMARY_NODE_IP}; \ export KUBEADM_IMAGE=${KUBEADM_IMAGE}; \ export PVC_BACKEND=${PVC_BACKEND}; \ + export LOOPBACK_CREATE=${LOOPBACK_CREATE}; \ + export LOOPBACK_DEVS=${LOOPBACK_DEVS}; \ + export LOOPBACK_SIZE=${LOOPBACK_SIZE}; \ + export LOOPBACK_DIR=${LOOPBACK_DIR}; \ bash ${WORK_DIR}/tools/gate/provision_gate_worker_node.sh" EOS done