#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
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
;;
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 ./
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 \
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
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 ..."
--- /dev/null
+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
--- /dev/null
+ 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 #}
--- /dev/null
+ 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 %}
--- /dev/null
+{% 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 %}
--- /dev/null
+{% 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 %}
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
#
# 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']