X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2F03-maasdeploy.sh;h=d2aaa36b0814e8599695b67c9eb70a29a2dbd75b;hb=6da65f9cfbda23f5f8e4b5965062afcf76409b2a;hp=2d40d516f566f0c2eb9ebcd5e790682b990f6324;hpb=0ea68a4b427388fa4ab5db9e13fc4fa20d5f7179;p=joid.git diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh index 2d40d516..d2aaa36b 100755 --- a/ci/03-maasdeploy.sh +++ b/ci/03-maasdeploy.sh @@ -2,14 +2,6 @@ #placeholder for deployment script. set -ex -maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'` - -if [[ "$maasver" > "2" ]]; then - echo "removing existing maas ..." - #sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller -y - #sudo rm -rf /var/lib/maas -fi - virtinstall=0 labname=$1 @@ -18,15 +10,15 @@ if [ ! -e $HOME/.ssh/id_rsa ]; then fi #install the packages needed -sudo apt-add-repository ppa:juju/stable -y +sudo apt-add-repository ppa:juju/devel -y sudo apt-add-repository ppa:maas/stable -y sudo apt-add-repository cloud-archive:newton -y sudo apt-get update -y -sudo apt-get dist-upgrade -y -sudo apt-get install openssh-server bzr git juju virtinst qemu-kvm libvirt-bin \ +#sudo apt-get dist-upgrade -y +sudo apt-get install openssh-server bzr git virtinst qemu-kvm libvirt-bin juju \ maas maas-region-controller python-pip python-psutil python-openstackclient \ python-congressclient gsutil charm-tools pastebinit python-jinja2 sshpass \ - openssh-server vlan ipmitool -y + openssh-server vlan ipmitool jq expect -y sudo pip install --upgrade pip @@ -39,22 +31,17 @@ sudo pip install --upgrade pip # Config preparation # -# Get labconfig and generate deployment.yaml for MAAS and deployconfig.yaml +# Get labconfig and generate deployconfig.yaml case "$labname" in intelpod[569]|orangepod[12]|cengnpod[12] ) array=(${labname//pod/ }) cp ../labconfig/${array[0]}/pod${array[1]}/labconfig.yaml . - python genMAASConfig.py -l labconfig.yaml > deployment.yaml python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml ;; 'attvirpod1' ) cp ../labconfig/att/virpod1/labconfig.yaml . - python genMAASConfig.py -l labconfig.yaml > deployment.yaml python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml ;; - 'juniperpod1' ) - cp maas/juniper/pod1/deployment.yaml ./deployment.yaml - ;; 'custom') labfile=$2 if [ -e $labfile ]; then @@ -68,45 +55,58 @@ case "$labname" in fi if [ ! -e ./labconfig.yaml ]; then virtinstall=1 + labname="default" + cp ../labconfig/default/labconfig.yaml ./ + cp ../labconfig/default/deployconfig.yaml ./ else - python genMAASConfig.py -l labconfig.yaml > deployment.yaml python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml - labname=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` + labname=`grep "maas_name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` fi ;; * ) virtinstall=1 + labname="default" + cp ../labconfig/default/labconfig.yaml ./ + python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml ;; esac -MAAS_IP=$(grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //') -MAAS_NAME=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` +python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < labconfig.yaml > labconfig.json +python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < deployconfig.yaml > deployconfig.json + +MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //') +MAAS_NAME=`grep "maas_name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` API_SERVER="http://$MAAS_IP/MAAS/api/2.0" API_SERVERMAAS="http://$MAAS_IP/MAAS/" PROFILE=ubuntu -MY_UPSTREAM_DNS=`grep "upstream_dns" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` +MY_UPSTREAM_DNS=`grep "upstream_dns" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` SSH_KEY=`cat ~/.ssh/id_rsa.pub` -MAIN_ARCHIVE=`grep "main_archive" deployment.yaml | cut -d ':' -f 2-3 | sed -e 's/ //'` +MAIN_ARCHIVE=`grep "main_archive" deployconfig.yaml | cut -d ':' -f 2-3 | sed -e 's/ //'` URL=https://images.maas.io/ephemeral-v2/daily/ KEYRING_FILE=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg SOURCE_ID=1 FABRIC_ID=1 -VLAN_TAG="" PRIMARY_RACK_CONTROLLER="$MAAS_IP" -SUBNET_CIDR="192.168.122.0/24" +SUBNET_CIDR=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="admin")'.cidr | cut -d \" -f 2 ` +SUBNETDATA_CIDR=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="data")'.cidr | cut -d \" -f 2 ` +SUBNETPUB_CIDR=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="public")'.cidr | cut -d \" -f 2 ` +SUBNETSTOR_CIDR=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="storage")'.cidr | cut -d \" -f 2 ` +SUBNETFLOAT_CIDR=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="floating")'.cidr | cut -d \" -f 2 ` VLAN_TAG="untagged" -# In the case of a virtual deployment get deployment.yaml and deployconfig.yaml +# In the case of a virtual deployment get deployconfig.yaml if [ "$virtinstall" -eq 1 ]; then - labname="default" - MAAS_IP="192.168.122.1" - API_SERVER="http://$MAAS_IP/MAAS/api/2.0" - API_SERVERMAAS="http://$MAAS_IP/MAAS/" - PRIMARY_RACK_CONTROLLER="$MAAS_IP" ./cleanvm.sh || true - cp ../labconfig/default/deployment.yaml ./ - cp ../labconfig/default/labconfig.yaml ./ - cp ../labconfig/default/deployconfig.yaml ./ +fi + +#create backup directory +mkdir ~/joid_config/ || true + +# Backup deployconfig.yaml in joid_config folder + +if [ -e ./deployconfig.yaml ]; then + cp ./deployconfig.yaml ~/joid_config/ + cp ./labconfig.yaml ~/joid_config/ fi # @@ -114,16 +114,14 @@ fi # # make sure no password asked during the deployment. -echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init - -if [ -e /etc/sudoers.d/90-joid-init ]; then - sudo cp /etc/sudoers.d/90-joid-init 91-joid-init - sudo chown $USER:$USER 91-joid-init - sudo chmod 660 91-joid-init - sudo cat 90-joid-init >> 91-joid-init - sudo chown root:root 91-joid-init - sudo mv 91-joid-init /etc/sudoers.d/ +sudoer_file=/etc/sudoers.d/90-joid-init +sudoer_entry="$USER ALL=(ALL) NOPASSWD:ALL" +if [ -e $sudoer_file ]; then + if ! sudo grep -q "$sudoer_entry" $sudoer_file; then + sudo sed -i -e "1i$sudoer_entry" $sudoer_file + fi else + echo "$sudoer_entry" > 90-joid-init sudo chown root:root 90-joid-init sudo mv 90-joid-init /etc/sudoers.d/ fi @@ -149,6 +147,7 @@ if [ "$virtinstall" -eq 1 ]; then sudo virsh net-define default-net-org.xml sudo virsh net-destroy default sudo virsh net-start default + rm -f default-net-org.xml fi # @@ -161,15 +160,17 @@ if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then sudo pip uninstall google-api-python-client fi -#create backup directory -mkdir ~/joid_config/ || true -mkdir ~/.juju/ || true if [ ! -e ~maas/.ssh/id_rsa.pub ]; then - sudo su - $USER -c "echo |ssh-keygen -t rsa -f $HOME/id_rsa_maas" + if [ ! -e $HOME/id_rsa_maas.pub ]; then + [ -e $HOME/id_rsa_maas ] && rm -f $HOME/id_rsa_maas + sudo su - $USER -c "echo |ssh-keygen -t rsa -f $HOME/id_rsa_maas" + fi sudo -u maas mkdir ~maas/.ssh/ || true sudo cp $HOME/id_rsa_maas ~maas/.ssh/id_rsa sudo cp $HOME/id_rsa_maas.pub ~maas/.ssh/id_rsa.pub + sudo chown maas:maas ~maas/.ssh/id_rsa + sudo chown maas:maas ~maas/.ssh/id_rsa.pub fi # Ensure virsh can connect without ssh auth @@ -190,198 +191,259 @@ installmaas(){ # http://blog.naydenov.net/2016/01/nodes-networking-deploying-openstack-on-maas-1-9-with-juju/ # configuremaas(){ - sudo maas createadmin --username=ubuntu --email=ubuntu@ubuntu.com --password=ubuntu + #reconfigure maas with correct MAAS address. + #Below code is needed as MAAS have issue in commisoning without restart. + sudo ./maas-reconfigure-region.sh $MAAS_IP + sleep 30 + sudo maas-rack config --region-url http://$MAAS_IP:5240/MAAS + + sudo maas createadmin --username=ubuntu --email=ubuntu@ubuntu.com --password=ubuntu || true API_KEY=`sudo maas-region apikey --username=ubuntu` maas login $PROFILE $API_SERVERMAAS $API_KEY - maas $PROFILE maas set-config name='main_archive' value=$MAIN_ARCHIVE - maas $PROFILE maas set-config name=upstream_dns value=$MY_UPSTREAM_DNS - maas $PROFILE maas set-config name='maas_name' value=$MAAS_NAME - maas $PROFILE maas set-config name='ntp_server' value='ntp.ubuntu.com' - maas $PROFILE sshkeys create "key=$SSH_KEY" - maas $PROFILE boot-source update $SOURCE_ID \ - url=$URL keyring_filename=$KEYRING_FILE - maas $PROFILE boot-source-selections create 1 \ - release='trusty' arches='amd64' labels='daily' \ - os='ubuntu' subarches='*' - maas $PROFILE boot-resources import - - while [ "$(maas $PROFILE boot-resources read | grep trusty | wc -l )" -le 0 ]; + maas $PROFILE maas set-config name='main_archive' value=$MAIN_ARCHIVE || true + maas $PROFILE maas set-config name=upstream_dns value=$MY_UPSTREAM_DNS || true + maas $PROFILE maas set-config name='maas_name' value=$MAAS_NAME || true + maas $PROFILE maas set-config name='ntp_server' value='ntp.ubuntu.com' || true + maas $PROFILE sshkeys create "key=$SSH_KEY" || true + + for tag in bootstrap compute control storage do - maas $PROFILE boot-resources import - sleep 20 + maas $PROFILE tags create name=$tag || true done - maas $PROFILE tags create name='bootstrap' - maas $PROFILE tags create name='compute' - maas $PROFILE tags create name='control' - maas $PROFILE tags create name='storage' - #create the required spaces. - maas $PROFILE space update 0 name=default - maas $PROFILE spaces create name=unused - maas $PROFILE spaces create name=admin-api - maas $PROFILE spaces create name=internal-api - maas $PROFILE spaces create name=public-api - maas $PROFILE spaces create name=compute-data - maas $PROFILE spaces create name=compute-external - maas $PROFILE spaces create name=storage-data - maas $PROFILE spaces create name=storage-cluster - - #maas $PROFILE subnet update vlan: name=internal-api space=<0> gateway_ip=10.5.1.1 - #maas $PROFILE subnet update vlan: name=admin-api space=<2> gateway_ip=10.5.12.1 - #maas $PROFILE subnet update vlan: name=public-api space=<1> gateway_ip=10.5.15.1 - #maas $PROFILE subnet update vlan: name=compute-data space=<3> gateway_ip=10.5.17.1 - #maas $PROFILE subnet update vlan: name=compute-external space=<4> gateway_ip=10.5.19.1 - #maas $PROFILE subnet update vlan: name=storage-data space=<5> gateway_ip=10.5.20.1 - #maas $PROFILE subnet update vlan: name=storage-cluster space=<6> gateway_ip=10.5.21.1 + maas $PROFILE space update 0 name=default || true + for space in unused admin-api internal-api public-api compute-data \ + compute-external storage-data storage-cluster + do + echo "Creating the space $space" + maas $PROFILE spaces create name=$space || true + done + #maas $PROFILE boot-source update $SOURCE_ID \ + # url=$URL keyring_filename=$KEYRING_FILE || true + #maas $PROFILE boot-resources import || true + #sleep 60 + + while [ "$(maas $PROFILE boot-resources is-importing)" == "true" ]; + do + sleep 60 + done } enablesubnetanddhcp(){ + TEMP_CIDR=$1 + enabledhcp=$2 + space=$3 - SUBNET_PREFIX="192.168.122" - SUBNET_CIDR="($SUBNET_PREFIX).0/24" + SUBNET_PREFIX=${TEMP_CIDR::-5} - IP_STATIC_RANGE_LOW="192.168.122.1" - IP_STATIC_RANGE_HIGH="192.168.122.49" + IP_RES_RANGE_LOW="$SUBNET_PREFIX.1" + IP_RES_RANGE_HIGH="$SUBNET_PREFIX.39" API_KEY=`sudo maas-region apikey --username=ubuntu` maas login $PROFILE $API_SERVERMAAS $API_KEY maas $PROFILE ipranges create type=reserved \ - start_ip=$IP_STATIC_RANGE_LOW end_ip=$IP_STATIC_RANGE_HIGH \ - comment='This is a reserved range' + start_ip=$IP_RES_RANGE_LOW end_ip=$IP_RES_RANGE_HIGH \ + comment='This is a reserved range' || true + + IP_DYNAMIC_RANGE_LOW="$SUBNET_PREFIX.40" + IP_DYNAMIC_RANGE_HIGH="$SUBNET_PREFIX.150" - IP_DYNAMIC_RANGE_LOW="192.168.122.50" - IP_DYNAMIC_RANGE_HIGH="192.168.122.150" maas $PROFILE ipranges create type=dynamic \ start_ip=$IP_DYNAMIC_RANGE_LOW end_ip=$IP_DYNAMIC_RANGE_HIGH \ - comment='This is a reserved dynamic range' - + comment='This is a reserved dynamic range' || true - FABRIC_ID=$(maas $PROFILE subnet read $SUBNET_CIDR \ - | grep fabric | cut -d ' ' -f 10 | cut -d '"' -f 2) + FABRIC_ID=$(maas $PROFILE subnet read $TEMP_CIDR | jq '.vlan.fabric_id') - PRIMARY_RACK_CONTROLLER=`maas $PROFILE rack-controllers read | grep system_id | cut -d '"' -f 4` + PRIMARY_RACK_CONTROLLER=$(maas $PROFILE rack-controllers read | jq -r '.[0].system_id') - maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER + if [ "$space" == "admin" ]; then + MY_GATEWAY=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="admin")'.gateway | cut -d \" -f 2 ` + #MY_NAMESERVER=`cat deployconfig.json | jq '.opnfv.upstream_dns' | cut -d \" -f 2` + if ([ $MY_GATEWAY ] && [ "$MY_GATEWAY" != "null" ]); then + maas $PROFILE subnet update $TEMP_CIDR gateway_ip=$MY_GATEWAY || true + fi + #maas $PROFILE subnet update $TEMP_CIDR dns_servers=$MY_NAMESERVER || true + #below command will enable the interface with internal-api space. + SPACEID=$(maas $PROFILE space read internal-api | jq '.id') + maas $PROFILE subnet update $TEMP_CIDR space=$SPACEID || true + if [ "$enabledhcp" == "true" ]; then + maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true + fi + elif [ "$space" == "data" ]; then + MY_GATEWAY=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="data")'.gateway | cut -d \" -f 2 ` + if ([ $MY_GATEWAY ] && [ "$MY_GATEWAY" != "null" ]); then + maas $PROFILE subnet update $TEMP_CIDR gateway_ip=$MY_GATEWAY || true + fi + #below command will enable the interface with data-api space for data network. + SPACEID=$(maas $PROFILE space read admin-api | jq '.id') + maas $PROFILE subnet update $TEMP_CIDR space=$SPACEID || true + if [ "$enabledhcp" == "true" ]; then + maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true + fi + elif [ "$space" == "public" ]; then + MY_GATEWAY=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="data")'.public | cut -d \" -f 2 ` + if ([ $MY_GATEWAY ] && [ "$MY_GATEWAY" != "null" ]); then + maas $PROFILE subnet update $TEMP_CIDR gateway_ip=$MY_GATEWAY || true + fi + #below command will enable the interface with public-api space for data network. + SPACEID=$(maas $PROFILE space read public-api | jq '.id') + maas $PROFILE subnet update $TEMP_CIDR space=$SPACEID || true + if [ "$enabledhcp" == "true" ]; then + maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true + fi + elif [ "$space" == "storage" ]; then + MY_GATEWAY=`cat labconfig.json | jq '.opnfv.spaces[] | select(.type=="data")'.storage | cut -d \" -f 2 ` + if ([ $MY_GATEWAY ] && [ "$MY_GATEWAY" != "null" ]); then + maas $PROFILE subnet update $TEMP_CIDR gateway_ip=$MY_GATEWAY || true + fi + #below command will enable the interface with public-api space for data network. + SPACEID=$(maas $PROFILE space read storage-data | jq '.id') + maas $PROFILE subnet update $TEMP_CIDR space=$SPACEID || true + if [ "$enabledhcp" == "true" ]; then + maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true + fi + fi +} - MY_GATEWAY="192.168.122.1" - MY_NAMESERVER=192.168.122.1 - maas $PROFILE subnet update $SUBNET_CIDR gateway_ip=$MY_GATEWAY - maas $PROFILE subnet update $SUBNET_CIDR dns_servers=$MY_NAMESERVER +addnodes(){ + API_KEY=`sudo maas-region apikey --username=ubuntu` + maas login $PROFILE $API_SERVERMAAS $API_KEY -} + # make sure there is no machine entry in maas + for m in $(maas $PROFILE machines read | jq -r '.[].system_id') + do + maas ubuntu machine delete $m + done -## derived from https://gist.github.com/epiloque/8cf512c6d64641bde388 -## works for arrays of hashes, as long as the hashes do not have arrays -parse_yaml2() { - local prefix=$2 - local s - local w - local fs - s='[[:space:]]*' - w='[a-zA-Z0-9_]*' - fs="$(echo @|tr @ '\034')" - sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ - -e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | - awk -F"$fs" '{ - indent = length($1)/2; - if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";} - vname[indent] = $2; - for (i in vname) {if (i > indent) {delete vname[i]}} - if (length($3) > 0) { - vn=""; for (i=0; i credential.yaml echo " $controllername:" >> credential.yaml @@ -461,8 +525,8 @@ addcredential() { } addcloud() { - controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployment.yaml` - cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployment.yaml` + controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml` + cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml` echo "clouds:" > maas-cloud.yaml echo " $cloudname:" >> maas-cloud.yaml @@ -473,7 +537,6 @@ addcloud() { juju add-cloud $cloudname maas-cloud.yaml --replace } - # # VLAN customization # @@ -497,51 +560,108 @@ esac # #read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer. -if [ -e ~/joid_config/deployconfig.yaml ]; then - cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml -elif [ -e ~/.juju/deployconfig.yaml ]; then - cp ~/.juju/deployconfig.yaml ./deployconfig.yaml +# Enable only non vlan interfaces first. +if [ -e ./labconfig.json ]; then + if [ $SUBNETDATA_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="data")'.ifname | sort -u` + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + if ([ -z $VLAN ] || [ "$VLAN" == "null" ]); then + enableautomode ${EXTNET[i]} AUTO $SUBNETDATA_CIDR || true + fi + i=$[$i+1] + done + fi + if [ $SUBNETPUB_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="public")'.ifname | sort -u` + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + if ([ -z $VLAN ] || [ "$VLAN" == "null" ]); then + enableautomode ${EXTNET[i]} AUTO $SUBNETPUB_CIDR || true + fi + i=$[$i+1] + done + fi + if [ $SUBNETSTOR_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="storage")'.ifname | sort -u` + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + if ([ -z $VLAN ] || [ "$VLAN" == "null" ]); then + enableautomode ${EXTNET[i]} AUTO $SUBNETSTOR_CIDR || true + fi + i=$[$i+1] + done + fi + if [ $SUBNETFLOAT_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="floating")'.ifname | sort -u` + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + if ([ -z $VLAN ] || [ "$VLAN" == "null" ]); then + enableautomode ${EXTNET[i]} link_up $SUBNETFLOAT_CIDR || true + fi + i=$[$i+1] + done + fi fi -if [ -e ./deployconfig.yaml ]; then - enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 ` - datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` - stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` - pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` - - # split EXTERNAL_NETWORK=first ip;last ip; gateway;network - - maas maas spaces create internal "Using for pxe network within the lab" +#enable only the vlan interfaces which were ignore in previous run. - if [ "$datanet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) +if [ -e ./labconfig.json ]; then + if [ $SUBNETDATA_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="data")'.ifname | sort -u` + VLAN=`cat labconfig.json | jq --raw-output '.opnfv.spaces[] | select(.type=="data")'.vlan` i="0" while [ ! -z "${EXTNET[i]}" ]; do - enableautomode ${EXTNET[i]} AUTO $datanet || true + if ([ $VLAN ] && [ "$VLAN" != "null" ]); then + crnodevlanint $VLAN || true + enableautomode ${EXTNET[i]} AUTO $SUBNETDATA_CIDR || true + fi + i=$[$i+1] + done + fi + if [ $SUBNETPUB_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="public")'.ifname | sort -u` + VLAN=`cat labconfig.json | jq --raw-output '.opnfv.spaces[] | select(.type=="public")'.vlan` + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + if ([ $VLAN ] && [ "$VLAN" != "null" ]); then + crnodevlanint $VLAN || true + enableautomode ${EXTNET[i]} AUTO $SUBNETPUB_CIDR || true + fi i=$[$i+1] done - maas maas spaces create admin "Using for admin network within the lab" - fi - if [ "$stornet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) + if [ $SUBNETSTOR_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="storage")'.ifname | sort -u` + VLAN=`cat labconfig.json | jq --raw-output '.opnfv.spaces[] | select(.type=="storage")'.vlan` i="0" while [ ! -z "${EXTNET[i]}" ]; do - enableautomode ${EXTNET[i]} AUTO $stornet || true + if ([ $VLAN ] && [ "$VLAN" != "null" ]); then + crnodevlanint $VLAN || true + enableautomode ${EXTNET[i]} AUTO $SUBNETSTOR_CIDR || true + fi i=$[$i+1] done fi - if [ "$pubnet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) + if [ $SUBNETFLOAT_CIDR ]; then + EXTNET=`cat labconfig.json | jq --raw-output '.lab.racks[0].nodes[].nics[] | select(.spaces[]=="floating")'.ifname | sort -u` + VLAN=`cat labconfig.json | jq --raw-output '.opnfv.spaces[] | select(.type=="floating")'.vlan` i="0" while [ ! -z "${EXTNET[i]}" ]; do - enableautomode ${EXTNET[i]} AUTO $pubnet || true + if ([ $VLAN ] && [ "$VLAN" != "null" ]); then + crnodevlanint $VLAN || true + enableautomode ${EXTNET[i]} link_up $SUBNETFLOAT_CIDR || true + fi i=$[$i+1] done - maas maas spaces create public "Using for public network within the lab" fi fi @@ -549,7 +669,7 @@ fi # Add the cloud and controller credentials for MAAS for that lab. jujuver=`juju --version` -if [ "$jujuver" > "2" ]; then +if [[ "$jujuver" > "2" ]]; then addcloud addcredential fi