- done
- FAB_ID=$((FAB_ID+1))
- done
-}
-
-enablesubnetanddhcp(){
- TEMP_CIDR=$1
- enabledhcp=$2
- space=$3
-
- SUBNET_PREFIX=${TEMP_CIDR::-5}
-
- 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_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"
-
- 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' || true
-
- FABRIC_ID=$(maas $PROFILE subnet read $TEMP_CIDR | jq '.vlan.fabric_id')
-
- PRIMARY_RACK_CONTROLLER=$(maas $PROFILE rack-controllers read | jq -r '.[0].system_id')
-
- 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_UNTTAGED 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_UNTTAGED 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_UNTTAGED 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_UNTTAGED dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true