cleanup code 71/45771/1
authorGuo Ruijing <ruijing.guo@intel.com>
Wed, 18 Oct 2017 23:56:15 +0000 (19:56 -0400)
committerGuo Ruijing <ruijing.guo@intel.com>
Thu, 19 Oct 2017 00:02:51 +0000 (20:02 -0400)
1. remove unused code due to juju>2 & maas>2.2 in Ubuntu16.04
2. remove deprecated 03-maasdeploy.sh
3. remove other unused code

Change-Id: I20fd0e96400db1262b0df3ef2b502c8001dd5b76
Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
13 files changed:
ci/00-maasdeploy.sh [deleted symlink]
ci/01-bootstrap.sh
ci/02-deploybundle.sh
ci/03-maasdeploy.sh
ci/clean.sh
ci/cleanmaas.sh
ci/depMAAS.py
ci/deploy.sh
ci/genBundle.py
ci/genDeploymentConfig.py
ci/genK8Bundle.py
ci/genMAASConfig.py
ci/openstack.sh

diff --git a/ci/00-maasdeploy.sh b/ci/00-maasdeploy.sh
deleted file mode 120000 (symlink)
index 33b6f4d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-03-maasdeploy.sh
\ No newline at end of file
index 88f87dd..e45c2ee 100755 (executable)
@@ -2,21 +2,6 @@
 
 set -ex
 
-#export JUJU_DEV_FEATURE_FLAGS=address-allocation
-
-jujuver=`juju --version`
-
-if [[ "$jujuver" < "2" ]]; then
-  juju bootstrap --debug --to bootstrap.maas --agent-version 1.25.5
-  sleep 5
-  #disable juju gui until xenial charms are in charm store.
-  juju deploy cs:juju-gui-130 --to 0
-
-  JUJU_REPOSITORY=
-  juju set-constraints tags=
-
-else
-  controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
-  cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
-  juju bootstrap $controllername $cloudname --debug --to bootstrap.maas
-fi
+controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
+cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
+juju bootstrap $controllername $cloudname --debug --to bootstrap.maas
index 5a72445..d86d1e0 100755 (executable)
@@ -12,9 +12,6 @@ opnfvfeature=$5
 opnfvdistro=$6
 opnfvmodel=$7
 
-jujuver=`juju --version`
-maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
-
 if [[ "$opnfvmodel" = "openstack" ]]; then
     #copy and download charms
     ./$opnfvsdn/fetch-charms.sh $opnfvdistro
