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-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
+ python-congressclient gsutil charm-tools pastebinit -y
#first parameter should be custom and second should be either
# absolute location of file (including file name) or url of the
# 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 ./
sudo pip uninstall google-api-python-client
fi
+#create backup directory
+mkdir ~/joid_config/ || true
+mkdir ~/.juju/ || true
+
# Init Juju
-juju init -f
+juju init -f || true
#
# MAAS deploy
# 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
#
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
#
#
#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
enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
fi
fi
+
+# Add the cloud and controller credentials for MAAS for that lab.
+jujuver=`juju --version`
+
+if [ "$jujuver" -ge "2" ]; then
+ addcloud
+ addcredential
+fi
+
#
# End of scripts
#