From 8802d14a762fb69bae83dc1ca2bce0cc4d190ba5 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Tue, 20 Sep 2016 14:24:13 +0200 Subject: [PATCH] VCA scripts added. New host script clean_container to stop and delete an MDG container Change-Id: I571fd2876658e024d0348f0910bb913e20ed48b3 Signed-off-by: garciadeblas --- jenkins/VCA/SETTINGS | 44 +++++++++++++++++++++++++++++ jenkins/VCA/start_build | 55 ++++++++++++++++++++++++++++++++++++ jenkins/host/clean_container | 41 +++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 jenkins/VCA/SETTINGS create mode 100755 jenkins/VCA/start_build create mode 100755 jenkins/host/clean_container diff --git a/jenkins/VCA/SETTINGS b/jenkins/VCA/SETTINGS new file mode 100644 index 00000000..ded50438 --- /dev/null +++ b/jenkins/VCA/SETTINGS @@ -0,0 +1,44 @@ +# 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 +# +# 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 +# +# Authors: +# - 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 +# +# 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=VCA +# +# 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 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=VCA +# +# 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 +# diff --git a/jenkins/VCA/start_build b/jenkins/VCA/start_build new file mode 100755 index 00000000..a945a05c --- /dev/null +++ b/jenkins/VCA/start_build @@ -0,0 +1,55 @@ +#!/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 +# +# 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. +# +# 20 Sep 2016 -- Gerardo Garcia -- adapted from template +# + +INFO "installing packages" +apt update +lxd init --auto +lxd waitready +systemctl stop lxd-bridge +systemctl --system daemon-reload +cat < /etc/default/lxd-bridge +USE_LXD_BRIDGE="true" +LXD_BRIDGE="lxdbr0" +UPDATE_PROFILE="true" +LXD_CONFILE="" +LXD_DOMAIN="lxd" +LXD_IPV4_ADDR="10.44.127.1" +LXD_IPV4_NETMASK="255.255.255.0" +LXD_IPV4_NETWORK="10.44.127.1/24" +LXD_IPV4_DHCP_RANGE="10.44.127.2,10.44.127.254" +LXD_IPV4_DHCP_MAX="252" +LXD_IPV4_NAT="true" +LXD_IPV6_ADDR="" +LXD_IPV6_MASK="" +LXD_IPV6_NETWORK="" +LXD_IPV6_NAT="false" +LXD_IPV6_PROXY="false" +EOF + +systemctl enable lxd-bridge +systemctl start lxd-bridge +lxc image copy ubuntu:16.04 local: --alias ubuntu-xenial +apt install -y juju +juju bootstrap juju localhost + +RC=0 + +INFO "done, RC=$RC" +exit $RC + + diff --git a/jenkins/host/clean_container b/jenkins/host/clean_container new file mode 100755 index 00000000..601e6b86 --- /dev/null +++ b/jenkins/host/clean_container @@ -0,0 +1,41 @@ +#!/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 +# +# 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. +# +# clean_container is run on a host to clean an MDG container +# +# 20 Sept 2016 -- Gerardo Garcia -- Genesis +# + +HERE=$(realpath $(dirname $0)) +OSM_JENKINS=$(dirname $HERE) +. $OSM_JENKINS/common/all_funcs + +[ $# -lt 1 ] && FATAL "arg is MDG name" + +export OSM_MDG=$1 +OSM_load_config + +if container_exists $OSM_BUILD_CONTAINER; then + INFO "Container exists. Deleting ..." + lxc stop $OSM_BUILD_CONTAINER + lxc delete $OSM_BUILD_CONTAINER + INFO "$OSM_BUILD_CONTAINER container deleted." +else + INFO "Container does not exist. Nothing to be done." +fi + +INFO "$OSM_MDG clean-container DONE." +exit 0 + -- 2.25.1