summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-11-21 15:29:11 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2018-01-19 14:39:32 +0800
commit4956657410d57861f9157167a291aefc437d9218 (patch)
treed878afd06be85dc2d4e6f4cbb75f5ffbf40b7e33 /deploy
parent522bce77aee6680a977fa7d0acac3d4091202377 (diff)
Support multi-cluster deploy
JIRA: COMPASS-566 1. set DEPLOY_HOST to "true "no longer refresh compass-core 2. patch depends on merged compass-tasks 3. support assign cluster name in scenario file Change-Id: I28d201c201cff5baefee9993d195be16ef1e830b Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Diffstat (limited to 'deploy')
-rw-r--r--deploy/client.py17
-rwxr-xr-xdeploy/compass_vm.sh20
-rw-r--r--deploy/conf/base.conf1
-rw-r--r--deploy/config_parse.py1
-rwxr-xr-xdeploy/launch.sh5
5 files changed, 34 insertions, 10 deletions
diff --git a/deploy/client.py b/deploy/client.py
index 910aa7f8..891e632c 100644
--- a/deploy/client.py
+++ b/deploy/client.py
@@ -399,17 +399,20 @@ class CompassClient(object):
except:
raise RuntimeError('subnet %s format is invalid' % subnet)
- if CONF.expansion == "false":
+ subnet_exist = False
+ for subnet_in_db in subnets_in_db:
+ if subnet == subnet_in_db['subnet']:
+ subnet_mapping[subnet] = subnet_in_db['id']
+ subnet_exist = True
+ break
+
+ if not subnet_exist:
status, resp = self.client.add_subnet(subnet)
LOG.info('add subnet %s status %s response %s',
subnet, status, resp)
if not self.is_ok(status):
raise RuntimeError('failed to add subnet %s' % subnet)
subnet_mapping[resp['subnet']] = resp['id']
- else:
- for subnet_in_db in subnets_in_db:
- if subnet == subnet_in_db['subnet']:
- subnet_mapping[subnet] = subnet_in_db['id']
self.subnet_mapping = subnet_mapping
@@ -475,8 +478,8 @@ class CompassClient(object):
if host['hostname'] in hostnames:
self.host_mapping[host['hostname']] = host['id']
- if CONF.expansion == "false":
- assert(len(self.host_mapping) == len(machines))
+ # if CONF.expansion == "false":
+ # assert(len(self.host_mapping) == len(machines))
def set_cluster_os_config(self, cluster_id):
"""set cluster os config."""
diff --git a/deploy/compass_vm.sh b/deploy/compass_vm.sh
index 7689f41c..cf215f3b 100755
--- a/deploy/compass_vm.sh
+++ b/deploy/compass_vm.sh
@@ -10,6 +10,26 @@
compass_vm_dir=$WORK_DIR/vm/compass
rsa_file=$compass_vm_dir/boot.rsa
ssh_args="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $rsa_file"
+
+function check_container_alive() {
+ docker exec -it compass-deck bash -c "exit" 1>/dev/null 2>&1
+ local deck_state=$?
+ docker exec -it compass-tasks bash -c "exit" 1>/dev/null 2>&1
+ local tasks_state=$?
+ docker exec -it compass-cobbler bash -c "exit" 1>/dev/null 2>&1
+ local cobbler_state=$?
+ docker exec -it compass-db bash -c "exit" 1>/dev/null 2>&1
+ local db_state=$?
+ docker exec -it compass-mq bash -c "exit" 1>/dev/null 2>&1
+ local mq_state=$?
+
+ if [ $((deck_state||tasks_state||cobbler_state||db_state||mq-state)) == 0 ]; then
+ echo "true"
+ else
+ echo "false"
+ fi
+}
+
function tear_down_compass() {
sudo virsh destroy compass > /dev/null 2>&1
sudo virsh undefine compass > /dev/null 2>&1
diff --git a/deploy/conf/base.conf b/deploy/conf/base.conf
index c2bf5291..5395405d 100644
--- a/deploy/conf/base.conf
+++ b/deploy/conf/base.conf
@@ -8,7 +8,6 @@ export EXT_NAT_GW=${EXT_NAT_GW:-192.16.1.1}
export EXT_NAT_IP_START=${EXT_NAT_IP_START:-192.16.1.3}
export EXT_NAT_IP_END=${EXT_NAT_IP_END:-192.16.1.254}
export EXTERNAL_NIC=${EXTERNAL_NIC:-eth0}
-export CLUSTER_NAME="opnfv2"
export DOMAIN="ods.com"
export PARTITIONS="/=30%,/home=5%,/tmp=5%,/var=60%"
export SUBNETS="10.1.0.0/24,172.16.2.0/24,172.16.3.0/24,172.16.4.0/24"
diff --git a/deploy/config_parse.py b/deploy/config_parse.py
index 3d8dedc5..1575ca37 100644
--- a/deploy/config_parse.py
+++ b/deploy/config_parse.py
@@ -104,6 +104,7 @@ def export_dha_file(dha, dha_file, ofile):
plugin_list.append(plugin_str)
env.update({'plugins': ','.join(plugin_list)})
+ env.update({'CLUSTER_NAME': dha.get('NAME', "opnfv")})
env.update({'TYPE': dha.get('TYPE', "virtual")})
env.update({'FLAVOR': dha.get('FLAVOR', "cluster")})
env.update({'HOSTNAMES': hostnames(dha, ',')})
diff --git a/deploy/launch.sh b/deploy/launch.sh
index 6cbad1fa..98d9e4d6 100755
--- a/deploy/launch.sh
+++ b/deploy/launch.sh
@@ -55,7 +55,8 @@ if [[ "$EXPANSION" == "false" ]]; then
export machines
- if [[ "$DEPLOY_COMPASS" == "true" ]]; then
+ CONTAINER_ALIVE=$(check_container_alive)
+ if [[ "$DEPLOY_COMPASS" == "true" && "$CONTAINER_ALIVE" == "false" ]]; then
if ! prepare_env;then
echo "prepare_env failed"
exit 1
@@ -71,7 +72,7 @@ if [[ "$EXPANSION" == "false" ]]; then
log_error "launch_compass failed"
exit 1
fi
- else
+ elif [[ "$DEPLOY_COMPASS" == "true" && "$CONTAINER_ALIVE" == "true" ]]; then
refresh_compass_core
fi
else