X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=tools%2Flocal-build.sh;h=4ff12f2ba267a4f173de223187cab420cce2fa6f;hb=refs%2Fchanges%2F86%2F13286%2F3;hp=ab4b147c05544e1d50d804a5fc0e9aa2a4119443;hpb=b26337f4b399b8d2307002aa7ca98c23e2d3a1ed;p=osm%2Fdevops.git diff --git a/tools/local-build.sh b/tools/local-build.sh index ab4b147c..4ff12f2b 100755 --- a/tools/local-build.sh +++ b/tools/local-build.sh @@ -18,7 +18,7 @@ APT_PROXY="" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -HTTPDDIR="$( cd "${HOME}/snap/qhttp/common" &> /dev/null && pwd )" +HTTPDDIR="${HOME}/.osm/httpd" HTTPPORT=8000 KUBECFG="~/.osm/microk8s-config.yaml" NO_CACHE="" @@ -35,10 +35,11 @@ function check_arguments(){ --apt-proxy) APT_PROXY="$2" && shift ;; --devel-tag) DEVEL_TAG="$2" && shift ;; --help | -h) show_help && exit 0 ;; - --httpddir) HTTPDIR="$2" && shift;; + --httpddir) HTTPDDIR="$2" && shift;; --install-local-registry) 'install_local_registry' ;; --install-microstack) 'install_microstack' ;; --install-qhttpd) INSTALL_HTTPD='install_qhttpd' ;; + --run-httpserver) INSTALL_HTTPD='run_httpserver' ;; --kubecfg) KUBECFG="$2" && shift ;; --module) TARGET_MODULE="$2" && shift;; --no-cache) NO_CACHE="--no-cache" ;; @@ -75,7 +76,8 @@ OPTIONS: --debug enable set -x for this script --install-local-registry install and enable Microk8s local registry on port 32000 --install-microstack install Microstack and configure to run robot tests - --install-qhttpd install QHTTPD as an HTTP server on port ${HTTPPORT} + --install-qhttpd (deprecated, use --run-httpserver instead) install QHTTPD as an HTTP server on port ${HTTPPORT} + --run-httpserver run HTTP server on port ${HTTPPORT} --kubecfg path to kubecfg.yaml (uses Charmed OSM by default) --no-cache do not use any cache when building docker images --module only build this comma delimited list of modules @@ -104,9 +106,9 @@ Let's assume that we have different repos cloned in the folder workspace: git clone "https://osm.etsi.org/gerrit/osm/IM git clone "https://osm.etsi.org/gerrit/osm/N2VC -First we install a light HTTP server to serve the artifacts: +First we run a light HTTP server to serve the artifacts: - devops/tools/local-build.sh --install-qhttpd + devops/tools/local-build.sh --run-httpserver Then we generate the artifacts (debian packages) for the different repos: common, IM, N2VC, RO, LCM, NBI @@ -168,6 +170,10 @@ function install_microstack() { --disk-format=qcow2 ubuntu20.04 } +function create_httpddir() { + mkdir -p ${HTTPDDIR} +} + function install_qhttpd() { sudo snap install qhttp EXISTING_PID=$(ps auxw | grep "http.server $HTTPPORT" | grep -v grep | awk '{print $2}') @@ -177,6 +183,14 @@ function install_qhttpd() { nohup qhttp -p ${HTTPPORT} & } +function run_httpserver() { + EXISTING_PID=$(ps auxw | grep "http.server $HTTPPORT" | grep -v grep | awk '{print $2}') + if [ ! -z $EXISTING_PID ] ; then + kill $EXISTING_PID + fi + nohup python3 -m http.server ${HTTPPORT} --directory "${HTTPDDIR}" &>/dev/null & +} + function stage_2() { print_section "Performing Stage 2" MODULES="common devops IM LCM MON N2VC NBI NG-UI NG-SA osmclient PLA POL RO tests" @@ -264,7 +278,13 @@ function stage_3() { fi HOSTIP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') - for file in ~/snap/qhttp/common/*.deb ; do + [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}') + [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}') + DEFAULT_IP=$(ip -o -4 a s ${DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}') + HOSTIP=${HOSTIP:=${DEFAULT_IP}} + echo $HOSTIP + + for file in ${HTTPDDIR}/*.deb ; do file=`basename ${file}` name=`echo ${file} | cut -d_ -f1 | sed "s/-/_/g" | sed "s/.deb//"`; name=${name^^}_URL @@ -436,6 +456,7 @@ if [ "$0" != "$BASH_SOURCE" ]; then else check_arguments $@ + create_httpddir eval "${INSTALL_HTTPD}" eval "${INSTALL_LOCAL_REGISTRY}" eval "${INSTALL_MICROSTACK}"