Adding the maas deployment script. This will deploy the maas in a 03/1903/1
authorNarinder Gupta <narinder.gupta@canoncial.com>
Wed, 23 Sep 2015 04:14:00 +0000 (23:14 -0500)
committerNarinder Gupta <narinder.gupta@canoncial.com>
Wed, 23 Sep 2015 04:16:09 +0000 (23:16 -0500)
VM. Also add a bootdtrap node. deploy.yaml will contain the config
file to deploy the openstack release.

deployment.yaml will be lab specific where it will install the
maas in a particular lab.

Change-Id: I9d19e06eeac55666fc38a8db22fe8ba0bda7a764

ci/02-maasdeploy.sh [new file with mode: 0755]
ci/deploy.py [new file with mode: 0755]
ci/deploy.sh
ci/deploy.yaml [new file with mode: 0755]
ci/intel/pod5/maas/deployment.yaml

diff --git a/ci/02-maasdeploy.sh b/ci/02-maasdeploy.sh
new file mode 100755 (executable)
index 0000000..d56cd9f
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+#placeholder for deployment script.
+set -ex
+
+case "$1" in
+    'intelpod5' )
+        cp intel/pod5/maas/deployment.yaml ./deployment.yaml
+        ;;
+    * )
+        cp intel/pod5/maas/deployment.yaml ./deployment.yaml
+        ;;
+esac
+
+echo "... Deployment of maas Started ...."
+sudo apt-add-repository ppa:maas-deployers/stable -y
+sudo apt-get update -y
+sudo apt-get install maas-deployer -y
+if [ ! -e /home/ubuntu/.ssh/id_rsa ]; then
+    ssh-keygen -N '' -f /home/ubuntu/.ssh/id_rsa
+fi
+sudo adduser ubuntu libvirtd
+cat /home/ubuntu/.ssh/id_rsa.pub > /home/ubuntu/.ssh/authorized_keys
+maas-deployer -c deployment.yaml -d --force
+echo "... Deployment of maas finish ...."
+
+maas_ip=`grep " ip_address" deployment.yaml | cut -d ":"  -f 2`
+
+#echo "... Deployment of opnfv release Started ...."
+python deploy.py $maas_ip
+#echo "... Deployment of opnfv release finished ...."
+
diff --git a/ci/deploy.py b/ci/deploy.py
new file mode 100755 (executable)
index 0000000..078a3df
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+"""
+MAAS Deployment Tool
+"""
+import copy
+import itertools
+import json
+import logging
+import os
+import sys
+import time
+import yaml
+
+from maas_deployer.vmaas.util import CONF as cfg
+
+from maas_deployer.vmaas import (
+    vm,
+    util,
+    template,
+)
+
+
+# Setup logging before imports
+logging.basicConfig(
+    filename='maas_deployer.log',
+    level=logging.DEBUG,
+    format=('%(asctime)s %(levelname)s '
+            '(%(funcName)s) %(message)s'))
+
+log = logging.getLogger('vmaas.main')
+handler = logging.StreamHandler()
+formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
+handler.setFormatter(formatter)
+log.addHandler(handler)
+
+def main():
+
+    maasipaddress = str(sys.argv); 
+
+    script = """
+        sudo apt-get install git -y 
+        git clone https://gerrit.opnfv.org/gerrit/joid
+        juju init -y
+        cp /home/juju/.juju/environments.yaml ~/.juju/
+        cd joid/ci/
+        ./deploy.sh 
+        """ 
+    try:
+        util.exec_script_remote('ubuntu', maasipaddress[1], script)
+    except:
+        # Remove console handler to avoid displaying the exception twice
+        log.removeHandler(handler)
+        log.exception("MAAS deployment failed.")
+        raise
+
+if __name__ == '__main__':
+    main()
index 7f39a93..f33ad4b 100755 (executable)
@@ -1,7 +1,6 @@
 #!/bin/bash
 
 set -ex