@@ -54,19 +51,10 @@ check_status() {
 PROFILE=maas
 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
 API_SERVERMAAS="http://$MAAS_IP:5240/MAAS/"
-if [[ "$maasver" > "2" ]]; then
-    API_KEY=`sudo maas-region apikey --username=ubuntu || true`
-else
-    API_KEY=`sudo maas-region-admin apikey --username=ubuntu || true`
-fi
-
+API_KEY=`sudo maas-region apikey --username=ubuntu || true`
 
 if [[ "$API_KEY" = "" ]]; then
-    if [[ "$maasver" > "2" ]]; then
-        API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region apikey --username=ubuntu'`
-    else
-        API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region-admin apikey --username=ubuntu'`
-    fi
+    API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region apikey --username=ubuntu'`
 fi
 
 maas login $PROFILE $API_SERVERMAAS $API_KEY
@@ -80,11 +68,7 @@ if [[ "$opnfvmodel" = "openstack" ]]; then
        osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
     fi
 
-    if [[ "$maasver" > "2" ]]; then
-        workmutiple=`maas maas nodes read | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
-    else
-        workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
-    fi
+    workmutiple=`maas maas nodes read | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
     max=0
     for v in ${workmutiple[@]}; do
         if (( $v > $max )); then max=$v; fi;
index bc0c2cb..09f497b 100755 (executable)
@@ -58,10 +58,6 @@ sudo apt-get install bridge-utils openssh-server bzr git virtinst qemu-kvm libvi
              python-congressclient gsutil charm-tools pastebinit python-jinja2 sshpass \
              openssh-server vlan ipmitool jq expect snap -y
 
-#sudo apt-get install snap -y
-#sudo snap install maas --classic
-#sudo snap install juju --classic
-
 sudo -H pip install --upgrade pip
 
 
@@ -223,14 +219,6 @@ fi
 sudo cat ~maas/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
 sudo cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
 
-#
-# MAAS deploy
-#
-
-installmaas(){
-    sudo apt-get install maas maas-region-controller -y
-}
-
 #
 # MAAS config
 # https://insights.ubuntu.com/2016/01/23/maas-setup-deploying-openstack-on-maas-1-9-with-juju/
@@ -688,12 +676,8 @@ if [ -e ./labconfig.json ]; then
 fi
 
 # Add the cloud and controller credentials for MAAS for that lab.
-jujuver=`juju --version`
-
-if [[ "$jujuver" > "2" ]]; then
-    addcloud
-    addcredential
-fi
+addcloud
+addcredential
 
 #
 # End of scripts
index 5005b59..1f3ef54 100755 (executable)
@@ -2,52 +2,22 @@
 
 set -ex
 
-jujuver=`juju --version`
-
-if [[ "$jujuver" > "2" ]]; then
-    if [ ! -d labconfig.yaml ]; then
-        cp ~/joid_config/labconfig.yaml ./labconfig.yaml || true
-        if [ -d $HOME/joid_config/deployconfig.yaml ]; then
-            cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml || true
-        else
-            python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
-        fi
-    fi
-else
-    if [ ! -d environments.yaml ]; then
-        cp ~/joid_config/environments.yaml ./environments.yaml || true
-        cp ~/.juju/environments.yaml ./environments.yaml || true
-    fi
-fi
-
-
-if [[ "$jujuver" > "2" ]]; then
-    controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
-    cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
-    juju destroy-controller $controllername --destroy-all-models -y || true
-#    juju kill-controller $controllername --timeout 10s -y || true
-    rm -rf precise
-    rm -rf trusty
-    rm -rf xenial
-    rm -rf ~/joid_config/admin-openrc
-    sleep 10
-    sudo sysctl -w vm.drop_caches=3
-elif [ -d $HOME/.juju/environments ]; then
-    echo " " > status.txt
-    juju status  &>>status.txt || true
-    if [ "$(grep -c "environment is not bootstrapped" status.txt )" -ge 1 ]; then
-        echo " environment is not bootstrapped ..."
+if [ ! -d labconfig.yaml ]; then
+    cp ~/joid_config/labconfig.yaml ./labconfig.yaml || true
+    if [ -d $HOME/joid_config/deployconfig.yaml ]; then
+        cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml || true
     else
-        echo " environment is bootstrapped ..."
-        jujuenv=`juju status | grep environment | cut -d ":" -f 2`
-        juju destroy-environment $jujuenv  -y || true
+        python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
     fi
-    rm -rf precise
-    rm -rf trusty
-    rm -rf xenial
-    rm -rf $HOME/.juju/j*
-    rm -rf $HOME/.juju/.deployer-store-cache
-    rm -rf $HOME/.juju/environments
-    rm -rf $HOME/.juju/ssh
-    sudo sysctl -w vm.drop_caches=3
 fi
+
+controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
+cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
+juju destroy-controller $controllername --destroy-all-models -y || true
+#juju kill-controller $controllername --timeout 10s -y || true
+rm -rf precise
+rm -rf trusty
+rm -rf xenial
+rm -rf ~/joid_config/admin-openrc
+sleep 10
+sudo sysctl -w vm.drop_caches=3
index 41a7419..bcb4e44 100755 (executable)
@@ -2,10 +2,6 @@
 
 set -ex
 
-maasver=$(apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/^[ ]*//')
-
-if [[ "$maasver" > "2" ]]; then
-    echo "removing existing maas ..."
-    sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller  -y
-    sudo rm -rf /var/lib/maas
-fi
+echo "removing existing maas ..."
+sudo apt-get purge maas maas-cli maas-common maas-dhcp maas-dns maas-proxy maas-rack-controller maas-region-api maas-region-controller  -y
+sudo rm -rf /var/lib/maas
index 5592bc4..3a16b1e 100644 (file)
@@ -31,14 +31,7 @@ labconfig_file = options.lab
 #
 # Set Path and configs path
 #
-
-# Capture our current directory
-jujuver = subprocess.check_output(["juju", "--version"])
-
-if LooseVersion(jujuver) >= LooseVersion('2'):
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas_tpl'
-else:
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas2/maas_tpl'
+TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas_tpl'
 
 HOME = os.environ['HOME']
 USER = os.environ['USER']
index 9277e85..a061f0e 100755 (executable)
@@ -227,7 +227,7 @@ deploy() {
         ./cleanvm.sh || true
 
         if [ "$virtinstall" -eq 1 ]; then
-            ./00-maasdeploy.sh virtual
+            ./03-maasdeploy.sh virtual
         else
             if [ -z "$labfile" ]; then
                 if [ ! -e ./labconfig.yaml ]; then
@@ -248,7 +248,7 @@ deploy() {
                 cp $labfile ./labconfig.yaml
             fi
 
-            ./00-maasdeploy.sh custom
+            ./03-maasdeploy.sh custom
         fi
     fi
 
@@ -318,8 +318,6 @@ juju status --format=tabular
 # translate bundle.yaml to json
 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
 
-jujuver=`juju --version`
-
 # Configuring deployment
 if ([ $opnfvmodel == "openstack" ]); then
     echo_info "Configuring OpenStack deployment"
@@ -327,13 +325,8 @@ if ([ $opnfvmodel == "openstack" ]); then
     ./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
 
     # creating heat domain after pushing the public API into /etc/hosts
-    if [[ "$jujuver" > "2" ]]; then
-        status=`juju run-action heat/0 domain-setup`
-        echo $status
-    else
-        status=`juju action do heat/0 domain-setup`
-        echo $status
-    fi
+    status=`juju run-action heat/0 domain-setup`
+    echo $status
 
     sudo ../juju/get-cloud-images || true
     ../juju/joid-configure-openstack || true
index 1bd09bb..ffe9cb8 100644 (file)
@@ -35,13 +35,7 @@ labconfig_file = options.lab
 #
 
 scenarioconfig_file = 'default_deployment_config.yaml'
-# Capture our current directory
-jujuver = subprocess.check_output(["juju", "--version"])
-
-if LooseVersion(jujuver) >= LooseVersion('2'):
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/juju2/bundle_tpl'
-else:
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/bundle_tpl'
+TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/juju2/bundle_tpl'
 
 #
 # Prepare variables
index 0a21fff..0d3a1c9 100644 (file)
@@ -30,14 +30,7 @@ labconfig_file = options.lab
 #
 # Set Path and configs path
 #
-
-# Capture our current directory
-jujuver = subprocess.check_output(["juju", "--version"])
-
-if LooseVersion(jujuver) >= LooseVersion('2'):
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/juju2'
-else:
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl'
+TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/juju2'
 
 HOME = os.environ['HOME']
 USER = os.environ['USER']
index 2f0b63d..f0198d7 100644 (file)
@@ -35,9 +35,6 @@ labconfig_file = options.lab
 #
 
 scenarioconfig_file = 'default_deployment_config.yaml'
-# Capture our current directory
-jujuver = subprocess.check_output(["juju", "--version"])
-
 TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/juju2/bundlek8_tpl'
 
 #
index 9417f71..8a3f557 100644 (file)
@@ -31,14 +31,7 @@ labconfig_file = options.lab
 #
 # Set Path and configs path
 #
-
-# Capture our current directory
-jujuver = subprocess.check_output(["juju", "--version"])
-
-if LooseVersion(jujuver) >= LooseVersion('2'):
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas2/maas_tpl'
-else:
-    TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas_tpl'
+TPL_DIR = os.path.dirname(os.path.abspath(__file__))+'/config_tpl/maas2/maas_tpl'
 
 HOME = os.environ['HOME']
 USER = os.environ['USER']
index a32bb99..a7d91fb 100755 (executable)
@@ -17,8 +17,6 @@ opnfvlab=$2
 opnfvdistro=$3
 opnfvos=$4
 
-jujuver=`juju --version`
-
 if [ -f ./deployconfig.yaml ];then
     EXTERNAL_NETWORK=`grep floating-ip-range deployconfig.yaml | cut -d ' ' -f 4 `
 
@@ -49,38 +47,22 @@ update_gw_mac() {
     ## get gateway mac
     EXTNET_GW_MAC=$(juju ssh nova-compute/0 "arp -a ${EXTNET_GW} | grep -Eo '([0-9a-fA-F]{2})(([/\s:-][0-9a-fA-F]{2}){5})'")
     ## set external gateway mac in onos
-    if [[ "$jujuver" < "2" ]]; then
-        juju set onos-controller gateway-mac=$EXTNET_GW_MAC
-    else
-        juju config onos-controller gateway-mac=$EXTNET_GW_MAC
-    fi
+    juju config onos-controller gateway-mac=$EXTNET_GW_MAC
 }
 
 unitAddress() {
-    if [[ "$jujuver" < "2" ]]; then
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
-    else
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
-    fi
+    juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"public-address\"]" 2> /dev/null
 }
 
 unitMachine() {
-    if [[ "$jujuver" < "2" ]]; then
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"services\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
-    else
-        juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
-    fi
+    juju status --format yaml | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"applications\"][\"$1\"][\"units\"][\"$1/$2\"][\"machine\"]" 2> /dev/null
 }
 
 keystoneIp() {
     if [ $(juju status keystone --format=short | grep " keystone"|wc -l) == 1 ];then
         unitAddress keystone 0
     else
-        if [[ "$jujuver" < "2" ]]; then
-            juju get keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
-        else
-            juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
-        fi
+        juju config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)['settings']['vip']['value']" | cut -d " " -f 1
     fi
 }
 
@@ -90,11 +72,7 @@ create_openrc() {
 
     mkdir -m 0700 -p cloud
     keystoneIp=$(keystoneIp)
-    if [[ "$jujuver" < "2" ]]; then
-        adminPasswd=$(juju get keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
-    else
-        adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
-    fi
+    adminPasswd=$(juju config keystone | grep admin-password -A 5 | grep value | awk '{print $2}' 2> /dev/null)
 
     v3api=`juju config keystone  preferred-api-version`