mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
F #4944: Include context packages in OpenNebula distribution
* download context pkgs with scons * update gitignore info * update docker_downloader.sh (cherry picked from commit be6d4d916cd6083c53b7fe57d50d857443ebfe21)
This commit is contained in:
parent
c4228eefcc
commit
7d7478b7f7
4
.gitignore
vendored
4
.gitignore
vendored
@ -54,3 +54,7 @@ share/esx-fw-vnc/*.rpm
|
||||
share/esx-fw-vnc/.vagrant*
|
||||
|
||||
*.vscode
|
||||
|
||||
share/context/*
|
||||
!share/context/download_context.sh
|
||||
!share/context/SConstruct
|
||||
|
@ -209,6 +209,9 @@ main_env.Append(marshal=ARGUMENTS.get('marshal', 'no'))
|
||||
# Docker-machine addon generation
|
||||
main_env.Append(docker_machine=ARGUMENTS.get('docker_machine', 'no'))
|
||||
|
||||
# Context packages download
|
||||
main_env.Append(context=ARGUMENTS.get('context', 'no'))
|
||||
|
||||
if not main_env.GetOption('clean'):
|
||||
try:
|
||||
if mysql == 'yes':
|
||||
@ -313,7 +316,8 @@ build_scripts = [
|
||||
'src/docker_machine/SConstruct',
|
||||
'src/monitor/SConstruct',
|
||||
'src/onedb/SConstruct',
|
||||
svncterm_path
|
||||
svncterm_path,
|
||||
'share/context/SConstruct'
|
||||
]
|
||||
|
||||
# disable svncterm
|
||||
|
@ -237,7 +237,8 @@ SHARE_DIRS="$SHARE_LOCATION/examples \
|
||||
$SHARE_LOCATION/schemas/libvirt \
|
||||
$SHARE_LOCATION/ssh \
|
||||
$SHARE_LOCATION/start-scripts \
|
||||
$SHARE_LOCATION/conf"
|
||||
$SHARE_LOCATION/conf \
|
||||
$SHARE_LOCATION/context"
|
||||
|
||||
ETC_DIRS="$ETC_LOCATION/vmm_exec \
|
||||
$ETC_LOCATION/hm \
|
||||
@ -668,6 +669,7 @@ INSTALL_FILES=(
|
||||
SSH_SH_LIB_FILES:$LIB_LOCATION/sh
|
||||
SSH_SH_OVERRIDE_LIB_FILES:$LIB_LOCATION/sh/override
|
||||
SSH_SHARE_FILES:$SHARE_LOCATION/ssh
|
||||
CONTEXT_SHARE:$SHARE_LOCATION/context
|
||||
)
|
||||
|
||||
INSTALL_CLIENT_FILES=(
|
||||
@ -2682,6 +2684,8 @@ LIBVIRT_RNG_SHARE_MODULE_FILES="share/schemas/libvirt/basictypes.rng \
|
||||
share/schemas/libvirt/nwfilter_params.rng \
|
||||
share/schemas/libvirt/storagecommon.rng"
|
||||
|
||||
CONTEXT_SHARE=$(find share/context/ -type f \( ! -iname "*.sh" ! -iname "SConstruct" \))
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#-----------------------------------------------------------------------------
|
||||
# INSTALL.SH SCRIPT
|
||||
|
29
share/context/SConstruct
Normal file
29
share/context/SConstruct
Normal file
@ -0,0 +1,29 @@
|
||||
# SConstruct for share/scripts/rubygems
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2020, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
import os
|
||||
|
||||
Import('env')
|
||||
|
||||
if env['context']=='yes':
|
||||
print ("Downloading OpenNebula context packages\n")
|
||||
exit_code=os.system("./download_context.sh")
|
||||
|
||||
if exit_code != 0:
|
||||
print ("Error downloading OpenNebula context packages\n")
|
||||
exit(-1)
|
53
share/context/download_context.sh
Executable file
53
share/context/download_context.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# This function returns the associated context packages version to the installed
|
||||
# OpenNebula version
|
||||
#-------------------------------------------------------------------------------
|
||||
function get_tag_version {
|
||||
local creleases=`curl -sSL $1 | jq -r '.[].tag_name' | cut -d 'v' -f 2`
|
||||
|
||||
for tag in `echo $creleases`; do
|
||||
if [ "$tag" = "`echo -e "$tag\n$VERSION" | sort -V | head -n1`" ]; then
|
||||
echo "$tag"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
CONTEXT_API="https://api.github.com/repos/OpenNebula/addon-context-linux/releases"
|
||||
CONTEXT_API_WINDOWS="https://api.github.com/repos/OpenNebula/addon-context-windows/releases"
|
||||
|
||||
VERSION=`cat ../../src/im_mad/remotes/VERSION`
|
||||
|
||||
###############################################################################
|
||||
# Download linux packages
|
||||
###############################################################################
|
||||
|
||||
TAG_VERSION=`get_tag_version $CONTEXT_API`
|
||||
|
||||
# If the current ONE version is greater than every context version the last one is retrieved
|
||||
if [ -z "$TAG_VERSION" ]; then
|
||||
TAG_VERSION=`curl -s $CONTEXT_API | jq -r '.[0].tag_name' | cut -d 'v' -f 2`
|
||||
fi
|
||||
|
||||
TAG="v$TAG_VERSION"
|
||||
|
||||
curl -s $CONTEXT_API | \
|
||||
jq -r --arg TAG "$TAG" '.[] | select(.tag_name == $TAG) | .assets[].browser_download_url' | \
|
||||
xargs wget -P .
|
||||
|
||||
###############################################################################
|
||||
# Download windows .msi
|
||||
###############################################################################
|
||||
|
||||
TAG_VERSION=`get_tag_version $CONTEXT_API_WINDOWS`
|
||||
|
||||
# If the current ONE version is greater than every context version the last one is retrieved
|
||||
if [ -z "$TAG_VERSION" ]; then
|
||||
TAG_VERSION=`curl -s $CONTEXT_API_WINDOWS | jq -r '.[0].tag_name' | cut -d 'v' -f 2`
|
||||
fi
|
||||
|
||||
TAG="v$TAG_VERSION"
|
||||
|
||||
wget -P . https://github.com/OpenNebula/addon-context-windows/releases/download/$TAG/one-context-$TAG_VERSION.msi
|
@ -19,9 +19,11 @@
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
VAR_LOCATION=/var/lib/one
|
||||
SHARE_LOCATION=/usr/share/one
|
||||
else
|
||||
LIB_LOCATION=$ONE_LOCATION/lib
|
||||
VAR_LOCATION=$ONE_LOCATION/var
|
||||
SHARE_LOCATION=$ONE_LOCATION/share
|
||||
fi
|
||||
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
@ -34,42 +36,14 @@ MARKET_URL=$1
|
||||
|
||||
MK_DOCKER=$LIB_LOCATION/sh/create_docker_image.sh
|
||||
|
||||
# URL with the context releases
|
||||
CONTEXT_API="https://api.github.com/repos/OpenNebula/addon-context-linux/releases"
|
||||
CONTEXT_URL="https://github.com/OpenNebula/addon-context-linux/releases/download"
|
||||
|
||||
PKG_APK="curl openssh"
|
||||
PKG_DEB="curl "
|
||||
PKG_RPM="openssh-server"
|
||||
PKG_CENTOS6="epel-release $PKG_RPM"
|
||||
PKG_FEDORA="network-scripts $PKG_RPM"
|
||||
|
||||
#Default DNS server to download the packages
|
||||
DNS_SERVER="1.1.1.1"
|
||||
|
||||
#Directory used to download packages
|
||||
TMP_DIR=/var/tmp
|
||||
|
||||
#Curl command and options used to download container image
|
||||
CURL="curl -L"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# This function returns the associated context packages version to the installed
|
||||
# OpenNebula version
|
||||
#-------------------------------------------------------------------------------
|
||||
function get_tag_name {
|
||||
local version=`oned --version 2>/dev/null | grep '^OpenNebula [0-9.]\+ ' | cut -d' ' -f2`
|
||||
|
||||
local creleases=`curl -sSL $CONTEXT_API | grep "\"tag_name\":" | \
|
||||
awk '{print $2}' | cut -d 'v' -f 2 | cut -d '"' -f 1`
|
||||
|
||||
for tag in `echo $creleases`; do
|
||||
if [ "$tag" = "`echo -e "$tag\n$version" | sort -V | head -n1`" ]; then
|
||||
echo "$tag"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
#Context location
|
||||
CONTEXT_PATH="$SHARE_LOCATION/context"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# This function takes care of removing all temporary directories in case
|
||||
@ -104,8 +78,6 @@ sid=`echo $id | cut -d '-' -f 1`
|
||||
url=`echo $MARKET_URL | grep -oP "^"docker://"\K.*"`
|
||||
arguments=`echo $url | cut -d '?' -f 2`
|
||||
|
||||
selected_tag=`get_tag_name`
|
||||
|
||||
#Create a shell variable for every argument (size=5219, format=raw...)
|
||||
for p in ${arguments//&/ }; do
|
||||
kvp=( ${p/=/ } );
|
||||
@ -150,10 +122,7 @@ fi
|
||||
|
||||
case "$distro" in
|
||||
debian|ubuntu)
|
||||
contextpkg=$dockerdir/context.deb
|
||||
contexturl=$CONTEXT_URL/v$selected_tag/one-context_$selected_tag-1.deb
|
||||
commands=$(cat <<EOC
|
||||
COPY context.deb /root/context.deb
|
||||
RUN apt-get update
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
@ -169,8 +138,7 @@ RUN apt-get update && apt-get install -y \
|
||||
vim-tiny \
|
||||
wget \
|
||||
haveged
|
||||
RUN apt-get install -y /root/context.deb
|
||||
RUN rm /root/context.deb
|
||||
RUN apt-get install -y /root/context/one-context_*.deb
|
||||
RUN apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
RUN systemctl enable haveged
|
||||
@ -178,28 +146,19 @@ EOC
|
||||
)
|
||||
;;
|
||||
centos)
|
||||
terminal="/bin/bash"
|
||||
contextpkg=$dockerdir/context.rpm
|
||||
contexturl=$CONTEXT_URL/v$selected_tag/one-context-$selected_tag-1.el7.noarch.rpm
|
||||
commands=$(cat <<EOC
|
||||
COPY context.rpm /root/context.rpm
|
||||
RUN yum update -y
|
||||
RUN yum install -y epel-release
|
||||
RUN yum install -y initscripts \
|
||||
e2fsprogs \
|
||||
haveged
|
||||
RUN yum localinstall -y /root/context.rpm
|
||||
RUN rm /root/context.rpm
|
||||
RUN yum localinstall -y \`find /root/context -type f \( ! -iname "*ec2*" -iname "*el7.noarch.rpm" \)\`
|
||||
RUN systemctl enable haveged
|
||||
EOC
|
||||
)
|
||||
;;
|
||||
alpine)
|
||||
terminal="/bin/ash"
|
||||
contextpkg=$dockerdir/context.apk
|
||||
contexturl=$CONTEXT_URL/v$selected_tag/one-context-$selected_tag-r1.apk
|
||||
commands=$(cat <<EOC
|
||||
COPY context.apk /root/context.apk
|
||||
RUN apk add coreutils \
|
||||
openrc \
|
||||
udev \
|
||||
@ -213,9 +172,7 @@ RUN rc-update add sysfs boot && \
|
||||
rc-update add haveged boot
|
||||
|
||||
RUN echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab
|
||||
|
||||
RUN apk add --allow-untrusted /root/context.apk
|
||||
RUN rm /root/context.apk
|
||||
RUN apk add --allow-untrusted /root/context/*.apk
|
||||
RUN rc-update del one-context boot && \
|
||||
rc-update add one-context default
|
||||
|
||||
@ -234,13 +191,15 @@ esac
|
||||
cat > $dockerfile <<EOC
|
||||
FROM $docker_hub
|
||||
USER root
|
||||
COPY context /root/context
|
||||
$commands
|
||||
RUN rm -rf /root/context
|
||||
RUN echo "#Generated by OpenNebula" > /etc/resolv.conf
|
||||
RUN rm -f /etc/ssh/ssh_host_* > /dev/null 2>&1
|
||||
RUN usermod -p '*' root > /dev/null 2>&1
|
||||
EOC
|
||||
|
||||
$CURL $contexturl -Lsfo $contextpkg > /dev/null 2>&1
|
||||
cp -rL $CONTEXT_PATH $dockerdir
|
||||
|
||||
docker build -t one$sid -f $dockerfile $dockerdir > /dev/null 2>&1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user