From 0b7b339fc0369e7e9fb6314252a24aadcb366704 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 12 Jul 2018 20:59:58 -0400 Subject: [PATCH] CP init scripts to jenkins-init-scripts This is a transition patch. Global-JJB now provides jenkins-init-scripts and we need to switch to using them. OpenDaylight has a few custom components not covered by global-jjb so we are using the local-init.sh entrypoint to add custom ODL code. Once this is merged we can test on the sandbox and if successful remove everything in the jenkins-scripts directory. Change-Id: I5bbdb4e06aabd062226124a7e02c9d187ac6df0d Signed-off-by: Thanh Ha --- jenkins-init-scripts/builder.sh | 12 ++++++++ jenkins-init-scripts/devstack.sh | 21 ++++++++++++++ jenkins-init-scripts/docker.sh | 17 ++++++++++++ jenkins-init-scripts/local-init.sh | 15 ++++++++++ jenkins-init-scripts/mininet-ubuntu.sh | 16 +++++++++++ jenkins-init-scripts/robot.sh | 12 ++++++++ jenkins-init-scripts/system_type.sh | 34 +++++++++++++++++++++++ jenkins-init-scripts/ubuntu-docker-ovs.sh | 26 +++++++++++++++++ 8 files changed, 153 insertions(+) create mode 100755 jenkins-init-scripts/builder.sh create mode 100755 jenkins-init-scripts/devstack.sh create mode 100755 jenkins-init-scripts/docker.sh create mode 100755 jenkins-init-scripts/local-init.sh create mode 100755 jenkins-init-scripts/mininet-ubuntu.sh create mode 100755 jenkins-init-scripts/robot.sh create mode 100755 jenkins-init-scripts/system_type.sh create mode 100755 jenkins-init-scripts/ubuntu-docker-ovs.sh diff --git a/jenkins-init-scripts/builder.sh b/jenkins-init-scripts/builder.sh new file mode 100755 index 000000000..367451f56 --- /dev/null +++ b/jenkins-init-scripts/builder.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# vim: sw=2 ts=2 sts=2 et : + +yum clean all + +# disable the firewall +/bin/bash ./disable_firewall.sh + +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF diff --git a/jenkins-init-scripts/devstack.sh b/jenkins-init-scripts/devstack.sh new file mode 100755 index 000000000..d8a873276 --- /dev/null +++ b/jenkins-init-scripts/devstack.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# It looks like the devstack gate is stomping on our dnsmasq setup which +# therefore kills our ability to do proper lookups of some resources. +# Let's capture the 3 nexus IPs into /etc/hosts +cat <> /etc/hosts +# the internal address for nexus +$(dig +short nexus.opendaylight.org) nexus.opendaylight.org +# all the nexus proxies +$(dig +short nexus01.dfw.opendaylight.org) nexus01.dfw.opendaylight.org +$(dig +short nexus02.dfw.opendaylight.org) nexus02.dfw.opendaylight.org +$(dig +short nexus03.ord.opendaylight.org) nexus03.ord.opendaylight.org +EOHOSTS + +# make sure we don't require tty for sudo operations +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF + +# vim: sw=2 ts=2 sts=2 et : diff --git a/jenkins-init-scripts/docker.sh b/jenkins-init-scripts/docker.sh new file mode 100755 index 000000000..d8963184c --- /dev/null +++ b/jenkins-init-scripts/docker.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# make sure we don't require tty for sudo operations +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF + +# make sure jenkins is part of the docker only if jenkins has already been +# created + +if grep -q jenkins /etc/passwd +then + /usr/sbin/usermod -a -G docker jenkins +fi + +# vim: sw=2 ts=2 sts=2 et : diff --git a/jenkins-init-scripts/local-init.sh b/jenkins-init-scripts/local-init.sh new file mode 100755 index 000000000..c4b2d9b81 --- /dev/null +++ b/jenkins-init-scripts/local-init.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2016 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +./system_type.sh +# shellcheck disable=SC1091 +source /tmp/system_type.sh +"./${SYSTEM_TYPE}.sh" diff --git a/jenkins-init-scripts/mininet-ubuntu.sh b/jenkins-init-scripts/mininet-ubuntu.sh new file mode 100755 index 000000000..7f0cd569e --- /dev/null +++ b/jenkins-init-scripts/mininet-ubuntu.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# make sure we don't require tty for sudo operations +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF + +# disable the firewall +/bin/bash ./disable_firewall.sh + +# Add 'hostname' into /etc/hosts during node spinup time to avoid sudo returning +# an 'unable to resolve host' message or some Java API's returning an unknown +# host exception. The workaround on adding "myhostname" into /etc/nss-switch.conf +# does not work on Ubuntu flavours. +sed -i "/127.0.0.1/s/$/\t$(hostname)/" /etc/hosts diff --git a/jenkins-init-scripts/robot.sh b/jenkins-init-scripts/robot.sh new file mode 100755 index 000000000..5fc0579d8 --- /dev/null +++ b/jenkins-init-scripts/robot.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# make sure we don't require tty for sudo operations +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF + +# make sure the firewall is stopped +service iptables stop + +# vim: sw=2 ts=2 sts=2 et : diff --git a/jenkins-init-scripts/system_type.sh b/jenkins-init-scripts/system_type.sh new file mode 100755 index 000000000..c5b141afd --- /dev/null +++ b/jenkins-init-scripts/system_type.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: EPL-1.0 +############################################################################## +# Copyright (c) 2016 The Linux Foundation and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################## + +HOST=$(/bin/hostname) +SYSTEM_TYPE='' + +IFS=',' +for i in "java-builder,builder" \ + "builder,builder" \ + "devstack,devstack" \ + "docker,docker" \ + "gbp,ubuntu-docker-ovs" \ + "kubernetes,mininet-ubuntu" \ + "robot,robot" \ + "mininet,mininet-ubuntu" +do set -- $i + if [[ $HOST == *"$1"* ]]; then + SYSTEM_TYPE="$2" + break + fi +done + +# Write out the system type to an environment file to then be sourced +echo "SYSTEM_TYPE=${SYSTEM_TYPE}" > /tmp/system_type.sh + +# vim: sw=4 ts=4 sts=4 et : diff --git a/jenkins-init-scripts/ubuntu-docker-ovs.sh b/jenkins-init-scripts/ubuntu-docker-ovs.sh new file mode 100755 index 000000000..743255b69 --- /dev/null +++ b/jenkins-init-scripts/ubuntu-docker-ovs.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# make sure we don't require tty for sudo operations +cat </etc/sudoers.d/89-jenkins-user-defaults +Defaults:jenkins !requiretty +jenkins ALL = NOPASSWD: ALL +EOF + +# Add 'hostname' into /etc/hosts during node spinup time to avoid sudo returning +# an 'unable to resolve host' message or some Java API's returning an unknown +# host exception. The workaround on adding "myhostname" into /etc/nss-switch.conf +# does not work on Ubuntu flavours. +sed -i "/127.0.0.1/s/$/\t$(hostname)/" /etc/hosts + +# Do the final install of OVS that the has to be done at boot time for +# some reason due to how the snapshots keep behaving. +dpkg --install /root/openvswitch-datapath-dkms* && \ +dpkg --install /root/openvswitch-{common,switch}* + +# add user jenkins to docker group +/usr/sbin/usermod -a -G docker jenkins + +# pull docker images +docker pull alagalah/odlpoc_ovs230 + +# vim: sw=2 ts=2 sts=2 et : -- 2.36.6