summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarinder Gupta <narinder.gupta@canonical.com>2016-11-03 06:50:09 -0500
committerNarinder Gupta <narinder.gupta@canonical.com>2016-11-03 07:56:13 -0500
commite63f44eb68b9e87b9b99a135fe75f9f9e84b1103 (patch)
treee7ea6e3d0c89a961e1562e5fff5489a624758d18
parent769c8026c814a4746db2bd7ff1cd2937e74381bd (diff)
added support for maas 2.0 in non virtualized environment.
Change-Id: Icf024ed2cbf538df43e6bd5203685552ab6564d2 Signed-off-by: Narinder Gupta <narinder.gupta@canonical.com>
-rwxr-xr-xci/03-maasdeploy.sh46
-rwxr-xr-xci/cleanvm.sh10
-rw-r--r--ci/config_tpl/maas2/maas_tpl/deployment.yaml45
-rw-r--r--ci/config_tpl/maas2/maas_tpl/juju-bootstrap.yaml13
-rw-r--r--ci/config_tpl/maas2/maas_tpl/maas-network_config.yaml20
-rw-r--r--ci/config_tpl/maas2/maas_tpl/maas-node_group_ifaces.yaml23
-rw-r--r--ci/config_tpl/maas2/maas_tpl/maas-nodes.yaml28
-rw-r--r--ci/genMAASConfig.py10
8 files changed, 175 insertions, 20 deletions
diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh
index 7239c027..49391aad 100755
--- a/ci/03-maasdeploy.sh
+++ b/ci/03-maasdeploy.sh
@@ -2,6 +2,13 @@
#placeholder for deployment script.
set -ex
+maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
+
+if [[ "$maasver" > "2" ]]; then
+ #sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller -y
+ #sudo rm -rf /var/lib/maas
+fi
+
virtinstall=0
labname=$1
@@ -9,20 +16,6 @@ if [ ! -e $HOME/.ssh/id_rsa ]; then
ssh-keygen -N '' -f $HOME/.ssh/id_rsa
fi
-API_SERVER="http://192.168.122.1/MAAS/api/2.0"
-API_SERVERMAAS="http://192.168.122.1/MAAS/"
-PROFILE=ubuntu
-MY_UPSTREAM_DNS=192.168.122.1
-SSH_KEY=`cat ~/.ssh/id_rsa.pub`
-URL=https://images.maas.io/ephemeral-v2/daily/
-KEYRING_FILE=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg
-SOURCE_ID=1
-FABRIC_ID=1
-VLAN_TAG=""
-PRIMARY_RACK_CONTROLLER="192.168.122.1"
-SUBNET_CIDR="192.168.122.0/24"
-VLAN_TAG="untagged"
-
#install the packages needed
sudo apt-add-repository ppa:juju/stable -y
sudo apt-add-repository ppa:maas/stable -y
@@ -84,9 +77,30 @@ case "$labname" in
;;
esac
+MAAS_IP=$(grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //')
+MAAS_NAME=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
+API_SERVER="http://$MAAS_IP/MAAS/api/2.0"
+API_SERVERMAAS="http://$MAAS_IP/MAAS/"
+PROFILE=ubuntu
+MY_UPSTREAM_DNS=`grep "upstream_dns" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
+SSH_KEY=`cat ~/.ssh/id_rsa.pub`
+MAIN_ARCHIVE=`grep "main_archive" deployment.yaml | cut -d ':' -f 2-3 | sed -e 's/ //'`
+URL=https://images.maas.io/ephemeral-v2/daily/
+KEYRING_FILE=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg
+SOURCE_ID=1
+FABRIC_ID=1
+VLAN_TAG=""
+PRIMARY_RACK_CONTROLLER="$MAAS_IP"
+SUBNET_CIDR="192.168.122.0/24"
+VLAN_TAG="untagged"
+
# In the case of a virtual deployment get deployment.yaml and deployconfig.yaml
if [ "$virtinstall" -eq 1 ]; then
labname="default"
+ MAAS_IP="192.168.122.1"
+ API_SERVER="http://$MAAS_IP/MAAS/api/2.0"
+ API_SERVERMAAS="http://$MAAS_IP/MAAS/"
+ PRIMARY_RACK_CONTROLLER="$MAAS_IP"
./cleanvm.sh || true
cp ../labconfig/default/deployment.yaml ./
cp ../labconfig/default/labconfig.yaml ./
@@ -174,9 +188,9 @@ configuremaas(){
sudo maas createadmin --username=ubuntu --email=ubuntu@ubuntu.com --password=ubuntu
API_KEY=`sudo maas-region apikey --username=ubuntu`
maas login $PROFILE $API_SERVER $API_KEY
- maas $PROFILE maas set-config name='main_archive' value='http://us.archive.ubuntu.com/ubuntu'
+ maas $PROFILE maas set-config name='main_archive' value=$MAIN_ARCHIVE
maas $PROFILE maas set-config name=upstream_dns value=$MY_UPSTREAM_DNS
- maas $PROFILE maas set-config name='maas_name' value='automaas'
+ maas $PROFILE maas set-config name='maas_name' value=$MAAS_NAME
maas $PROFILE maas set-config name='ntp_server' value='ntp.ubuntu.com'
maas $PROFILE sshkeys create "key=$SSH_KEY"
maas $PROFILE boot-source update $SOURCE_ID \
diff --git a/ci/cleanvm.sh b/ci/cleanvm.sh
index 8259347c..f7f062a6 100755
--- a/ci/cleanvm.sh
+++ b/ci/cleanvm.sh
@@ -8,6 +8,8 @@ set -ex
echo " Cleanup Started ..."
./clean.sh || true
+maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
+
sudo virsh destroy node1-control || true
sudo virsh destroy node3-control || true
sudo virsh destroy node4-control || true
@@ -20,8 +22,10 @@ sudo virsh undefine node2-compute || true
sudo virsh undefine node5-compute || true
sudo rm -rf /var/lib/libvirt/images/node1-control.img /var/lib/libvirt/images/node2-compute.img /var/lib/libvirt/images/node3-control.img /var/lib/libvirt/images/node4-control.img /var/lib/libvirt/images/node5-compute.img || true
-#sudo virsh destroy bootstrap || true
-#sudo virsh undefine bootstrap || true
-#sudo rm -rf /var/lib/libvirt/images/bootstrap.img || true
+if [[ "$maasver" > "2" ]]; then
+ sudo virsh destroy bootstrap || true
+ sudo virsh undefine bootstrap || true
+ sudo rm -rf /var/lib/libvirt/images/bootstrap.img || true
+fi
echo " Cleanup Finished ..."
diff --git a/ci/config_tpl/maas2/maas_tpl/deployment.yaml b/ci/config_tpl/maas2/maas_tpl/deployment.yaml
new file mode 100644
index 00000000..b8e84cc5
--- /dev/null
+++ b/ci/config_tpl/maas2/maas_tpl/deployment.yaml
@@ -0,0 +1,45 @@
+opnfv-{{ lab.location }}{{ lab.racks[0].rack }}-maas:
+ juju-bootstrap:
+{% include 'juju-bootstrap.yaml' %}
+ maas:
+ apt_sources:
+ - ppa:maas/stable
+ - ppa:juju/stable
+ arch: amd64
+ boot_source:
+ keyring_filename: /usr/share/keyrings/ubuntu-cloudimage-keyring.gpg
+ selections:
+ '1':
+ arches: amd64
+ labels: release
+ os: ubuntu
+ release: xenial
+ subarches: '*'
+ url: http://maas.ubuntu.com/images/ephemeral-v2/releases/
+ disk_size: 160G
+ interfaces:
+{% for net in opnfv.spaces %}
+ - bridge={{ net.bridge }},model=virtio
+{% endfor %}
+ ip_address: {{ os.brAdmIP }}
+ memory: 4096
+ name: opnfv-{{ lab.location }}{{ lab.racks[0].rack }}
+ network_config: |
+{% include 'maas-network_config.yaml' %}
+ node_group_ifaces:
+{% include 'maas-node_group_ifaces.yaml' %}
+ nodes:
+{% include 'maas-nodes.yaml' %}
+ password: ubuntu
+ pool: default
+ release: trusty
+ settings:
+ maas_name: {{ lab.location }}{{ lab.racks[0].rack }}
+ main_archive: http://archive.ubuntu.com/ubuntu
+ upstream_dns: {{ lab.racks[0].dns }}
+ user: ubuntu
+ vcpus: 4
+ virsh:
+ rsa_priv_key: {{ os.home }}/.ssh/id_rsa
+ rsa_pub_key: {{ os.home }}/.ssh/id_rsa.pub
+ uri: qemu+ssh://{{ os.user }}@{{ os.brAdmIP }}/system
diff --git a/ci/config_tpl/maas2/maas_tpl/juju-bootstrap.yaml b/ci/config_tpl/maas2/maas_tpl/juju-bootstrap.yaml
new file mode 100644
index 00000000..533c62cc
--- /dev/null
+++ b/ci/config_tpl/maas2/maas_tpl/juju-bootstrap.yaml
@@ -0,0 +1,13 @@
+ arch: amd64
+ disk_size: 60G
+ interfaces:
+{% for net in ['admin','public','external'] %}
+{% if net in opnfv.spaces_dict %}
+ - bridge={{ opnfv.spaces_dict[net].bridge }},model=virtio
+{% endif %}
+{% endfor %}
+ memory: 4096
+ name: bootstrap
+ pool: default
+ vcpus: 4
+{# Empty block to avoid bad block trim #}
diff --git a/ci/config_tpl/maas2/maas_tpl/maas-network_config.yaml b/ci/config_tpl/maas2/maas_tpl/maas-network_config.yaml
new file mode 100644
index 00000000..6188a515
--- /dev/null
+++ b/ci/config_tpl/maas2/maas_tpl/maas-network_config.yaml
@@ -0,0 +1,20 @@
+ auto lo
+ iface lo inet loopback
+{% set ethid = 0 %}
+{% for net in opnfv.spaces %}
+
+ auto eth{{ ethid }}
+ iface eth{{ ethid }} inet static
+ netmask 255.255.255.0
+{% if net.type!='external' %}
+{% set net_prefix = net.cidr[:-4] %}
+ address {{ net_prefix }}5
+{% else %}
+ address {{ net.ipaddress }}
+{% endif %}
+{% if net.type=='admin' %}
+ gateway {{ net.gateway }}
+ dns-nameservers {{ lab.racks[0].dns }} {{ net_prefix }}5 127.0.0.1
+{% endif %}
+{% set ethid = ethid+1 %}
+{% endfor %}
diff --git a/ci/config_tpl/maas2/maas_tpl/maas-node_group_ifaces.yaml b/ci/config_tpl/maas2/maas_tpl/maas-node_group_ifaces.yaml
new file mode 100644
index 00000000..578c89fb
--- /dev/null
+++ b/ci/config_tpl/maas2/maas_tpl/maas-node_group_ifaces.yaml
@@ -0,0 +1,23 @@
+{% set ethid = 0 %}
+{% for net in opnfv.spaces %}
+{% if net.type!='external' %}
+{% set net_prefix = net.cidr[:-4] %}
+ - broadcast_ip: {{ net_prefix }}255
+ device: eth{{ ethid }}
+ dynamic_range:
+ high: {{ net_prefix }}250
+ low: {{ net_prefix }}81
+ ip: {{ net_prefix }}5
+{% if net.gateway!= None %}
+ router_ip: {{ net.gateway }}
+{% endif %}
+{% if net.type!='admin' %}
+ management: 1
+{% endif %}
+ static_range:
+ high: {{ net_prefix }}80
+ low: {{ net_prefix }}50
+ subnet_mask: 255.255.255.0
+{% set ethid = ethid+1 %}
+{% endif %}
+{% endfor %}
diff --git a/ci/config_tpl/maas2/maas_tpl/maas-nodes.yaml b/ci/config_tpl/maas2/maas_tpl/maas-nodes.yaml
new file mode 100644
index 00000000..e32dd7ca
--- /dev/null
+++ b/ci/config_tpl/maas2/maas_tpl/maas-nodes.yaml
@@ -0,0 +1,28 @@
+{% for node in lab.racks[0].nodes %}
+ - interfaces:
+{% for nic in node.nics %}
+ - mac_address: {{ nic.mac[0] }}
+ mode: auto
+ name: {{ nic.ifname }}
+{% endfor %}
+{% if node.architecture=='x86_64' %}
+ architecture: amd64/generic
+{% endif %}
+ mac_addresses:
+{% for nic in node.nics %}
+ - {{ nic.mac[0] }}
+{% endfor %}
+ name: {{ node.name }}
+ power:
+{% if node.power.type=='ipmi' %}
+ address: {{ node.power.address }}
+ driver: LAN_2_0
+ pass: {{ node.power.pass }}
+ type: ipmi
+ user: {{ node.power.user }}
+{% elif node.power.type=='wakeonlan' %}
+ type: ether_wake
+ mac_address: {{ node.power.mac_address }}
+{% endif %}
+ tags: {{ ' '.join(node.roles) }}
+{% endfor %}
diff --git a/ci/genMAASConfig.py b/ci/genMAASConfig.py
index 2b4948dc..c3bc92f0 100644
--- a/ci/genMAASConfig.py
+++ b/ci/genMAASConfig.py
@@ -10,7 +10,9 @@ Parameters:
from optparse import OptionParser
from jinja2 import Environment, FileSystemLoader
+from distutils.version import LooseVersion, StrictVersion
import os
+import subprocess
import yaml
from pprint import pprint as pp
import socket
@@ -31,7 +33,13 @@ labconfig_file = options.lab
#
# Capture our current directory
-TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas_tpl'
+jujuver = subprocess.check_output(["juju", "--version"])
+
+if LooseVersion(jujuver) >= LooseVersion('2'):
+ TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas_tpl'
+else:
+ TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas2/maas_tpl'
+
HOME = os.environ['HOME']
USER = os.environ['USER']