-./00-bootstrap.sh
 
 #need to put mutiple cases here where decide this bundle to deploy by default use the odl bundle.
 # Below parameters are the default and we can according the release
@@ -10,13 +9,23 @@ opnfvsdn=odl
 opnfvtype=nonha
 openstack=kilo
 opnfvlab=intelpod5
+opnfvrel=b
+
+read_config() {
+    opnfvrel=`grep release: deploy.yaml | cut -d ":" -f2`
+    openstack=`grep openstack: deploy.yaml | cut -d ":" -f2`
+    opnfvtype=`grep type: deploy.yaml | cut -d ":" -f2`
+    opnfvlab=`grep lab: deploy.yaml | cut -d ":" -f2`
+    opnfvsdn=`grep sdn: deploy.yaml | cut -d ":" -f2`
+}
 
 usage() { echo "Usage: $0 [-s <odl|opencontrail>]
                          [-t <nonha|ha|tip>] 
                          [-o <juno|kilo|liberty>]
-                         [-l <intelpod5>]" 1>&2 exit 1;}
+                         [-l <intelpod5>]
+                         [-r <a|b>]" 1>&2 exit 1; } 
 
-while getopts ":s:t:o:l:h:" opt; do
+while getopts ":s:t:o:l:h:r:" opt; do
     case "${opt}" in
         s)
             opnfvsdn=${OPTARG}
@@ -30,6 +39,9 @@ while getopts ":s:t:o:l:h:" opt; do
         l)
             opnfvlab=${OPTARG}
             ;;
+        r)
+            opnfvrel=${OPTARG}
+            ;;
         h)
             usage
             ;;
@@ -38,9 +50,21 @@ while getopts ":s:t:o:l:h:" opt; do
     esac
 done
 
-#copy the script which needs to get deployed as part of ofnfv release
-cp ./$opnfvsdn/01-deploybundle.sh ./01-deploybundle.sh
+deploy() {
+    #copy the script which needs to get deployed as part of ofnfv release
+    echo "deploying now"
+    cp ./$opnfvsdn/01-deploybundle.sh ./01-deploybundle.sh
+    ./00-bootstrap.sh
+
+    #case default:
+    ./01-deploybundle.sh $opnfvtype $openstack $opnfvlab
+}
 
-#case default:
-./01-deploybundle.sh $opnfvtype $openstack $opnfvlab
+if [ "$#" -eq 0 ]; then
+  echo "This installtion will use deploy.yaml" 
+  read_config
+fi
 
+echo "deploying started"
+deploy
+echo "deploying finished"
diff --git a/ci/deploy.yaml b/ci/deploy.yaml
new file mode 100755 (executable)
index 0000000..031c86f
--- /dev/null
@@ -0,0 +1,13 @@
+# This file defines the deployment for the MAAS environment which is to be
+# deployed and automated.
+opnfv:
+    # Defines the openstack release needs to be get installed.
+    release:A
+    # Defines the openstack release needs to be get installed.
+    openstack:kilo
+    # Defines the sdn plugin to be get installed.
+    sdn:odl
+    # Defines the ha type to be get installed.
+    type:nonha
+    # Defines the lab where release to be get installed.
+    lab:intellab5
index 79eaba0..d89a24f 100755 (executable)
@@ -176,6 +176,15 @@ demo-maas:
 #                  mac_address: "38:63:bb:43:b8:9c"
 #                  requested_address: 192.168.122.5
 
+#            - name: jenkins-slave
+#              tags: jenkins-slave
+#              architecture: amd64/generic
+#              mac_addresses:
+#                  - "52:54:00:f0:5c:53"
+#              power:
+#                  type: virsh
+#                  address: qemu+ssh://ubuntu@10.4.1.1/system
+
     # Contains the virtual machine parameters for creating the Juju bootstrap
     # node virtual machine
     juju-bootstrap: