X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fjoid%2Fjoid-deploy.sh;h=e197dbd8c6eabdbfe549681556aee7265a3d50bc;hb=79b920c07b40d64e70f93f28a0822ad1488f32ee;hp=53255a3ffb528d6c44acaaddba09ba88c2e5296a;hpb=a8f12bed43703261d23bcd11d650ceffcf4fe5c3;p=releng.git diff --git a/jjb/joid/joid-deploy.sh b/jjb/joid/joid-deploy.sh index 53255a3ff..e197dbd8c 100644 --- a/jjb/joid/joid-deploy.sh +++ b/jjb/joid/joid-deploy.sh @@ -1,58 +1,67 @@ #!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2016 Orange and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## set +e set -o nounset -PWD_FILENAME="passwords.sh" - ## -## Create LAB_CONFIG folder if not exists +## Functions ## -mkdir -p $LAB_CONFIG +function exit_on_error { + RES=$1 + MSG=$2 + if [ $RES != 0 ]; then + echo "FAILED - $MSG" + exit $RES + fi +} ## -## Override default passwords with local settings if needed +## Create LAB_CONFIG folder if not exists ## -if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then - echo "------ Load local passwords ------" - source $LAB_CONFIG/$PWD_FILENAME -else - export MAAS_USER=ubuntu - export MAAS_PASSWORD=ubuntu - export OS_ADMIN_PASSWORD=openstack -fi +mkdir -p $LAB_CONFIG ## ## Set Joid pod config name ## - # This part will be removed when pod names will be synced between jenkins and joid config - case $NODE_NAME in - orange-fr-pod2) - POD=orange-pod2 ;; - *) - POD=$NODE_NAME ;; - esac - export POD_NAME=${POD/-} + +case $NODE_NAME in + *virtual*) + POD=default ;; + *) + POD=$NODE_NAME ;; +esac +export POD_NAME=${POD/-} ## ## Redeploy MAAS or recover the previous config ## cd $WORKSPACE/ci -if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then + +if [ -e "$LAB_CONFIG/deployconfig.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then echo "------ Recover Juju environment to use MAAS ------" - cp $LAB_CONFIG/environments.yaml . + if [ ! -e deployconfig.yaml ]; then + cp $LAB_CONFIG/deployconfig.yaml . + cp $LAB_CONFIG/deployment.yaml . + cp $LAB_CONFIG/labconfig.yaml . + fi else - MAASCONFIG=$WORKSPACE/ci/maas/${POD/-*}/${POD/*-}/deployment.yaml - echo "------ Set MAAS password ------" - sed -i -- "s/user: ubuntu/user: $MAAS_USER/" $MAASCONFIG - sed -i -- "s/password: ubuntu/password: $MAAS_PASSWORD/" $MAASCONFIG - echo "------ Redeploy MAAS ------" - ./02-maasdeploy.sh $POD_NAME - RES=$? - if [ $RES != 0 ]; then - echo "MAAS Deploy FAILED" - exit $RES + if ["$NODE_NAME" == "default" ]; then + echo "------ Redeploy MAAS ------" + ./03-maasdeploy.sh default + exit_on_error $? "MAAS Deploy FAILED" + else + echo "------ Redeploy MAAS ------" + ./03-maasdeploy.sh custom $LAB_CONFIG/labconfig.yaml + exit_on_error $? "MAAS Deploy FAILED" fi fi @@ -60,89 +69,95 @@ fi ## Configure Joid deployment ## -# Get juju deployer file -if [ "$HA_MODE" == 'nonha' ]; then - SRCBUNDLE=$WORKSPACE/ci/$SDN_CONTROLLER/juju-deployer/ovs-$SDN_CONTROLLER.yaml -else - SRCBUNDLE=$WORKSPACE/ci/$SDN_CONTROLLER/juju-deployer/ovs-$SDN_CONTROLLER-$HA_MODE.yaml +# Based on scenario naming we can get joid options +# naming convention: +# ---[-] +# With parameters: +# model=(os|k8) +# controller=(nosdn|odl_l3|odl_l2|onos|ocl) +# No odl_l3 today +# nfvfeature=(kvm|ovs|dpdk|nofeature) +# '_' list separated. +# mode=(ha|noha) +# extrastuff=(none) +# Optional field - Not used today + +IFS='-' read -r -a DEPLOY_OPTIONS <<< "${DEPLOY_SCENARIO}--" +#last -- need to avoid nounset error + +JOID_MODEL=${DEPLOY_OPTIONS[0]} +SDN_CONTROLLER=${DEPLOY_OPTIONS[1]} +NFV_FEATURES=${DEPLOY_OPTIONS[2]} +HA_MODE=${DEPLOY_OPTIONS[3]} +EXTRA=${DEPLOY_OPTIONS[4]} + +if [ "$SDN_CONTROLLER" == 'odl_l2' ] || [ "$SDN_CONTROLLER" == 'odl_l3' ]; then + SDN_CONTROLLER='odl' +fi +if [ "$HA_MODE" == 'noha' ]; then + HA_MODE='nonha' fi -# Modify files - -echo "------ Set openstack password ------" -sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE +# Add extra to features +if [ "$EXTRA" != "" ];then + NFV_FEATURES="${NFV_FEATURES}_${EXTRA}" +fi -echo "------ Set ceph disks ------" -if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then - CEPH_DISKS_CONTROLLERS=$CEPH_DISKS +# temporary sfc feature is availble only on onos and trusty +if [ "$NFV_FEATURES" == 'sfc' ] && [ "$SDN_CONTROLLER" == 'onos' ];then + UBUNTU_DISTRO=trusty fi -#Find the first line of osd-devices to change the one for ceph, then the other for ceph-osd -CEPH_DEV_LINE=$(grep -nr osd-devices $SRCBUNDLE |head -n1|cut -d: -f1) -sed -i -- "${CEPH_DEV_LINE}s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE -sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS_CONTROLLERS@" $SRCBUNDLE -sed -i -r -- "s/^(\s+osd-reformat: )'no'/\1'$CEPH_REFORMAT'/" $SRCBUNDLE ## ## Configure Joid deployment ## -echo "------ Deploy with juju ------" -echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME" +if [ "$JOID_MODEL" == 'k8' ]; then + echo "------ Deploy with juju ------" + echo "Execute: ./deploy.sh -m $JOID_MODEL -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES" -./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -RES=$? -if [ $RES != 0 ]; then - echo "Deploy FAILED" - exit $RES + ./deploy.sh -m kubernetes -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES + exit_on_error $? "Main deploy FAILED" fi ## ## Set Admin RC ## -JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc -echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------" -KEYSTONE=$(cat bundles.yaml |shyaml get-value openstack-phase2.services.keystone.options.vip) - -# export the openrc file -cat << EOF > $JOID_ADMIN_OPENRC -export OS_USERNAME=admin -export OS_PASSWORD=$OS_ADMIN_PASSWORD -export OS_TENANT_NAME=admin -export OS_AUTH_URL=http://$KEYSTONE:5000/v2.0 -export OS_REGION_NAME=Canonical -EOF - -## -## Backup local juju env -## - -echo "------ Backup Juju environment ------" -cp environments.yaml $LAB_CONFIG/ - -## -## Basic test to return a realistic result to jenkins -## - -echo "------ Do basic test ------" -source $JOID_ADMIN_OPENRC -curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d " -{ \"auth\": { - \"identity\": { - \"methods\": [\"password\"], - \"password\": { - \"user\": { - \"name\": \"admin\", - \"domain\": { \"id\": \"default\" }, - \"password\": \"$OS_ADMIN_PASSWORD\" - } - } - } - } -}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null; -RES=$? -if [ $RES == 0 ]; then - echo "Deploy SUCCESS" -else - echo "Deploy FAILED to auth to openstack" +if [ "$JOID_MODEL" == 'os' ]; then + echo "------ Deploy with juju ------" + echo "Execute: ./deploy.sh -m $JOID_MODEL -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES" + + ./deploy.sh -m openstack -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME -d $UBUNTU_DISTRO -f $NFV_FEATURES + exit_on_error $? "Main deploy FAILED" + + JOID_ADMIN_OPENRC=$LAB_CONFIG/admin-openrc + echo "------ Create OpenRC file [$JOID_ADMIN_OPENRC] ------" + + # get controller IP + case "$SDN_CONTROLLER" in + "odl") + SDN_CONTROLLER_IP=$(juju status odl-controller/0 |grep public-address|sed -- 's/.*\: //') + ;; + "onos") + SDN_CONTROLLER_IP=$(juju status onos-controller/0 |grep public-address|sed -- 's/.*\: //') + ;; + *) + SDN_CONTROLLER_IP='none' + ;; + esac + SDN_PASSWORD='admin' + + # export the openrc file by getting the one generated by joid and add SDN + # controller for Functest + # cp ./cloud/admin-openrc $JOID_ADMIN_OPENRC + echo export SDN_CONTROLLER=$SDN_CONTROLLER_IP >> $JOID_ADMIN_OPENRC + echo export SDN_PASSWORD=$SDN_PASSWORD >> $JOID_ADMIN_OPENRC + fi -exit $RES + +## +## Exit success +## + +echo "Deploy success" +exit 0