- SETTINGS files in template and riftware were modified to allow option for privileged container
- New function in common/container to create privileged containers
- RO SETTINGS and start_build skeleton were created
Change-Id: I80143214708e65c62c899efecd30d4b84fb715ce
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
--- /dev/null
+# Copyright 2016 RIFT.IO Inc
+#
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# sample SETTINGS file
+#
+# 24 June 2016 -- Jeremy Mordkoff -- Genesis
+#
+# this variable holds the name of the container image needed to build or run this product
+export OSM_BASE_IMAGE=ubuntu:14.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
+export OSM_BUILD_CONTAINER=RO
+#
+# 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=RO
--- /dev/null
+#!/bin/bash
+# Copyright 2016 RIFT.IO Inc
+#
+# 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
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# TEMPLATE script to start a build. This is run inside a container
+#
+# 6 July 2016 -- Jeremy.Mordkoff@riftio.com -- adapted from the riftware version
+#
+
+HERE=$(realpath $(dirname $0))
+OSM_JENKINS=$(dirname $HERE)
+. $OSM_JENKINS/common/all_funcs
+
+# SET YOU MDG repository name here
+export OSM_MDG=RO
+OSM_load_config
+
+
+# Here is an example for how to handle an incremental build
+if [ -d $OSM_MDG ]; then
+ INFO "reusing existing workspace"
+ cd $OSM_MDG
+ git pull
+else
+ INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG"
+ git clone $OSM_GIT_URL/$OSM_MDG
+ cd $OSM_MDG
+fi
+INFO "starting build"
+
+### for start_build
+### put your commands here to
+### build, test and produce coverage reports
+
+##CODE HERE
+touch compiled
+
+RC=0
+
+INFO "done, RC=$RC"
+exit $RC
+
+
fi
INFO "creating container $2 using image $1"
DEBUG "lxc launch $1 $2"
- sudo 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
}
container_exec() {
container="$1"
shift
- DEBUG "exec in $1 \"$*\""
+ DEBUG "exec in $container \"$*\""
lxc exec "$container" -- $*
}
OSM_load_config
if ! container_exists $OSM_BUILD_CONTAINER; then
- create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER
+ 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
wait_container_up $OSM_BUILD_CONTAINER
RE="fedora|fc[0-9]"
if [[ $OSM_BASE_IMAGE =~ $RE ]]; then
container_exec $OSM_BUILD_CONTAINER yum -y install git
else
- container_exec $OSM_BUILD_CONTAINER apt install git
+ container_exec $OSM_BUILD_CONTAINER apt -y install git realpath
fi
container_exec $OSM_BUILD_CONTAINER git clone ${OSM_GIT_URL}/devops
else
container_exec $OSM_BUILD_CONTAINER git -C devops pull
fi
-
container_exec $OSM_BUILD_CONTAINER ./devops/jenkins/$OSM_MDG/start_build
RC=$?
INFO "$OSM_MDG build complete. Return code was $RC"
exit $RC
+
# 24 June 2016 -- Jeremy Mordkoff -- Genesis
#
# see ../template/SETTINGS for descriptions
-export OSM_BASE_IMAGE=fc20
+export OSM_BASE_IMAGE=fedora20
export OSM_BUILD_CONTAINER=rift-build
+export OSM_BUILD_CONTAINER_PRIVILEGED=yes
export OSM_RUNTIME_CONTAINER=rift-runtime
+export OSM_RUNTIME_CONTAINER_PRIVILEGED=yes
# 24 June 2016 -- Jeremy Mordkoff -- Genesis
#
# this variable holds the name of the container image needed to build or run this product
-export OSM_BASE_IMAGE=fc20
+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
-export OSM_BUILD_CONTAINER=rift-build
+export OSM_BUILD_CONTAINER=container_name-build
+#
+# this variable must be set to allow creating the build container in privileged mode
+# this variable should be removed in the future when no privileged mode is required
+#export OSM_BUILD_CONTAINER_PRIVILEGED=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=rift-runtime
+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
+