From: beierlm Date: Thu, 9 Dec 2021 13:47:59 +0000 (-0500) Subject: Bug 1648: Update Microstack Installation X-Git-Tag: v12.0.0rc1~69 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F11489%2F2;p=osm%2Fdevops.git Bug 1648: Update Microstack Installation Change installation to --devmode instead of --classic Add --control to the init Checks for state before creating some objects Use the admin password generated by MicroStack install script Update default security group to have fully open access Update the initial image laod to 20.04 Added creation of an osm-ext network with router to external Fixes bug 1648 Change-Id: I6038be023bf04f99000b0ac8aeec7f7bcf205204 Signed-off-by: beierlm --- diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index bd714a6a..0f895cd6 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -422,32 +422,74 @@ function add_local_k8scluster() { } function install_microstack() { - sudo snap install microstack --classic --beta - sudo microstack.init --auto - wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ~/.osm/ - microstack.openstack image create \ - --public \ - --disk-format qcow2 \ - --container-format bare \ - --file ~/.osm/ubuntu-16.04-server-cloudimg-amd64-disk1.img \ - ubuntu1604 - ssh-keygen -t rsa -N "" -f ~/.ssh/microstack - microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack - export OSM_HOSTNAME=`juju status -m $MODEL_NAME --format json | jq -rc '.applications."nbi".address'` - osm vim-create --name microstack-site \ - --user admin \ - --password keystone \ - --auth_url http://10.20.20.1:5000/v3 \ - --tenant admin \ - --account_type openstack \ - --config='{security_groups: default, - keypair: microstack, - project_name: admin, - user_domain_name: default, - region_name: microstack, - insecure: True, - availability_zone: nova, - version: 3}' + + sudo snap install microstack --beta --devmode + + CHECK=$(microstack.openstack server list) + if [ $? -ne 0 ] ; then + if [[ $CHECK == *"not initialized"* ]]; then + echo "Setting MicroStack dashboard to listen to port 8080" + sudo snap set microstack config.network.ports.dashboard=8080 + echo "Initializing MicroStack. This can take several minutes" + sudo microstack.init --auto --control + fi + fi + + sudo snap alias microstack.openstack openstack + + echo "Updating default security group in MicroStack to allow all access" + + for i in $(microstack.openstack security group list | awk '/default/{ print $2 }'); do + for PROTO in icmp tcp udp ; do + echo " $PROTO ingress" + CHECK=$(microstack.openstack security group rule create $i --protocol $PROTO --remote-ip 0.0.0.0/0 2>&1) + if [ $? -ne 0 ] ; then + if [[ $CHECK != *"409"* ]]; then + echo "Error creating ingress rule for $PROTO" + echo $CHECK + fi + fi + done + done + + microstack.openstack network show osm-ext &>/dev/null + if [ $? -ne 0 ]; then + echo "Creating osm-ext network with router to bridge to MicroStack external network" + microstack.openstack network create --enable --no-share osm-ext + microstack.openstack subnet create osm-ext-subnet --network osm-ext --dns-nameserver 8.8.8.8 \ + --subnet-range 172.30.0.0/24 + microstack.openstack router create external-router + microstack.openstack router add subnet external-router osm-ext-subnet + microstack.openstack router set --external-gateway external external-router + fi + + microstack.openstack image list | grep ubuntu20.04 &> /dev/null + if [ $? -ne 0 ] ; then + echo "Fetching Ubuntu 20.04 image and upLoading to MicroStack" + wget -q -O- https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img \ + | microstack.openstack image create --public --container-format=bare \ + --disk-format=qcow2 ubuntu20.04 | grep status + fi + + if [ ! -f ~/.ssh/microstack ]; then + ssh-keygen -t rsa -N "" -f ~/.ssh/microstack + microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack + fi + + echo "Creating VIM microstack-site in OSM" + . /var/snap/microstack/common/etc/microstack.rc + + osm vim-create \ + --name microstack-site \ + --user "$OS_USERNAME" \ + --password "$OS_PASSWORD" \ + --auth_url "$OS_AUTH_URL" \ + --tenant "$OS_USERNAME" \ + --account_type openstack \ + --config='{use_floating_ip: True, + insecure: True, + keypair: microstack, + management_network_name: osm-ext}' } DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5; exit}'`