X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=ci%2F00-maasdeploy.sh;h=f87e2d3d8a30bf7bf406d30c5537ec2ac6c89f3d;hb=512a3b283ff25cad16a36605c80df4742673690b;hp=98ca47af5a71144488708fac917bdcd8bfb70bfe;hpb=669a243f81e11b1fb4e74ac58f8c6f426f1c7751;p=joid.git diff --git a/ci/00-maasdeploy.sh b/ci/00-maasdeploy.sh index 98ca47af..f87e2d3d 100755 --- a/ci/00-maasdeploy.sh +++ b/ci/00-maasdeploy.sh @@ -6,15 +6,21 @@ virtinstall=0 labname=$1 #install the packages needed +sudo apt-add-repository ppa:opnfv-team/proposed -y 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 pip install --upgrade pip 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 + python-congressclient gsutil charm-tools pastebinit -y + +sudo apt-get purge juju -y +wget https://launchpad.net/~juju/+archive/ubuntu/stable/+files/juju-core_1.25.5-0ubuntu1~14.04.2~juju1_amd64.deb +sudo dpkg -i juju-core_1.25.5-0ubuntu1~14.04.2~juju1_amd64.deb #first parameter should be custom and second should be either # absolute location of file (including file name) or url of the @@ -69,7 +75,7 @@ esac # In the case of a virtual deployment get deployment.yaml and deployconfig.yaml if [ "$virtinstall" -eq 1 ]; then labname="default" - ./cleanvm.sh + ./cleanvm.sh || true cp ../labconfig/default/deployment.yaml ./ cp ../labconfig/default/labconfig.yaml ./ cp ../labconfig/default/deployconfig.yaml ./ @@ -136,15 +142,12 @@ if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then sudo pip uninstall google-api-python-client fi -# Init Juju -juju init -f +#create backup directory +mkdir ~/joid_config/ || true +mkdir ~/.juju/ || true -# Backup deployment.yaml and deployconfig.yaml in .juju folder -cp ./deployment.yaml ~/.juju/ - -if [ -e ./deployconfig.yaml ]; then - cp ./deployconfig.yaml ~/.juju/ -fi +# Init Juju +juju init -f || true # # MAAS deploy @@ -156,6 +159,23 @@ sudo chown $USER:$USER environments.yaml echo "... Deployment of maas finish ...." +# Backup deployment.yaml and deployconfig.yaml in .juju folder + +cp ./environments.yaml ~/.juju/ +cp ./environments.yaml ~/joid_config/ + +if [ -e ./deployconfig.yaml ]; then + cp ./deployconfig.yaml ~/.juju/ + cp ./labconfig.yaml ~/.juju/ + cp ./deployconfig.yaml ~/joid_config/ + cp ./labconfig.yaml ~/joid_config/ +fi + +if [ -e ./deployment.yaml ]; then + cp ./deployment.yaml ~/.juju/ + cp ./deployment.yaml ~/joid_config/ +fi + # # MAAS Customization # @@ -166,17 +186,17 @@ 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`" +#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 virtual 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 node1-control --ram 8192 --cpu host --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 node2-compute --ram 8192 --cpu host --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 + sudo virt-install --connect qemu:///system --name node5-compute --ram 8192 --cpu host --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` @@ -221,7 +241,7 @@ 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` + nodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4` if [ ! -z "$nodes" ]; then maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3 fi @@ -248,6 +268,35 @@ crnodevlanint() { done } +#function for JUJU envronment + +addcredential() { + controllername=`awk 'NR==1{print $2}' environments.yaml` + cloudname=`awk 'NR==1{print $2}' environments.yaml` + + echo "credentials:" > credential.yaml + echo " $controllername:" >> credential.yaml + echo " opnfv-credentials:" >> credential.yaml + echo " auth-type: oauth1" >> credential.yaml + echo " maas-oauth: $apikey" >> credential.yaml + + juju add-credential $controllername -f credential.yaml --replace +} + +addcloud() { + controllername=`awk 'NR==1{print $2}' environments.yaml` + cloudname=`awk 'NR==1{print $2}' environments.yaml` + + echo "clouds:" > maas-cloud.yaml + echo " $cloudname:" >> maas-cloud.yaml + echo " type: maas" >> maas-cloud.yaml + echo " auth-types: [oauth1]" >> maas-cloud.yaml + echo " endpoint: http://$maas_ip/MAAS" >> maas-cloud.yaml + + juju add-cloud $cloudname maas-cloud.yaml --replace +} + + # # VLAN customization # @@ -255,14 +304,14 @@ crnodevlanint() { case "$labname" in 'intelpod9' ) maas refresh - crvlanupdsubnet vlan902 1 "DataNetwork" 902 2 || true - crvlanupdsubnet vlan905 2 "PublicNetwork" 905 3 || true - crnodevlanint $vlan902 eth0 || true + crvlanupdsubnet vlan904 fabric-1 "MgmtNetwork" 904 2 || true + crvlanupdsubnet vlan905 fabric-2 "PublicNetwork" 905 3 || 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 + crnodevlanint $vlan905 eth3 || true + enableautomodebyname eth1.905 AUTO "10.9.15.0/24" || true + enableautomodebyname eth3.905 AUTO "10.9.15.0/24" || true + enableautomodebyname eth0 AUTO "10.9.12.0/24" || true + enableautomodebyname eth2 AUTO "10.9.12.0/24" || true ;; esac @@ -271,9 +320,13 @@ 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 ~/.juju/deployconfig.yaml ]; then +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 +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/ //'` @@ -310,6 +363,15 @@ if [ -e ~/.juju/deployconfig.yaml ]; then fi fi + +# Add the cloud and controller credentials for MAAS for that lab. +jujuver=`juju --version` + +if [[ "$jujuver" > "2" ]]; then + addcloud + addcredential +fi + # # End of scripts #