From ee04b4563003e33e11163adbbaa39e5c7091d82f Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Mon, 19 Sep 2016 18:07:40 +0200 Subject: [PATCH] Changes in container funcs to allow options when creating containers, in templates to allow nested containers. Changes in RO scripts to install packages and dependencies before building Change-Id: Ie3a631387268f5a94dec3414ff103700ae743f4b Signed-off-by: garciadeblas --- jenkins/RO/SETTINGS | 6 +++++- jenkins/RO/start_build | 10 +++++++++- jenkins/common/container | 22 +++++++++------------- jenkins/host/start_build | 11 ++++++----- jenkins/template/SETTINGS | 13 +++++++++++-- 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/jenkins/RO/SETTINGS b/jenkins/RO/SETTINGS index 691ab733..8c37f162 100644 --- a/jenkins/RO/SETTINGS +++ b/jenkins/RO/SETTINGS @@ -1,4 +1,6 @@ # +# Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -11,9 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# Authors: +# - Gerardo Garcia - gerardo.garciadeblas@telefonica.com # # this variable holds the name of the container image needed to build or run this product -export OSM_BASE_IMAGE=ubuntu:14.04 +export OSM_BASE_IMAGE=ubuntu:16.04 # # this variable holds the name of the container to be used to build a package # if this container already exists, the build process can skip the container build diff --git a/jenkins/RO/start_build b/jenkins/RO/start_build index 7ae8d240..ddc29ef1 100755 --- a/jenkins/RO/start_build +++ b/jenkins/RO/start_build @@ -1,5 +1,7 @@ #!/bin/bash # +# Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U. +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -12,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# Authors: +# - Gerardo Garcia - gerardo.garciadeblas@telefonica.com # HERE=$(realpath $(dirname $0)) @@ -47,10 +51,14 @@ fi INFO "starting build" +INFO " cleaning .pyc" rm *.pyc +INFO " installing openmano packages and dependencies from current repo (--noclone)" +./scripts/install_openmano.sh --noclone -q +INFO " compiling *.py" python -m py_compile *.py RC=$? -git checkout master #Cleaning the environment. It's also done at the beginning, but it's done just in case. +#git checkout master #Cleaning the environment. It's also done at the beginning, but it's done just in case. INFO "done, RC=$RC" exit $RC diff --git a/jenkins/common/container b/jenkins/common/container index 400e38aa..d959f8f3 100644 --- a/jenkins/common/container +++ b/jenkins/common/container @@ -1,6 +1,7 @@ # This file is meant to be SOURCED # # Copyright 2016 RIFT.IO Inc +# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ # # container_funcs # 24 June 2016 -- Jeremy Mordkoff -- Genesis +# -- Gerardo García container_exists() { if [ $# -ne 1 ]; then @@ -32,21 +34,15 @@ container_exists() { } create_container() { - if [ $# -ne 2 ]; then - FATAL "args are image container" + if [ $# -lt 2 ]; then + FATAL "args are image container [options]" fi INFO "creating container $2 using image $1" - DEBUG "lxc launch $1 $2" - lxc launch "$1" "$2" -} - -create_privileged_container() { - if [ $# -ne 2 ]; then - FATAL "args are image container" - fi - INFO "creating container $2 using image $1" - DEBUG "lxc launch $1 $2" - lxc launch "$1" "$2" -c security.privileged=true + image=$1 + container=$2 + shift 2 + DEBUG "lxc launch $image $container $*" + lxc launch "$image" "$container" "$*" } container_exec() { diff --git a/jenkins/host/start_build b/jenkins/host/start_build index d026fae1..41ea0684 100755 --- a/jenkins/host/start_build +++ b/jenkins/host/start_build @@ -1,5 +1,6 @@ #!/bin/bash # Copyright 2016 RIFT.IO Inc +# Copyright 2016 Telefónica Investigación y Desarrollo S.A.U. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ # start-build is run on a host to start a MDG build # # 24 June 2016 -- Jeremy Mordkoff -- Genesis +# -- Gerardo Garcia HERE=$(realpath $(dirname $0)) @@ -29,11 +31,10 @@ shift OSM_load_config if ! container_exists $OSM_BUILD_CONTAINER; then - if [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]]; then - create_privileged_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER - else - create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER - fi + CONTAINER_OPTS="" + [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true" + [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true" + create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS wait_container_up $OSM_BUILD_CONTAINER RE="fedora|fc[0-9]" if [[ $OSM_BASE_IMAGE =~ $RE ]]; then diff --git a/jenkins/template/SETTINGS b/jenkins/template/SETTINGS index 86202eba..94154f3b 100644 --- a/jenkins/template/SETTINGS +++ b/jenkins/template/SETTINGS @@ -1,4 +1,5 @@ # Copyright 2016 RIFT.IO Inc +# Copyright 2016 Telefónica Investigación y Desarrollo, S.A.U. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +15,9 @@ # # sample SETTINGS file # -# 24 June 2016 -- Jeremy Mordkoff -- Genesis +# Authors: +# 24 June 2016 -- Jeremy Mordkoff -- Genesis +# -- Gerardo Garcia # # this variable holds the name of the container image needed to build or run this product export OSM_BASE_IMAGE=ubuntu:16.04 @@ -27,6 +30,9 @@ export OSM_BUILD_CONTAINER=container_name-build # this variable should be removed in the future when no privileged mode is required #export OSM_BUILD_CONTAINER_PRIVILEGED=yes # +# this variable must be set to allow ensted containers in the build container +#export OSM_BUILD_CONTAINER_ALLOW_NESTED=yes +# # this variable holds the name of the container to be used to run a package # if this container already exists, the run processes can skip the container build export OSM_RUNTIME_CONTAINER=container_name-runtime @@ -34,4 +40,7 @@ export OSM_RUNTIME_CONTAINER=container_name-runtime # this variable must be set to allow creating the runtime container in privileged mode # this variable should be removed in the future when no privileged mode is required #export OSM_RUNTIME_CONTAINER_PRIVILEGED=yes - +# +# this variable must be set to allow ensted containers in the build container +#export OSM_RUNTIME_CONTAINER_ALLOW_NESTED=yes +# -- 2.25.1