diff options
Diffstat (limited to 'jjb/joid')
-rw-r--r-- | jjb/joid/joid-ci-jobs.yml | 175 | ||||
-rw-r--r-- | jjb/joid/joid-deploy.sh | 130 |
2 files changed, 132 insertions, 173 deletions
diff --git a/jjb/joid/joid-ci-jobs.yml b/jjb/joid/joid-ci-jobs.yml index 80e21f50e..e3b010028 100644 --- a/jjb/joid/joid-ci-jobs.yml +++ b/jjb/joid/joid-ci-jobs.yml @@ -43,8 +43,8 @@ # commented out below controllers to get Arno scenario settled first # - 'nosdn': # disabled: true -# - 'onos': -# disabled: true + - 'onos': + disabled: true # - 'opencontrail': # disabled: true @@ -74,8 +74,8 @@ parameters: - project-parameter: project: '{project}' - - '{pod}-defaults' - '{installer}-defaults' + - '{pod}-defaults' - string: name: SDN_CONTROLLER default: '{sdn-controller}' @@ -90,9 +90,28 @@ branch: '{branch}' builders: - - '{installer}-multijob-{pod}-builder': - pod: '{pod}' - stream: '{stream}' + - multijob: + name: deploy + condition: SUCCESSFUL + projects: + - name: 'joid-deploy-{pod}-daily-{stream}' + current-parameters: true + git-revision: true + kill-phase-on: FAILURE + - multijob: + name: functest + condition: COMPLETED + projects: + - name: 'functest-joid-{pod}-daily-{stream}' + current-parameters: true + kill-phase-on: NEVER + - multijob: + name: yardstick + condition: COMPLETED + projects: + - name: 'yardstick-joid-{pod}-daily-{stream}' + current-parameters: true + kill-phase-on: NEVER - job-template: name: 'joid-deploy-{pod}-daily-{stream}' @@ -111,8 +130,8 @@ parameters: - project-parameter: project: '{project}' - - '{pod}-defaults' - '{installer}-defaults' + - '{pod}-defaults' scm: - git-scm: @@ -121,144 +140,24 @@ branch: '{branch}' builders: - - '{pod}-builder' + - 'builder-macro' ######################## -# multijob builder macros -######################## -# intel-pod5 is CI POD so full CI will run on it -# deploy, functest, yardstick -- builder: - name: joid-multijob-intel-pod5-builder - builders: - - multijob: - name: deploy - condition: SUCCESSFUL - projects: - - name: 'joid-deploy-{pod}-daily-{stream}' - current-parameters: true - git-revision: true - kill-phase-on: FAILURE - - multijob: - name: functest - condition: COMPLETED - projects: - - name: 'functest-joid-{pod}-daily-{stream}' - current-parameters: true - kill-phase-on: NEVER - - multijob: - name: yardstick - condition: COMPLETED - projects: - - name: 'yardstick-joid-{pod}-daily-{stream}' - current-parameters: true - kill-phase-on: NEVER -# intel-pod6 is CI POD so full CI will run on it -# deploy, functest, yardstick -- builder: - name: joid-multijob-intel-pod6-builder - builders: - - multijob: - name: deploy - condition: SUCCESSFUL - projects: - - name: 'joid-deploy-{pod}-daily-{stream}' - current-parameters: true - git-revision: true - kill-phase-on: FAILURE - - multijob: - name: functest - condition: COMPLETED - projects: - - name: 'functest-joid-{pod}-daily-{stream}' - current-parameters: true - kill-phase-on: NEVER - - multijob: - name: yardstick - condition: COMPLETED - projects: - - name: 'yardstick-joid-{pod}-daily-{stream}' - current-parameters: true - kill-phase-on: NEVER -# yardstick placeholder -# - multijob: -# name: yardstick -# condition: COMPLETED -# projects: -# - name: 'yardstick-joid-{pod}-daily-{stream}' -# current-parameters: true -# kill-phase-on: NEVER - -# orange-pod2 is NOT a CI POD so only the selected jobs will run -# deploy and functest currently -- builder: - name: joid-multijob-orange-pod2-builder - builders: - - multijob: - name: deploy - condition: SUCCESSFUL - projects: - - name: 'joid-deploy-{pod}-daily-{stream}' - current-parameters: true - git-revision: true - kill-phase-on: FAILURE - - multijob: - name: functest - condition: COMPLETED - projects: - - name: 'functest-joid-{pod}-daily-{stream}' - current-parameters: true - kill-phase-on: NEVER -######################## # builder macros ######################## - builder: - name: intel-pod5-builder + name: 'builder-macro' builders: - shell: | #!/bin/bash echo "Running $INSTALLER_TYPE with controller $SDN_CONTROLLER" echo - echo "Executing clean.sh" - cd $WORKSPACE/ci - ./clean.sh - echo - echo "Executing 02-maasdeploy.sh intelpod5" - ./02-maasdeploy.sh intelpod5 - echo - echo "Executing deploy.sh -o liberty -s $SDN_CONTROLLER -t ha -l intelpod5" - ./deploy.sh -o liberty -s $SDN_CONTROLLER -t ha -l intelpod5 - -- builder: - name: intel-pod6-builder - builders: - - shell: | - #!/bin/bash - echo "Running $INSTALLER_TYPE with controller $SDN_CONTROLLER" - echo - echo "Executing clean.sh" - cd $WORKSPACE/ci - ./clean.sh - echo - echo "Executing 02-maasdeploy.sh intelpod6" - ./02-maasdeploy.sh intelpod6 - echo - echo "Executing deploy.sh -o liberty -s $SDN_CONTROLLER -t ha -l intelpod6" - ./deploy.sh -o liberty -s $SDN_CONTROLLER -t ha -l intelpod6 - -- builder: - name: orange-pod2-builder - builders: - - shell: | - #!/bin/bash - echo "Running $INSTALLER_TYPE with controller $SDN_CONTROLLER" - echo "Please note that this is WIP generic builder" - echo - echo "Executing clean.sh" + echo "------ First Executing clean.sh ------" cd $WORKSPACE/ci ./clean.sh - shell: - !include-raw ./joid-deploy.sh + !include-raw: ./joid-deploy.sh + ######################## # trigger macros ######################## @@ -274,3 +173,15 @@ name: 'joid-orange-pod2-odl-trigger' triggers: - timed: '' +- trigger: + name: 'joid-intel-pod5-onos-trigger' + triggers: + - timed: '' +- trigger: + name: 'joid-intel-pod6-onos-trigger' + triggers: + - timed: '' +- trigger: + name: 'joid-orange-pod2-onos-trigger' + triggers: + - timed: '' diff --git a/jjb/joid/joid-deploy.sh b/jjb/joid/joid-deploy.sh index c7e5ba8fd..e23afac1c 100644 --- a/jjb/joid/joid-deploy.sh +++ b/jjb/joid/joid-deploy.sh @@ -2,51 +2,67 @@ set +e set -o nounset -JOID_LOCAL_CONFIG_FOLDER=$HOME/joid_config -JOID_ADMIN_OPENRC=$JOID_LOCAL_CONFIG_FOLDER/admin-openrc +PWD_FILENAME="passwords.sh" ## -## Load local config or defaults ## +## +function exit_on_error { + RES=$1 + MSG=$2 + if [ $RES != 0 ]; then + echo "FAILED - $MSG" + exit $RES + fi +} + + +## +## Create LAB_CONFIG folder if not exists +## +mkdir -p $LAB_CONFIG -if [ -e "$JOID_LOCAL_CONFIG_FOLDER/config.sh" ]; then - echo "------ Load local config ------" - source $JOID_LOCAL_CONFIG_FOLDER/config.sh +## +## Override default passwords with local settings if needed +## + +if [ -e "$LAB_CONFIG/$PWD_FILENAME" ]; then + echo "------ Load local passwords ------" + source $LAB_CONFIG/$PWD_FILENAME else - echo "------ No local config, load default ------" - # link NODE_NAME to joid node config names + export MAAS_USER=ubuntu + export MAAS_PASSWORD=ubuntu + export OS_ADMIN_PASSWORD=openstack +fi + +## +## 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_DC=$(echo $POD |cut -d\- -f1) - export POD_NUM=$(echo $POD |cut -d\- -f2) - export POD_NAME=$POD_DC$POD_NUM - export MAAS_REINSTALL=true - export MAAS_USER=ubuntu - export MAAS_PASSWORD=ubuntu - export OS_ADMIN_PASSWORD=openstack - export CEPH_DISKS=/srv - export CEPH_REFORMAT=no -fi + export POD_NAME=${POD/-} ## ## Redeploy MAAS or recover the previous config ## cd $WORKSPACE/ci -if [ -e "$JOID_LOCAL_CONFIG_FOLDER/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then +if [ -e "$LAB_CONFIG/environments.yaml" ] && [ "$MAAS_REINSTALL" == "false" ]; then echo "------ Recover Juju environment to use MAAS ------" - cp $JOID_LOCAL_CONFIG_FOLDER/environments.yaml . + cp $LAB_CONFIG/environments.yaml . else - MAASCONFIG=$WORKSPACE/ci/maas/$POD_DC/$POD_NUM/deployment.yaml + 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 + exit_on_error $? "MAAS Deploy FAILED" fi ## @@ -66,7 +82,15 @@ echo "------ Set openstack password ------" sed -i -- "s/\"admin-password\": openstack/\"admin-password\": $OS_ADMIN_PASSWORD/" $SRCBUNDLE echo "------ Set ceph disks ------" -sed -i -- "s@osd-devices: /srv@osd-devices: $CEPH_DISKS@" $SRCBUNDLE +CEPH_DISKS_CONTROLLERS=${CEPH_DISKS_CONTROLLERS:-} +if [ -z "$CEPH_DISKS_CONTROLLERS" ]; then + CEPH_DISKS_CONTROLLERS=$CEPH_DISKS +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 ## @@ -77,20 +101,15 @@ echo "------ Deploy with juju ------" echo "Execute: ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME" ./deploy.sh -t $HA_MODE -o $OS_RELEASE -s $SDN_CONTROLLER -l $POD_NAME +exit_on_error $? "Main deploy FAILED" ## ## 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) -# create the folder if needed -JOID_ADMIN_OPENRC_FOLDER=$(echo $JOID_ADMIN_OPENRC | perl -pe "s|^(.*/).*?$|\1|") -if [ ! -d "$JOID_ADMIN_OPENRC_FOLDER" ]; then - mkdir -p $JOID_ADMIN_OPENRC_FOLDER -fi - # export the openrc file cat << EOF > $JOID_ADMIN_OPENRC export OS_USERNAME=admin @@ -104,14 +123,14 @@ EOF ## Backup local juju env ## -if [ -d "$JOID_LOCAL_CONFIG_FOLDER" ]; then - echo "------ Backup Juju environment ------" - cp environments.yaml $JOID_LOCAL_CONFIG_FOLDER/ -fi +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\": { @@ -119,18 +138,47 @@ curl -i -sw '%{http_code}' -H "Content-Type: application/json" -d " \"methods\": [\"password\"], \"password\": { \"user\": { - \"name\": \"$OS_TENANT_NAME\", + \"name\": \"admin\", \"domain\": { \"id\": \"default\" }, - \"password\": \"$OS_PASSWORD\" + \"password\": \"$OS_ADMIN_PASSWORD\" } } } } -}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null; echo $?; -RES=$? -if [ $RES == 0 ]; then - echo "Deploy SUCCESS" +}" http://$KEYSTONE:5000/v3/auth/tokens |grep "HTTP/1.1 20" 2>&1 >/dev/null; +exit_on_error $? "Deploy FAILED to auth to openstack" + + +## +## Create external network if needed +## + +EXTERNAL_NETWORK=${EXTERNAL_NETWORK:-} +# split EXTERNAL_NETWORK=name;type;first ip;last ip; gateway;network +IFS=';' read -r -a EXTNET <<< "$EXTERNAL_NETWORK" +EXTNET_NAME=${EXTNET[0]} +EXTNET_TYPE=${EXTNET[1]} +EXTNET_FIP=${EXTNET[2]} +EXTNET_LIP=${EXTNET[3]} +EXTNET_GW=${EXTNET[4]} +EXTNET_NET=${EXTNET[5]} +# If we have more information than only the name, try to create it +if [ -z "$EXTNET_TYPE" ]; then + echo "------ No data for external network creation, pass ------" else - echo "Deploy FAILED" + echo "------ External network creation ------" + neutron net-create $EXTNET_NAME --router:external True \ + --provider:physical_network external --provider:network_type $EXTNET_TYPE + exit_on_error $? "External network creation failed" + neutron subnet-create $EXTNET_NAME --name $EXTNET_NAME \ + --allocation-pool start=$EXTNET_FIP,end=$EXTNET_LIP \ + --disable-dhcp --gateway $EXTNET_GW $EXTNET_NET + exit_on_error $? "External subnet creation failed" fi -exit $RES + +## +## Exit success +## + +echo "Deploy success" +exit 0 |