diff options
-rwxr-xr-x | ci/01-deploybundle.sh | 14 | ||||
-rwxr-xr-x | ci/02-maasdeploy.sh | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | ci/deploy.py | 112 | ||||
-rwxr-xr-x | ci/deploy.sh | 5 |
4 files changed, 70 insertions, 63 deletions
diff --git a/ci/01-deploybundle.sh b/ci/01-deploybundle.sh index 71f2362a..96be450e 100755 --- a/ci/01-deploybundle.sh +++ b/ci/01-deploybundle.sh @@ -107,10 +107,10 @@ case "$1" in ;; esac -case "$4" in - 'onos' ) - echo "... onos prepare test ..." - sleep 180s - sh onos/juju_test_prepare.sh "$3" - ;; -esac +#case "$4" in +# 'onos' ) +# echo "... onos prepare test ..." +# sleep 180s +# sh onos/juju_test_prepare.sh "$3" +# ;; +#esac diff --git a/ci/02-maasdeploy.sh b/ci/02-maasdeploy.sh index 5989feef..5f49daf1 100755 --- a/ci/02-maasdeploy.sh +++ b/ci/02-maasdeploy.sh @@ -74,7 +74,7 @@ sudo apt-add-repository ppa:maas/stable -y sudo apt-add-repository cloud-archive:liberty -y sudo apt-get update -y sudo apt-get dist-upgrade -y -sudo apt-get install openssh-server git maas-deployer juju juju-deployer maas-cli python-pip python-openstackclient -y +sudo apt-get install openssh-server git maas-deployer juju juju-deployer maas-cli python-pip python-openstackclient gsutil -y sudo pip install shyaml juju init -f diff --git a/ci/deploy.py b/ci/deploy.py index 078a3df6..d52bd609 100755..100644 --- a/ci/deploy.py +++ b/ci/deploy.py @@ -1,57 +1,59 @@ -#!/usr/bin/env python -""" -MAAS Deployment Tool -""" -import copy -import itertools -import json -import logging -import os -import sys -import time import yaml +import pprint + +with open('example.yaml', 'r') as f: + doc = yaml.load(f) +txt = doc["nodes"][0]["power"] + +with open('deployment.yaml', 'r') as ft: + doc1 = yaml.load(ft) + +def setInDict(dataDict, mapList, value): + getFromDict(dataDict, mapList[:-1])[mapList[-1]] = value + +def getFromDict(dataDict, mapList): + return reduce(lambda d, k: d[k], mapList, dataDict) + +if len(doc["nodes"]) > len(doc1["demo-maas"]["maas"]["nodes"]): + exit 0 + +c=0 +while c < len(doc["nodes"]): + + value = getFromDict(doc, ["nodes",c, "name"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "name"], value) + + value = getFromDict(doc, ["nodes",c, "tags"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "tags"], value) + + value = getFromDict(doc, ["nodes",c, "arch"]) + if value == "x86_64": + value="amd64/generic" + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "architecture"], value) + + value = getFromDict(doc, ["nodes",c, "mac_address"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "mac_addresses"], value) + + value = getFromDict(doc, ["nodes",c, "power", "type"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "power", "type"], value) + + if value == "wakeonlan": + value = getFromDict(doc, ["nodes",c, "power", "mac_address"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "power", "mac_address"], value) + + if value == "ipmi": + value = getFromDict(doc, ["nodes",c, "power", "address"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "power", "address"], value) + + value = getFromDict(doc, ["nodes",c, "power", "user"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "power", "user"], value) + + value = getFromDict(doc, ["nodes",c, "power", "pass"]) + setInDict(doc1, ["demo-maas", "maas", "nodes", c, "power", "pass"], value) + + c=c+1 + +with open('deployment.yaml', 'w') as ft: + yaml.dump(doc1, ft) + -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() diff --git a/ci/deploy.sh b/ci/deploy.sh index 6005eb1d..f9aadaa9 100755 --- a/ci/deploy.sh +++ b/ci/deploy.sh @@ -163,6 +163,11 @@ unitAddress() createopenrc() { + if [ "$opnfvsdn" == "onos" ]; then + sh onos/juju_test_prepare.sh "$opnfvlab" + check_status + fi + mkdir -m 0700 -p cloud controller_address=$(unitAddress keystone 0) |