Add secret-management in Charmed OSM
[osm/devops.git] / jenkins / VCA / update-lxd-image.sh
old mode 100644 (file)
new mode 100755 (executable)
index ce14b1d..8cad93b
@@ -10,7 +10,7 @@
 set -eux
 
 # The basic charm layer also installs all the things. 47 packages.
-LAYER_BASIC="gcc build-essential python3-pip python3-setuptools python3-yaml"
+LAYER_BASIC="gcc build-essential python3-pip python3-setuptools libyaml-dev python3-yaml python3-dev"
 
 # the basic layer also installs virtualenv, but the name changed in xenial.
 TRUSTY_PACKAGES="python-virtualenv"
@@ -21,6 +21,9 @@ DOWNLOAD_PACKAGES=""
 
 PACKAGES="$LAYER_BASIC $DOWNLOAD_PACKAGES"
 
+# Packages from pypi to pre-install
+PYPI="charms.reactive charmhelpers paramiko>=1.16.0,<1.17"
+
 function cache() {
     series=$1
     container=juju-${series}-base
@@ -28,11 +31,18 @@ function cache() {
 
     lxc delete $container -f || true
     lxc launch ubuntu:$series $container
-    sleep 5  # wait for network
+
+    # Wait for the container to get an IP address
+    lxc exec $container -- bash -c "for i in {1..60}; do sleep 1; ping -c1 10.44.127.1 &> /dev/null && break; done"
+
+    # Wait for cloud-init to finish
+    lxc exec $container -- bash -c "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 1; done"
 
     lxc exec $container -- apt-get update -y
-    lxc exec $container -- apt-get upgrade -y
+    lxc exec $container -- apt-get upgrade -y -o Dpkg::Options::='--force-confold'
     lxc exec $container -- apt-get install -y $PACKAGES $2
+    lxc exec $container -- pip3 install --upgrade pip
+    lxc exec $container -- pip3 install --upgrade $PYPI
     lxc stop $container
 
     lxc image delete $alias || true
@@ -41,5 +51,6 @@ function cache() {
     lxc delete $container -f || true
 }
 
-cache trusty "$TRUSTY_PACKAGES"
+# Cache the image for the Ubuntu series or series to support
+# cache trusty "$TRUSTY_PACKAGES"
 cache xenial "$XENIAL_PACKAGES"