From 947016a2eb2be266c8eaf183ea904b2bc204776b Mon Sep 17 00:00:00 2001 From: Narinder Gupta Date: Tue, 2 Aug 2016 08:56:54 -0500 Subject: clenup the naming convention of the scripts and modify not to use variable directly. Change-Id: I234b53010a32c3b1f0daef507585dde4652616eb Signed-off-by: Narinder Gupta --- ci/00-bootstrap.sh | 14 --- ci/00-maasdeploy.sh | 310 +++++++++++++++++++++++++++++++++++++++++++++ ci/01-bootstrap.sh | 14 +++ ci/01-deploybundle.sh | 93 -------------- ci/02-deploybundle.sh | 102 +++++++++++++++ ci/02-maasdeploy.sh | 312 ---------------------------------------------- ci/deploy.py | 339 -------------------------------------------------- ci/deploy.sh | 4 +- ci/genmaasconfig.py | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 767 insertions(+), 760 deletions(-) delete mode 100755 ci/00-bootstrap.sh create mode 100755 ci/00-maasdeploy.sh create mode 100755 ci/01-bootstrap.sh delete mode 100755 ci/01-deploybundle.sh create mode 100755 ci/02-deploybundle.sh delete mode 100755 ci/02-maasdeploy.sh delete mode 100644 ci/deploy.py create mode 100644 ci/genmaasconfig.py (limited to 'ci') diff --git a/ci/00-bootstrap.sh b/ci/00-bootstrap.sh deleted file mode 100755 index 59a22197..00000000 --- a/ci/00-bootstrap.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -ex - -#export JUJU_DEV_FEATURE_FLAGS=address-allocation - -juju bootstrap --debug --to bootstrap.maas -sleep 5 -#disable juju gui until xenial charms are in charm store. -juju deploy cs:juju-gui-130 --to 0 - -JUJU_REPOSITORY= -juju set-constraints tags= - diff --git a/ci/00-maasdeploy.sh b/ci/00-maasdeploy.sh new file mode 100755 index 00000000..f25a36d9 --- /dev/null +++ b/ci/00-maasdeploy.sh @@ -0,0 +1,310 @@ +#!/bin/bash +#placeholder for deployment script. +set -ex + +virtinstall=0 +labname=$1 + +#install the packages needed +sudo apt-add-repository ppa:maas-deployers/stable -y +sudo apt-add-repository ppa:juju/stable -y +sudo apt-add-repository ppa:maas/stable -y +sudo apt-add-repository cloud-archive:mitaka -y +sudo apt-get update -y +sudo apt-get dist-upgrade -y +sudo apt-get install openssh-server bzr git maas-deployer juju juju-deployer \ + maas-cli python-pip python-psutil python-openstackclient \ + python-congressclient gsutil charm-tools -y + +#first parameter should be custom and second should be either +# absolute location of file (including file name) or url of the +# file to download. + +if [ "$1" == "custom" ]; then + if [ -e $2 ]; then + cp $2 ./labconfig.yaml || true + python genmaasconfig.py + else + wget $2 -t 3 -T 10 -O ./labconfig.yaml || true + count=`wc -l labconfig.yaml | cut -d " " -f 1` + + if [ $count -lt 10 ]; then + rm -rf labconfig.yaml + else + python genmaasconfig.py + fi + fi + + if [ ! -e ./labconfig.yaml ]; then + virtinstall=1 + cp ../labconfig/default/deployment.yaml ./ + cp ../labconfig/default/labconfig.yaml ./ + fi + labname=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` +else + case "$1" in + 'intelpod5' ) + cp ../labconfig/intel/pod5/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'intelpod6' ) + cp ../labconfig/intel/pod6/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'intelpod9' ) + cp ../labconfig/intel/pod6/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'orangepod1' ) + cp ../labconfig/orange/pod1/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'orangepod2' ) + cp ../labconfig/orange/pod1/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'attvirpod1' ) + cp ../labconfig/att/virpod1/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'juniperpod1' ) + cp maas/juniper/pod1/deployment.yaml ./deployment.yaml + ;; + 'cengnpod1' ) + cp ../labconfig/cengn/pod1/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + 'cengnpod2' ) + cp ../labconfig/cengn/pod2/labconfig.yaml ./ + #to be removed later once converted for all labs. + python genmaasconfig.py + ;; + * ) + virtinstall=1 + labname="default" + ./cleanvm.sh + cp ../labconfig/default/deployment.yaml ./ + cp ../labconfig/default/deployconfig.yaml ./ + ;; + esac +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/ +else + sudo chown root:root 90-joid-init + sudo mv 90-joid-init /etc/sudoers.d/ +fi + +echo "... Deployment of maas Started ...." + +if [ ! -e $HOME/.ssh/id_rsa ]; then + ssh-keygen -N '' -f $HOME/.ssh/id_rsa +fi + +#define the pool and try to start even though its already exist. +# For fresh install this may or may not there. + +sudo apt-get install libvirt-bin -y +sudo adduser $USER libvirtd +sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true +sudo virsh pool-start default || true +sudo virsh pool-autostart default || true + +# To avoid problem between apiclient/maas_client and apiclient from google +# we remove the package google-api-python-client from yardstick installer +if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then + sudo pip uninstall google-api-python-client +fi + +sudo pip install shyaml +juju init -f + +cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys + +if [ "$virtinstall" -eq 1 ]; then + sudo virsh net-dumpxml default > default-net-org.xml + sudo sed -i '/dhcp/d' default-net-org.xml + sudo sed -i '/range/d' default-net-org.xml + sudo virsh net-define default-net-org.xml + sudo virsh net-destroy default + sudo virsh net-start default +fi + +#Below function will mark the interfaces in Auto mode to enbled by MAAS +enableautomode() { + listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4` + for nodes in $listofnodes + do + maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3 + done +} + +#Below function will mark the interfaces in Auto mode to enbled by MAAS +# using hostname of the node added into MAAS + +enableautomodebyname() { + if [ ! -z "$4" ]; then + for i in `seq 1 7`; + do + nodes=`maas maas nodes list hostname=node$i-$4 | grep system_id | cut -d '"' -f 4` + if [ ! -z "$nodes" ]; then + maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3 + fi + done + fi +} + +#Below function will create vlan and update interface with the new vlan +# will return the vlan id created +crvlanupdsubnet() { + newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 ` + maas maas subnet update $5 vlan=$newvlanid + eval "$1"="'$newvlanid'" +} + +#Below function will create interface with new vlan and bind to physical interface +crnodevlanint() { + listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4` + + for nodes in $listofnodes + do + parentid=`maas maas interface read $nodes $2 | grep interfaces | cut -d '/' -f 8` + maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid + done + } + +#just make sure the ssh keys added into maas for the current user +sed --i "s@/home/ubuntu@$HOME@g" ./deployment.yaml +sed --i "s@qemu+ssh://ubuntu@qemu+ssh://$USER@g" ./deployment.yaml + +cp ./deployment.yaml ~/.juju/ + +if [ -e ./deployconfig.yaml ]; then + cp ./deployconfig.yaml ~/.juju/ +fi + +sudo maas-deployer -c deployment.yaml -d --force + +sudo chown $USER:$USER environments.yaml + +echo "... Deployment of maas finish ...." + +maas_ip=`grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` +apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2` +maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey} +maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`" + +#Added the Qtip public to run the Qtip test after install on bare metal nodes. +maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`" +maas maas sshkeys new key="`cat ./maas/sshkeys/DominoKey.pub`" + +#adding compute and control nodes VM to MAAS for deployment purpose. +if [ "$virtinstall" -eq 1 ]; then + # create two more VMs to do the deployment. + sudo virt-install --connect qemu:///system --name node1-control --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node1-control + + sudo virt-install --connect qemu:///system --name node2-compute --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node2-compute + + sudo virt-install --connect qemu:///system --name node5-compute --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node5-compute + + node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2` + node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2` + node5computemac=`grep "mac address" node5-compute | head -1 | cut -d "'" -f 2` + + sudo virsh -c qemu:///system define --file node1-control + sudo virsh -c qemu:///system define --file node2-compute + sudo virsh -c qemu:///system define --file node5-compute + + maas maas tags new name='control' + maas maas tags new name='compute' + + controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node1-control' tags='control' hostname='node1-control' power_type='virsh' mac_addresses=$node1controlmac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node1-control' | grep system_id | cut -d '"' -f 4 ` + + maas maas tag update-nodes control add=$controlnodeid + + computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node2-compute' tags='compute' hostname='node2-compute' power_type='virsh' mac_addresses=$node2computemac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node2-compute' | grep system_id | cut -d '"' -f 4 ` + + maas maas tag update-nodes compute add=$computenodeid + + computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node5-compute' tags='compute' hostname='node5-compute' power_type='virsh' mac_addresses=$node5computemac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node5-compute' | grep system_id | cut -d '"' -f 4 ` + + maas maas tag update-nodes compute add=$computenodeid +fi + +#read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer. +enable_if(){ + if [ -e ~/.juju/deployconfig.yaml ]; then + cp ~/.juju/deployconfig.yaml ./deployconfig.yaml + + 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 + + if [ "$datanet" != "''" ]; then + EXTNET=(${enableiflist//,/ }) + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + enableautomode ${EXTNET[i]} AUTO $datanet || true + i=$[$i+1] + done + fi + if [ "$stornet" != "''" ]; then + EXTNET=(${enableiflist//,/ }) + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + enableautomode ${EXTNET[i]} AUTO $stornet || true + i=$[$i+1] + done + fi + if [ "$pubnet" != "''" ]; then + EXTNET=(${enableiflist//,/ }) + i="0" + while [ ! -z "${EXTNET[i]}" ]; + do + enableautomode ${EXTNET[i]} AUTO $pubnet || true + i=$[$i+1] + done + fi + fi +} + +# Enable vlan interfaces with maas +case "$labname" in + 'intelpod9' ) + maas refresh + crvlanupdsubnet vlan902 1 "DataNetwork" 902 2 || true + crvlanupdsubnet vlan905 2 "PublicNetwork" 905 3 || true + crnodevlanint $vlan902 eth0 || true + crnodevlanint $vlan905 eth1 || true + enableautomodebyname eth0.902 AUTO "10.9.12.0/24" compute || true + enableautomodebyname eth1.905 AUTO "10.9.15.0/24" compute || true + enableautomodebyname eth0.902 AUTO "10.9.12.0/24" control || true + enableautomodebyname eth1.905 AUTO "10.9.15.0/24" control || true + ;; +esac + +enable_if + +echo " .... MAAS deployment finished successfully ...." diff --git a/ci/01-bootstrap.sh b/ci/01-bootstrap.sh new file mode 100755 index 00000000..59a22197 --- /dev/null +++ b/ci/01-bootstrap.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -ex + +#export JUJU_DEV_FEATURE_FLAGS=address-allocation + +juju bootstrap --debug --to bootstrap.maas +sleep 5 +#disable juju gui until xenial charms are in charm store. +juju deploy cs:juju-gui-130 --to 0 + +JUJU_REPOSITORY= +juju set-constraints tags= + diff --git a/ci/01-deploybundle.sh b/ci/01-deploybundle.sh deleted file mode 100755 index 10be1697..00000000 --- a/ci/01-deploybundle.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -#placeholder for deployment script. -set -ex - -# ./01-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro - - #copy and download charms - cp $4/fetch-charms.sh ./fetch-charms.sh - #modify the ubuntu series wants to deploy - sed -i -- "s|distro=trusty|distro=$6|g" ./fetch-charms.sh - ./fetch-charms.sh $6 - -osdomname='' - -#check whether charms are still executing the code even juju-deployer says installed. -check_status() { - retval=0 - timeoutiter=0 - while [ $retval -eq 0 ]; do - sleep 30 - juju status > status.txt - if [ "$(grep -c "executing" status.txt )" -ge 2 ]; then - echo " still executing the reltionship within charms ..." - if [ $timeoutiter -ge 60 ]; then - retval=1 - fi - timeoutiter=$((timeoutiter+1)) - else - retval=1 - fi - done - echo "...... deployment finishing ......." -} - -#read the value from deployment.yaml -if [ -e ~/.juju/deployment.yaml ]; then - cp ~/.juju/deployment.yaml ./deployment.yaml - if [ -e ~/.juju/deployconfig.yaml ]; then - cp ~/.juju/deployconfig.yaml ./deployconfig.yaml - extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '` - datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` - admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` - cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` - osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` - fi -fi - -case "$3" in - 'juniperpod1' ) - sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml - sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml - ;; - 'ravellodemopod' ) - sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml - ;; -esac - -# lets put the if seperateor as "," as this will save me from world. -fea="" -IFS="," -for feature in $5; do - if [ "$fea" == "" ]; then - fea=$feature - else - fea=$fea"_"$feature - fi -done - -#update source if trusty is target distribution -var=os-$4-$fea-$1"-"$6"_"$2 - -if [ "$osdomname" != "''" ]; then - var=$var"_"publicapi -fi - -#lets generate the bundle for all target using genBundle.py -python genBundle.py -l deployconfig.yaml -s $var > bundles.yaml - -echo "... Deployment Started ...." -juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2"-nodes - -# seeing issue related to number of open files. -# juju run --service nodes 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' - -count=`juju status nodes --format=short | grep nodes | wc -l` - -c=0 -while [ $c -lt $count ]; do - juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' - let c+=1 -done - -juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2" || true diff --git a/ci/02-deploybundle.sh b/ci/02-deploybundle.sh new file mode 100755 index 00000000..ffacef9f --- /dev/null +++ b/ci/02-deploybundle.sh @@ -0,0 +1,102 @@ +#!/bin/bash +#placeholder for deployment script. +set -ex + +# ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro + +opnfvtype=$1 +openstack=$2 +opnfvlab=$3 +opnfvsdn=$4 +opnfvfeature=$5 +opnfvdistro=$6 + +#copy and download charms +cp $opnfvsdn/fetch-charms.sh ./fetch-charms.sh + +#modify the ubuntu series wants to deploy +sed -i -- "s|distro=trusty|distro=$opnfvdistro|g" ./fetch-charms.sh + +./fetch-charms.sh $opnfvdistro + +osdomname='' + +#check whether charms are still executing the code even juju-deployer says installed. +check_status() { + retval=0 + timeoutiter=0 + while [ $retval -eq 0 ]; do + sleep 30 + juju status > status.txt + if [ "$(grep -c "executing" status.txt )" -ge 2 ]; then + echo " still executing the reltionship within charms ..." + if [ $timeoutiter -ge 60 ]; then + retval=1 + fi + timeoutiter=$((timeoutiter+1)) + else + retval=1 + fi + done + echo "...... deployment finishing ......." +} + +#read the value from deployment.yaml +if [ -e ~/.juju/deployment.yaml ]; then + cp ~/.juju/deployment.yaml ./deployment.yaml + if [ -e ~/.juju/deployconfig.yaml ]; then + cp ~/.juju/deployconfig.yaml ./deployconfig.yaml + extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '` + datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` + admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'` + cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` + osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'` + fi +fi + +case "$opnfvlab" in + 'juniperpod1' ) + sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml + sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml + ;; + 'ravellodemopod' ) + sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml + ;; +esac + +# lets put the if seperateor as "," as this will save me from world. +fea="" +IFS="," +for feature in $opnfvfeature; do + if [ "$fea" == "" ]; then + fea=$feature + else + fea=$fea"_"$feature + fi +done + +#update source if trusty is target distribution +var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack + +if [ "$osdomname" != "''" ]; then + var=$var"_"publicapi +fi + +#lets generate the bundle for all target using genBundle.py +python genBundle.py -l deployconfig.yaml -s $var > bundles.yaml + +echo "... Deployment Started ...." +juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack"-nodes + +# seeing issue related to number of open files. +# juju run --service nodes 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' + +count=`juju status nodes --format=short | grep nodes | wc -l` + +c=0 +while [ $c -lt $count ]; do + juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' + let c+=1 +done + +juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true diff --git a/ci/02-maasdeploy.sh b/ci/02-maasdeploy.sh deleted file mode 100755 index 07acfe2a..00000000 --- a/ci/02-maasdeploy.sh +++ /dev/null @@ -1,312 +0,0 @@ -#!/bin/bash -#placeholder for deployment script. -set -ex - -virtinstall=0 -labname=$1 - -#install the packages needed -sudo apt-add-repository ppa:maas-deployers/stable -y -sudo apt-add-repository ppa:juju/stable -y -sudo apt-add-repository ppa:maas/stable -y -sudo apt-add-repository cloud-archive:mitaka -y -sudo apt-get update -y -sudo apt-get dist-upgrade -y -sudo apt-get install openssh-server bzr git maas-deployer juju juju-deployer \ - maas-cli python-pip python-psutil python-openstackclient \ - python-congressclient gsutil charm-tools -y - -#first parameter should be custom and second should be either -# absolute location of file (including file name) or url of the -# file to download. - -if [ "$1" == "custom" ]; then - if [ -e $2 ]; then - cp $2 ./labconfig.yaml || true - python deploy.py - else - wget $2 -t 3 -T 10 -O ./labconfig.yaml || true - count=`wc -l labconfig.yaml | cut -d " " -f 1` - - if [ $count -lt 10 ]; then - rm -rf labconfig.yaml - else - python deploy.py - fi - fi - - if [ ! -e ./labconfig.yaml ]; then - virtinstall=1 - cp ../labconfig/default/deployment.yaml ./ - cp ../labconfig/default/labconfig.yaml ./ - fi - labname=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` -else - case "$1" in - 'intelpod5' ) - cp ../labconfig/intel/pod5/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'intelpod6' ) - cp ../labconfig/intel/pod6/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'intelpod9' ) - cp ../labconfig/intel/pod6/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'orangepod1' ) - cp ../labconfig/orange/pod1/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'orangepod2' ) - cp ../labconfig/orange/pod1/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'attvirpod1' ) - cp ../labconfig/att/virpod1/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'juniperpod1' ) - cp maas/juniper/pod1/deployment.yaml ./deployment.yaml - ;; - 'cengnpod1' ) - cp ../labconfig/cengn/pod1/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - 'cengnpod2' ) - cp ../labconfig/cengn/pod2/labconfig.yaml ./ - #to be removed later once converted for all labs. - python deploy.py - ;; - * ) - virtinstall=1 - labname="default" - ./cleanvm.sh - cp ../labconfig/default/deployment.yaml ./ - cp ../labconfig/default/deployconfig.yaml ./ - ;; - esac -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/ -else - sudo chown root:root 90-joid-init - sudo mv 90-joid-init /etc/sudoers.d/ -fi - -echo "... Deployment of maas Started ...." - -if [ ! -e $HOME/.ssh/id_rsa ]; then - ssh-keygen -N '' -f $HOME/.ssh/id_rsa -fi - -#define the pool and try to start even though its already exist. -# For fresh install this may or may not there. - -sudo apt-get install libvirt-bin -y -sudo adduser $USER libvirtd -sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true -sudo virsh pool-start default || true -sudo virsh pool-autostart default || true - -# To avoid problem between apiclient/maas_client and apiclient from google -# we remove the package google-api-python-client from yardstick installer -if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then - sudo pip uninstall google-api-python-client -fi - -sudo pip install shyaml -juju init -f - -cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys - -if [ "$virtinstall" -eq 1 ]; then - sudo virsh net-dumpxml default > default-net-org.xml - sudo sed -i '/dhcp/d' default-net-org.xml - sudo sed -i '/range/d' default-net-org.xml - sudo virsh net-define default-net-org.xml - sudo virsh net-destroy default - sudo virsh net-start default -fi - -#Below function will mark the interfaces in Auto mode to enbled by MAAS -enableautomode() { - listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4` - for nodes in $listofnodes - do - maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3 - done -} - -#Below function will mark the interfaces in Auto mode to enbled by MAAS -# using hostname of the node added into MAAS - -enableautomodebyname() { - if [ ! -z "$4" ]; then - for i in `seq 1 7`; - do - nodes=`maas maas nodes list hostname=node$i-$4 | grep system_id | cut -d '"' -f 4` - if [ ! -z "$nodes" ]; then - maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3 - fi - done - fi -} - -#Below function will create vlan and update interface with the new vlan -# will return the vlan id created -crvlanupdsubnet() { - newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 ` - maas maas subnet update $5 vlan=$newvlanid - eval "$1"="'$newvlanid'" -} - -#Below function will create interface with new vlan and bind to physical interface -crnodevlanint() { - listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4` - - for nodes in $listofnodes - do - parentid=`maas maas interface read $nodes $2 | grep interfaces | cut -d '/' -f 8` - maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid - done - } - -#just make sure the ssh keys added into maas for the current user -sed --i "s@/home/ubuntu@$HOME@g" ./deployment.yaml -sed --i "s@qemu+ssh://ubuntu@qemu+ssh://$USER@g" ./deployment.yaml - -cp ./deployment.yaml ~/.juju/ - -if [ -e ./deployconfig.yaml ]; then - cp ./deployconfig.yaml ~/.juju/ -fi - -sudo maas-deployer -c deployment.yaml -d --force - -sudo chown $USER:$USER environments.yaml - -echo "... Deployment of maas finish ...." - -maas_ip=`grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'` -apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2` -maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey} -maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`" - -#Added the Qtip public to run the Qtip test after install on bare metal nodes. -maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`" -maas maas sshkeys new key="`cat ./maas/sshkeys/DominoKey.pub`" - -#adding compute and control nodes VM to MAAS for deployment purpose. -if [ "$virtinstall" -eq 1 ]; then - # create two more VMs to do the deployment. - sudo virt-install --connect qemu:///system --name node1-control --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node1-control - - sudo virt-install --connect qemu:///system --name node2-compute --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node2-compute - - sudo virt-install --connect qemu:///system --name node5-compute --ram 8192 --vcpus 4 --disk size=120,format=qcow2,bus=virtio,io=native,pool=default --network bridge=virbr0,model=virtio --network bridge=virbr0,model=virtio --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node5-compute - - node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2` - node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2` - node5computemac=`grep "mac address" node5-compute | head -1 | cut -d "'" -f 2` - - sudo virsh -c qemu:///system define --file node1-control - sudo virsh -c qemu:///system define --file node2-compute - sudo virsh -c qemu:///system define --file node5-compute - - maas maas tags new name='control' - maas maas tags new name='compute' - - controlnodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node1-control' tags='control' hostname='node1-control' power_type='virsh' mac_addresses=$node1controlmac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node1-control' | grep system_id | cut -d '"' -f 4 ` - - maas maas tag update-nodes control add=$controlnodeid - - computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node2-compute' tags='compute' hostname='node2-compute' power_type='virsh' mac_addresses=$node2computemac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node2-compute' | grep system_id | cut -d '"' -f 4 ` - - maas maas tag update-nodes compute add=$computenodeid - - computenodeid=`maas maas nodes new autodetect_nodegroup='yes' name='node5-compute' tags='compute' hostname='node5-compute' power_type='virsh' mac_addresses=$node5computemac power_parameters_power_address='qemu+ssh://'$USER'@192.168.122.1/system' architecture='amd64/generic' power_parameters_power_id='node5-compute' | grep system_id | cut -d '"' -f 4 ` - - maas maas tag update-nodes compute add=$computenodeid -fi - -#read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer. -enable_if(){ - if [ -e ~/.juju/deployconfig.yaml ]; then - cp ~/.juju/deployconfig.yaml ./deployconfig.yaml - - 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 - - if [ "$datanet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) - i="0" - while [ ! -z "${EXTNET[i]}" ]; - do - enableautomode ${EXTNET[i]} AUTO $datanet || true - i=$[$i+1] - done - fi - if [ "$stornet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) - i="0" - while [ ! -z "${EXTNET[i]}" ]; - do - enableautomode ${EXTNET[i]} AUTO $stornet || true - i=$[$i+1] - done - fi - if [ "$pubnet" != "''" ]; then - EXTNET=(${enableiflist//,/ }) - i="0" - while [ ! -z "${EXTNET[i]}" ]; - do - enableautomode ${EXTNET[i]} AUTO $pubnet || true - i=$[$i+1] - done - fi - fi -} - -# Enable vlan interfaces with maas -case "$labname" in - 'intelpod9' ) - maas refresh - crvlanupdsubnet vlan902 1 "DataNetwork" 902 2 || true - crvlanupdsubnet vlan905 2 "PublicNetwork" 905 3 || true - crnodevlanint $vlan902 eth0 || true - crnodevlanint $vlan905 eth1 || true - enableautomodebyname eth0.902 AUTO "10.9.12.0/24" compute || true - enableautomodebyname eth1.905 AUTO "10.9.15.0/24" compute || true - enableautomodebyname eth0.902 AUTO "10.9.12.0/24" control || true - enableautomodebyname eth1.905 AUTO "10.9.15.0/24" control || true - ;; - 'juniperpod1' ) - ;; -esac - -enable_if - -echo " .... MAAS deployment finished successfully ...." diff --git a/ci/deploy.py b/ci/deploy.py deleted file mode 100644 index 0ca0b778..00000000 --- a/ci/deploy.py +++ /dev/null @@ -1,339 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -""" -Deploy JOID -""" - -import yaml -import socket -import fcntl -import struct -import getpass - - -def get_ip_address(ifname): - """Get local IP""" - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl( - s.fileno(), - 0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]) - )[20:24]) - -with open('labconfig.yaml', 'r') as labf: - try: - labcfg = yaml.load(labf) - except yaml.YAMLError as exc: - print(exc) - - -opnfvcfg = {} -opnfvlabcfg = {} - - -def get_from_dict(dataDict, mapList): - return reduce(lambda d, k: d[k], mapList, dataDict) - -# lets define the bootstrap section -opnfvcfg['demo-maas'] = {'juju-bootstrap': {'memory': 4096, - 'name': "bootstrap", - 'pool': "default", - 'vcpus': 4, - 'disk_size': "60G", - 'arch': "amd64", - 'interfaces': []}, - 'maas': {'memory': 4096, - 'pool': "default", - 'vcpus': 4, - 'disk_size': "160G", - 'arch': "amd64", - 'interfaces': [], - 'name': "", - 'network_config': [], - 'node_group_ifaces': [], - 'nodes': [], - 'password': 'ubuntu', - 'user': 'ubuntu', - 'release': 'trusty', - 'apt_sources': [], - 'ip_address': '', - 'boot_source': { - 'keyring_filename': "/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg", - 'url': "http://maas.ubuntu.com/images/ephemeral-v2/releases/", - 'selections': { - '1': { - 'arches': 'amd64', - 'labels': 'release', - 'os': 'ubuntu', - 'release': 'xenial', - 'subarches': '*' - } - } - }, - 'settings': {'maas_name': '', - 'upstream_dns': '', - 'main_archive': "http://archive.ubuntu.com/ubuntu" - }, - 'virsh': {'rsa_priv_key': '/home/ubuntu/.ssh/id_rsa', - 'rsa_pub_key': '/home/ubuntu/.ssh/id_rsa.pub', - 'uri': '' - } - } - } - -opnfvlabcfg['opnfv'] = {'ext-port': '', - 'floating-ip-range': '', - 'dataNetwork': '', - 'ceph-disk': '/srv/', - 'storageNetwork': '', - 'interface-enable': '', - 'publicNetwork': '', - 'os-domain-name': '', - 'vip': {'rabbitmq': '', - 'dashboard': '', - 'glance': '', - 'keystone': '', - 'ceilometer': '', - 'mysql': '', - 'nova': '', - 'neutron': '', - 'heat': '', - 'cinder': ''} - } - - -opnfvcfg['demo-maas']['maas']['apt_sources'].append("ppa:maas/stable") -opnfvcfg['demo-maas']['maas']['apt_sources'].append("ppa:juju/stable") - -# lets modify the maas general settings: - -updns = get_from_dict(labcfg, ["lab", "racks", 0, "dns"]) -opnfvcfg["demo-maas"]["maas"]["settings"]["upstream_dns"] = updns - -location = get_from_dict(labcfg, ["lab", "location"]) -rack = get_from_dict(labcfg, ["lab", "racks", 0, "rack"]) -value = location+rack - -opnfvcfg["demo-maas"]["maas"]["settings"]["maas_name"] = value -opnfvcfg["demo-maas"]["maas"]["name"] = "opnfv-"+value - -ethbrAdm = "" -ethbrAdmin = "" - -c = 0 -y = 0 -# z = 0 - -while c < len(labcfg["opnfv"]["spaces"]): - brtype = get_from_dict(labcfg, ["opnfv", "spaces", c, "type"]) - brname = get_from_dict(labcfg, ["opnfv", "spaces", c, "bridge"]) - brcidr = get_from_dict(labcfg, ["opnfv", "spaces", c, "cidr"]) -# - if brtype == "admin": - ethbrAdmin = get_from_dict(labcfg, ["opnfv", "spaces", c, "bridge"]) - brgway = get_from_dict(labcfg, ["opnfv", "spaces", c, "gateway"]) - tmpcidr = brcidr[:-4] - opnfvlabcfg["opnfv"]["admNetwork"] = tmpcidr+"2" - opnfvlabcfg["opnfv"]["admNetgway"] = brgway - - nodegroup = {"device": "eth"+str(y), - "ip": tmpcidr+"5", - "subnet_mask": "255.255.255.0", - "broadcast_ip": tmpcidr+"255", - "router_ip": brgway, - "static_range": {"high": tmpcidr+"80", - "low": tmpcidr+"50"}, - "dynamic_range": {"high": tmpcidr+"250", - "low": tmpcidr+"81"}} - - ethbrAdm = ('auto lo\n' - ' iface lo inet loopback\n\n' - 'auto eth'+str(y)+'\n' - ' iface eth'+str(y)+' inet static\n' - ' address '+tmpcidr+'5\n' - ' netmask 255.255.255.0\n' - ' gateway '+brgway+'\n' - ' dns-nameservers '+updns+' '+tmpcidr+'5 127.0.0.1\n') - - opnfvcfg['demo-maas']['maas']['ip_address'] = tmpcidr+"5" - opnfvcfg['demo-maas']['maas']['interfaces'].append( - "bridge="+brname+",model=virtio") - opnfvcfg['demo-maas']['juju-bootstrap']['interfaces'].append( - "bridge="+brname+",model=virtio") - opnfvcfg["demo-maas"]["maas"]["node_group_ifaces"].append(nodegroup) - y = y+1 - elif brtype: - opnfvcfg["demo-maas"]["maas"]["interfaces"].append( - "bridge="+brname+",model=virtio") - brgway = get_from_dict(labcfg, ["opnfv", "spaces", c, "gateway"]) - if brtype != "external": - tmpcidr = brcidr[:-4] - if brgway: - nodegroup = {"device": "eth"+str(y), - "ip": tmpcidr+"5", - "subnet_mask": "255.255.255.0", - "broadcast_ip": tmpcidr+"255", - "management": 1, - "router_ip": brgway, - "static_range": {"high": tmpcidr+"80", - "low": tmpcidr+"50"}, - "dynamic_range": {"high": tmpcidr+"250", - "low": tmpcidr+"81"}} - else: - nodegroup = {"device": "eth"+str(y), - "ip": tmpcidr+"5", - "subnet_mask": "255.255.255.0", - "broadcast_ip": tmpcidr+"255", - "management": 1, - "static_range": {"high": tmpcidr+"80", - "low": tmpcidr+"50"}, - "dynamic_range": {"high": tmpcidr+"250", - "low": tmpcidr+"81"}} - opnfvcfg["demo-maas"]["maas"]["node_group_ifaces"].append( - nodegroup) - ethbrAdm = (ethbrAdm+'\n' - 'auto eth'+str(y)+'\n' - ' iface eth'+str(y)+' inet static\n' - ' address '+tmpcidr+'5\n' - ' netmask 255.255.255.0\n') - y = y+1 - if brtype == "public": - opnfvcfg["demo-maas"]["juju-bootstrap"]["interfaces"].append( - "bridge="+brname+",model=virtio") - opnfvlabcfg["opnfv"]["publicNetwork"] = brcidr - if brtype == "external": - ipaddress = get_from_dict(labcfg, ["opnfv", "spaces", - c, "ipaddress"]) - ethbrAdm = (ethbrAdm+'\n' - 'auto eth'+str(y)+'\n' - ' iface eth'+str(y)+' inet static\n' - ' address '+ipaddress+'\n' - ' netmask 255.255.255.0\n') - opnfvcfg["demo-maas"]["juju-bootstrap"]["interfaces"].append( - "bridge="+brname+",model=virtio") - if brtype == "data": - opnfvlabcfg["opnfv"]["dataNetwork"] = brcidr - if brtype == "storage": - opnfvlabcfg["opnfv"]["storageNetwork"] = brcidr - - c = c+1 - -# lets modify the maas general settings: -value = get_ip_address(ethbrAdmin) -value = "qemu+ssh://"+getpass.getuser()+"@"+value+"/system" -opnfvcfg['demo-maas']['maas']['virsh']['uri'] = value -opnfvcfg['demo-maas']['maas']['network_config'] = ethbrAdm - -if len(labcfg["lab"]["racks"][0]["nodes"]) < 1: - print("looks like virtual deployment where nodes were not defined") - opnfvcfg["demo-maas"]["maas"]["nodes"].remove() - exit() - -# lets insert the node details here: -c = 0 -ifnamelist = [] -# -while c < len(labcfg["lab"]["racks"][0]["nodes"]): - valuemac = [] - y = 0 - # setup value of name and tags accordigly - noderoleslist = labcfg["lab"]["racks"][0]["nodes"][c]["roles"] - noderoles = " ".join(noderoleslist) - - valuetype = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", - c, "power", "type"]) - namevalue = labcfg["lab"]["racks"][0]["nodes"][c]["name"] - valuearc = get_from_dict(labcfg, ["lab", "racks", 0, - "nodes", c, "architecture"]) - # setup value of architecture - if valuearc == "x86_64": - valuearc = "amd64/generic" - - if valuetype == "wakeonlan": - macvalue = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", - c, "power", "mac_address"]) - power = {"type": "ether_wake", "mac_address": macvalue} - if valuetype == "ipmi": - valueaddr = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, - "power", "address"]) - valueuser = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, - "power", "user"]) - valuepass = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, - "power", "pass"]) - valuedriver = "LAN_2_0" - power = {"type": valuetype, "address": valueaddr, "user": valueuser, - "pass": valuepass, "driver": valuedriver} - - opnfvcfg["demo-maas"]["maas"]["nodes"].append( - {"name": namevalue, - "architecture": valuearc, - "interfaces": [], - "mac_addresses": [], - "power": power, - 'tags': noderoles}) - - y = 0 - while y < len(labcfg["lab"]["racks"][0]["nodes"][c]["nics"]): - valuespaces = labcfg["lab"]["racks"][0]["nodes"][c][ - "nics"][y]["spaces"] - valueifname = labcfg["lab"]["racks"][0]["nodes"][c][ - "nics"][y]["ifname"] - if "admin" not in valuespaces: - ifnamelist += [valueifname] - valueifmac = labcfg["lab"]["racks"][0]["nodes"][c]["nics"][y]["mac"][0] - valuemac += labcfg["lab"]["racks"][0]["nodes"][c]["nics"][y]["mac"] - opnfvcfg["demo-maas"]["maas"]["nodes"][c]["interfaces"].append( - {"name": valueifname, - "mac_address": valueifmac, - "mode": "auto"}) - y = y+1 - - if valueifmac: - opnfvcfg["demo-maas"]["maas"]["nodes"][c]['mac_addresses'] = valuemac - - c = c+1 - -opnfvlabcfg["opnfv"]["floating-ip-range"] =\ - labcfg["lab"]["racks"][0]["floating-ip-range"] -opnfvlabcfg["opnfv"]["ext-port"] =\ - labcfg["lab"]["racks"][0]["ext-port"] -opnfvlabcfg["opnfv"]["ceph-disk"] =\ - labcfg["opnfv"]["storage"][0]["disk"] -opnfvlabcfg["opnfv"]["interface-enable"] =\ - ",".join(list(set(ifnamelist))) - -# setup vip addresss for HA -opnfvlabcfg["opnfv"]["vip"]["rabbitmq"] =\ - opnfvlabcfg["opnfv"]["admNetwork"]+"0" -opnfvlabcfg["opnfv"]["vip"]["dashboard"] =\ - opnfvlabcfg["opnfv"]["admNetwork"]+"1" -opnfvlabcfg["opnfv"]["vip"]["glance"] = opnfvlabcfg["opnfv"]["admNetwork"]+"2" -opnfvlabcfg["opnfv"]["vip"]["keystone"] =\ - opnfvlabcfg["opnfv"]["admNetwork"]+"3" -opnfvlabcfg["opnfv"]["vip"]["ceilometer"] =\ - opnfvlabcfg["opnfv"]["admNetwork"]+"4" -opnfvlabcfg["opnfv"]["vip"]["mysql"] = opnfvlabcfg["opnfv"]["admNetwork"]+"5" -opnfvlabcfg["opnfv"]["vip"]["nova"] = opnfvlabcfg["opnfv"]["admNetwork"]+"6" -opnfvlabcfg["opnfv"]["vip"]["neutron"] = opnfvlabcfg["opnfv"]["admNetwork"]+"7" -opnfvlabcfg["opnfv"]["vip"]["heat"] = opnfvlabcfg["opnfv"]["admNetwork"]+"8" -opnfvlabcfg["opnfv"]["vip"]["cinder"] = opnfvlabcfg["opnfv"]["admNetwork"]+"9" - -osdomname = labcfg["lab"]["racks"][0]["osdomainname"] - -if osdomname: - opnfvlabcfg["opnfv"]["os-domain-name"] =\ - labcfg["lab"]["racks"][0]["osdomainname"] - opnfvlabcfg["opnfv"]["domain"] = labcfg["lab"]["racks"][0]["osdomainname"] - -opnfvlabcfg["opnfv"]["ext_port"] = labcfg["lab"]["racks"][0]["ext-port"] -opnfvlabcfg["opnfv"]["units"] = len(labcfg["lab"]["racks"][0]["nodes"]) -opnfvlabcfg["opnfv"]["admin_password"] = "openstack" -opnfvlabcfg["opnfv"]["storage"] = labcfg["opnfv"]["storage"] -opnfvlabcfg["opnfv"]["spaces"] = labcfg["opnfv"]["spaces"] - -with open('deployment.yaml', 'wa') as opnfvf: - yaml.dump(opnfvcfg, opnfvf, default_flow_style=False) - -with open('deployconfig.yaml', 'wa') as opnfvf: - yaml.dump(opnfvlabcfg, opnfvf, default_flow_style=False) diff --git a/ci/deploy.sh b/ci/deploy.sh index d5c8cc2d..15aa60e5 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -126,10 +126,10 @@ deploy() { fi #bootstrap the node - ./00-bootstrap.sh + ./01-bootstrap.sh #case default deploy the opnfv platform: - ./01-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro + ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro } #check whether charms are still executing the code even juju-deployer says installed. diff --git a/ci/genmaasconfig.py b/ci/genmaasconfig.py new file mode 100644 index 00000000..0ca0b778 --- /dev/null +++ b/ci/genmaasconfig.py @@ -0,0 +1,339 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +""" +Deploy JOID +""" + +import yaml +import socket +import fcntl +import struct +import getpass + + +def get_ip_address(ifname): + """Get local IP""" + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + return socket.inet_ntoa(fcntl.ioctl( + s.fileno(), + 0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]) + )[20:24]) + +with open('labconfig.yaml', 'r') as labf: + try: + labcfg = yaml.load(labf) + except yaml.YAMLError as exc: + print(exc) + + +opnfvcfg = {} +opnfvlabcfg = {} + + +def get_from_dict(dataDict, mapList): + return reduce(lambda d, k: d[k], mapList, dataDict) + +# lets define the bootstrap section +opnfvcfg['demo-maas'] = {'juju-bootstrap': {'memory': 4096, + 'name': "bootstrap", + 'pool': "default", + 'vcpus': 4, + 'disk_size': "60G", + 'arch': "amd64", + 'interfaces': []}, + 'maas': {'memory': 4096, + 'pool': "default", + 'vcpus': 4, + 'disk_size': "160G", + 'arch': "amd64", + 'interfaces': [], + 'name': "", + 'network_config': [], + 'node_group_ifaces': [], + 'nodes': [], + 'password': 'ubuntu', + 'user': 'ubuntu', + 'release': 'trusty', + 'apt_sources': [], + 'ip_address': '', + 'boot_source': { + 'keyring_filename': "/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg", + 'url': "http://maas.ubuntu.com/images/ephemeral-v2/releases/", + 'selections': { + '1': { + 'arches': 'amd64', + 'labels': 'release', + 'os': 'ubuntu', + 'release': 'xenial', + 'subarches': '*' + } + } + }, + 'settings': {'maas_name': '', + 'upstream_dns': '', + 'main_archive': "http://archive.ubuntu.com/ubuntu" + }, + 'virsh': {'rsa_priv_key': '/home/ubuntu/.ssh/id_rsa', + 'rsa_pub_key': '/home/ubuntu/.ssh/id_rsa.pub', + 'uri': '' + } + } + } + +opnfvlabcfg['opnfv'] = {'ext-port': '', + 'floating-ip-range': '', + 'dataNetwork': '', + 'ceph-disk': '/srv/', + 'storageNetwork': '', + 'interface-enable': '', + 'publicNetwork': '', + 'os-domain-name': '', + 'vip': {'rabbitmq': '', + 'dashboard': '', + 'glance': '', + 'keystone': '', + 'ceilometer': '', + 'mysql': '', + 'nova': '', + 'neutron': '', + 'heat': '', + 'cinder': ''} + } + + +opnfvcfg['demo-maas']['maas']['apt_sources'].append("ppa:maas/stable") +opnfvcfg['demo-maas']['maas']['apt_sources'].append("ppa:juju/stable") + +# lets modify the maas general settings: + +updns = get_from_dict(labcfg, ["lab", "racks", 0, "dns"]) +opnfvcfg["demo-maas"]["maas"]["settings"]["upstream_dns"] = updns + +location = get_from_dict(labcfg, ["lab", "location"]) +rack = get_from_dict(labcfg, ["lab", "racks", 0, "rack"]) +value = location+rack + +opnfvcfg["demo-maas"]["maas"]["settings"]["maas_name"] = value +opnfvcfg["demo-maas"]["maas"]["name"] = "opnfv-"+value + +ethbrAdm = "" +ethbrAdmin = "" + +c = 0 +y = 0 +# z = 0 + +while c < len(labcfg["opnfv"]["spaces"]): + brtype = get_from_dict(labcfg, ["opnfv", "spaces", c, "type"]) + brname = get_from_dict(labcfg, ["opnfv", "spaces", c, "bridge"]) + brcidr = get_from_dict(labcfg, ["opnfv", "spaces", c, "cidr"]) +# + if brtype == "admin": + ethbrAdmin = get_from_dict(labcfg, ["opnfv", "spaces", c, "bridge"]) + brgway = get_from_dict(labcfg, ["opnfv", "spaces", c, "gateway"]) + tmpcidr = brcidr[:-4] + opnfvlabcfg["opnfv"]["admNetwork"] = tmpcidr+"2" + opnfvlabcfg["opnfv"]["admNetgway"] = brgway + + nodegroup = {"device": "eth"+str(y), + "ip": tmpcidr+"5", + "subnet_mask": "255.255.255.0", + "broadcast_ip": tmpcidr+"255", + "router_ip": brgway, + "static_range": {"high": tmpcidr+"80", + "low": tmpcidr+"50"}, + "dynamic_range": {"high": tmpcidr+"250", + "low": tmpcidr+"81"}} + + ethbrAdm = ('auto lo\n' + ' iface lo inet loopback\n\n' + 'auto eth'+str(y)+'\n' + ' iface eth'+str(y)+' inet static\n' + ' address '+tmpcidr+'5\n' + ' netmask 255.255.255.0\n' + ' gateway '+brgway+'\n' + ' dns-nameservers '+updns+' '+tmpcidr+'5 127.0.0.1\n') + + opnfvcfg['demo-maas']['maas']['ip_address'] = tmpcidr+"5" + opnfvcfg['demo-maas']['maas']['interfaces'].append( + "bridge="+brname+",model=virtio") + opnfvcfg['demo-maas']['juju-bootstrap']['interfaces'].append( + "bridge="+brname+",model=virtio") + opnfvcfg["demo-maas"]["maas"]["node_group_ifaces"].append(nodegroup) + y = y+1 + elif brtype: + opnfvcfg["demo-maas"]["maas"]["interfaces"].append( + "bridge="+brname+",model=virtio") + brgway = get_from_dict(labcfg, ["opnfv", "spaces", c, "gateway"]) + if brtype != "external": + tmpcidr = brcidr[:-4] + if brgway: + nodegroup = {"device": "eth"+str(y), + "ip": tmpcidr+"5", + "subnet_mask": "255.255.255.0", + "broadcast_ip": tmpcidr+"255", + "management": 1, + "router_ip": brgway, + "static_range": {"high": tmpcidr+"80", + "low": tmpcidr+"50"}, + "dynamic_range": {"high": tmpcidr+"250", + "low": tmpcidr+"81"}} + else: + nodegroup = {"device": "eth"+str(y), + "ip": tmpcidr+"5", + "subnet_mask": "255.255.255.0", + "broadcast_ip": tmpcidr+"255", + "management": 1, + "static_range": {"high": tmpcidr+"80", + "low": tmpcidr+"50"}, + "dynamic_range": {"high": tmpcidr+"250", + "low": tmpcidr+"81"}} + opnfvcfg["demo-maas"]["maas"]["node_group_ifaces"].append( + nodegroup) + ethbrAdm = (ethbrAdm+'\n' + 'auto eth'+str(y)+'\n' + ' iface eth'+str(y)+' inet static\n' + ' address '+tmpcidr+'5\n' + ' netmask 255.255.255.0\n') + y = y+1 + if brtype == "public": + opnfvcfg["demo-maas"]["juju-bootstrap"]["interfaces"].append( + "bridge="+brname+",model=virtio") + opnfvlabcfg["opnfv"]["publicNetwork"] = brcidr + if brtype == "external": + ipaddress = get_from_dict(labcfg, ["opnfv", "spaces", + c, "ipaddress"]) + ethbrAdm = (ethbrAdm+'\n' + 'auto eth'+str(y)+'\n' + ' iface eth'+str(y)+' inet static\n' + ' address '+ipaddress+'\n' + ' netmask 255.255.255.0\n') + opnfvcfg["demo-maas"]["juju-bootstrap"]["interfaces"].append( + "bridge="+brname+",model=virtio") + if brtype == "data": + opnfvlabcfg["opnfv"]["dataNetwork"] = brcidr + if brtype == "storage": + opnfvlabcfg["opnfv"]["storageNetwork"] = brcidr + + c = c+1 + +# lets modify the maas general settings: +value = get_ip_address(ethbrAdmin) +value = "qemu+ssh://"+getpass.getuser()+"@"+value+"/system" +opnfvcfg['demo-maas']['maas']['virsh']['uri'] = value +opnfvcfg['demo-maas']['maas']['network_config'] = ethbrAdm + +if len(labcfg["lab"]["racks"][0]["nodes"]) < 1: + print("looks like virtual deployment where nodes were not defined") + opnfvcfg["demo-maas"]["maas"]["nodes"].remove() + exit() + +# lets insert the node details here: +c = 0 +ifnamelist = [] +# +while c < len(labcfg["lab"]["racks"][0]["nodes"]): + valuemac = [] + y = 0 + # setup value of name and tags accordigly + noderoleslist = labcfg["lab"]["racks"][0]["nodes"][c]["roles"] + noderoles = " ".join(noderoleslist) + + valuetype = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", + c, "power", "type"]) + namevalue = labcfg["lab"]["racks"][0]["nodes"][c]["name"] + valuearc = get_from_dict(labcfg, ["lab", "racks", 0, + "nodes", c, "architecture"]) + # setup value of architecture + if valuearc == "x86_64": + valuearc = "amd64/generic" + + if valuetype == "wakeonlan": + macvalue = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", + c, "power", "mac_address"]) + power = {"type": "ether_wake", "mac_address": macvalue} + if valuetype == "ipmi": + valueaddr = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, + "power", "address"]) + valueuser = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, + "power", "user"]) + valuepass = get_from_dict(labcfg, ["lab", "racks", 0, "nodes", c, + "power", "pass"]) + valuedriver = "LAN_2_0" + power = {"type": valuetype, "address": valueaddr, "user": valueuser, + "pass": valuepass, "driver": valuedriver} + + opnfvcfg["demo-maas"]["maas"]["nodes"].append( + {"name": namevalue, + "architecture": valuearc, + "interfaces": [], + "mac_addresses": [], + "power": power, + 'tags': noderoles}) + + y = 0 + while y < len(labcfg["lab"]["racks"][0]["nodes"][c]["nics"]): + valuespaces = labcfg["lab"]["racks"][0]["nodes"][c][ + "nics"][y]["spaces"] + valueifname = labcfg["lab"]["racks"][0]["nodes"][c][ + "nics"][y]["ifname"] + if "admin" not in valuespaces: + ifnamelist += [valueifname] + valueifmac = labcfg["lab"]["racks"][0]["nodes"][c]["nics"][y]["mac"][0] + valuemac += labcfg["lab"]["racks"][0]["nodes"][c]["nics"][y]["mac"] + opnfvcfg["demo-maas"]["maas"]["nodes"][c]["interfaces"].append( + {"name": valueifname, + "mac_address": valueifmac, + "mode": "auto"}) + y = y+1 + + if valueifmac: + opnfvcfg["demo-maas"]["maas"]["nodes"][c]['mac_addresses'] = valuemac + + c = c+1 + +opnfvlabcfg["opnfv"]["floating-ip-range"] =\ + labcfg["lab"]["racks"][0]["floating-ip-range"] +opnfvlabcfg["opnfv"]["ext-port"] =\ + labcfg["lab"]["racks"][0]["ext-port"] +opnfvlabcfg["opnfv"]["ceph-disk"] =\ + labcfg["opnfv"]["storage"][0]["disk"] +opnfvlabcfg["opnfv"]["interface-enable"] =\ + ",".join(list(set(ifnamelist))) + +# setup vip addresss for HA +opnfvlabcfg["opnfv"]["vip"]["rabbitmq"] =\ + opnfvlabcfg["opnfv"]["admNetwork"]+"0" +opnfvlabcfg["opnfv"]["vip"]["dashboard"] =\ + opnfvlabcfg["opnfv"]["admNetwork"]+"1" +opnfvlabcfg["opnfv"]["vip"]["glance"] = opnfvlabcfg["opnfv"]["admNetwork"]+"2" +opnfvlabcfg["opnfv"]["vip"]["keystone"] =\ + opnfvlabcfg["opnfv"]["admNetwork"]+"3" +opnfvlabcfg["opnfv"]["vip"]["ceilometer"] =\ + opnfvlabcfg["opnfv"]["admNetwork"]+"4" +opnfvlabcfg["opnfv"]["vip"]["mysql"] = opnfvlabcfg["opnfv"]["admNetwork"]+"5" +opnfvlabcfg["opnfv"]["vip"]["nova"] = opnfvlabcfg["opnfv"]["admNetwork"]+"6" +opnfvlabcfg["opnfv"]["vip"]["neutron"] = opnfvlabcfg["opnfv"]["admNetwork"]+"7" +opnfvlabcfg["opnfv"]["vip"]["heat"] = opnfvlabcfg["opnfv"]["admNetwork"]+"8" +opnfvlabcfg["opnfv"]["vip"]["cinder"] = opnfvlabcfg["opnfv"]["admNetwork"]+"9" + +osdomname = labcfg["lab"]["racks"][0]["osdomainname"] + +if osdomname: + opnfvlabcfg["opnfv"]["os-domain-name"] =\ + labcfg["lab"]["racks"][0]["osdomainname"] + opnfvlabcfg["opnfv"]["domain"] = labcfg["lab"]["racks"][0]["osdomainname"] + +opnfvlabcfg["opnfv"]["ext_port"] = labcfg["lab"]["racks"][0]["ext-port"] +opnfvlabcfg["opnfv"]["units"] = len(labcfg["lab"]["racks"][0]["nodes"]) +opnfvlabcfg["opnfv"]["admin_password"] = "openstack" +opnfvlabcfg["opnfv"]["storage"] = labcfg["opnfv"]["storage"] +opnfvlabcfg["opnfv"]["spaces"] = labcfg["opnfv"]["spaces"] + +with open('deployment.yaml', 'wa') as opnfvf: + yaml.dump(opnfvcfg, opnfvf, default_flow_style=False) + +with open('deployconfig.yaml', 'wa') as opnfvf: + yaml.dump(opnfvlabcfg, opnfvf, default_flow_style=False) -- cgit 1.2.3-korg