aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbuild/make_repo.sh4
-rwxr-xr-xdeploy.sh10
-rwxr-xr-xdeploy/adapters/ansible/roles/database/tasks/mongodb_config.yml4
-rw-r--r--deploy/client.py56
-rw-r--r--deploy/compass_vm.sh18
-rw-r--r--deploy/deploy_host.sh8
-rw-r--r--deploy/host_baremetal.sh8
-rw-r--r--deploy/host_virtual.sh18
-rwxr-xr-xdeploy/launch.sh75
-rwxr-xr-xdeploy/network.sh6
-rwxr-xr-xdeploy/prepare.sh13
-rw-r--r--deploy/restful.py5
-rwxr-xr-xdeploy_compass.sh3
-rwxr-xr-xdeploy_compass_only.sh3
-rwxr-xr-xdeploy_host.sh3
-rwxr-xr-xdeploy_host_only.sh3
-rwxr-xr-xredeploy_host.sh3
17 files changed, 156 insertions, 84 deletions
diff --git a/build/make_repo.sh b/build/make_repo.sh
index 67f2e2f2..c165c99f 100755
--- a/build/make_repo.sh
+++ b/build/make_repo.sh
@@ -163,8 +163,8 @@ function make_all_repo()
make_repo --os-ver rhel7 --package-tag compass \
--tmpl "${WORK_PATH}/build/templates/compass_core.tmpl" \
- --default-package "kernel-devel epel-release wget libxml2 glibc gcc perl openssl-libs mkisofs createrepo \
- python-yaml python-jinja2 python-paramiko elasticsearch logstash bind-license vim \
+ --default-package "kernel-devel epel-release wget libxml2 glibc gcc perl openssl-libs mkisofs createrepo lsof \
+ python-yaml python-jinja2 python-paramiko elasticsearch logstash bind-license vim nmap-ncat \
yum cobbler cobbler-web createrepo mkisofs syslinux pykickstart bind rsync fence-agents \
dhcp xinetd tftp-server httpd libselinux-python python-setuptools python-devel mysql-devel \
mysql-server mysql MySQL-python redis mod_wsgi net-tools rabbitmq-server nfs-utils" \
diff --git a/deploy.sh b/deploy.sh
index b95475b1..653eec85 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -2,18 +2,16 @@
COMPASS_DIR=`cd ${BASH_SOURCE[0]%/*}/;pwd`
export COMPASS_DIR
-if [[ -z "$DEPLOY_STEP" ]]; then
- export DEPLOY_STEP="all"
+if [[ -z $DEPLOY_COMPASS && -z $DEPLOY_HOST && -z $REDEPLOY_HOST ]]; then
+ export DEPLOY_COMPASS="true"
+ export DEPLOY_HOST="true"
fi
-for i in python-cheetah python-yaml screen; do
+for i in python-cheetah python-yaml; do
if [[ `dpkg-query -l $i` == 0 ]]; then
continue
fi
sudo apt-get install -y --force-yes $i
done
-screen -ls |grep deploy|awk -F. '{print $1}'|xargs kill -9
-screen -wipe
-#screen -dmSL deploy bash $COMPASS_DIR/ci/launch.sh $*
$COMPASS_DIR/deploy/launch.sh $*
diff --git a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
index 573b30a9..321c38d5 100755
--- a/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
+++ b/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
@@ -11,8 +11,8 @@
shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY|SECONDARY'|wc -l
register: servers
until: servers.stdout|int == 3
- retries: 20
- delay: 3
+ retries: 60
+ delay: 10
- debug: msg='{{ servers.stdout |int }}'
diff --git a/deploy/client.py b/deploy/client.py
index 1952b3ab..b9cfd7fe 100644
--- a/deploy/client.py
+++ b/deploy/client.py
@@ -228,6 +228,9 @@ opts = [
cfg.StrOpt('deploy_type',
help='deploy type',
default='virtual'),
+ cfg.StrOpt('deploy_flag',
+ help='deploy flag',
+ default='deploy'),
]
CONF.register_cli_opts(opts)
@@ -279,9 +282,9 @@ class CompassClient(object):
def get_machines(self):
status, resp = self.client.list_machines()
- LOG.info(
- 'get all machines status: %s, resp: %s', status, resp)
if not self.is_ok(status):
+ LOG.error(
+ 'get all machines status: %s, resp: %s', status, resp)
raise RuntimeError('failed to get machines')
machines_to_add = list(set([
@@ -289,12 +292,21 @@ class CompassClient(object):
if machine
]))
- LOG.info('machines to add: %s', machines_to_add)
machines_db = [str(m["mac"]) for m in resp]
- LOG.info('machines in db: %s', machines_db)
- assert(set(machines_db) == set(machines_to_add))
+ LOG.info('machines in db: %s\n to add: %s', machines_db, machines_to_add)
+ if not set(machines_to_add).issubset(set(machines_db)):
+ raise RuntimeError('unidentify machine to add')
+
+ return [m["id"] for m in resp if str(m["mac"]) in machines_to_add]
+
+ def list_clusters(self):
+ status, resp = self.client.list_clusters(name=CONF.cluster_name)
+ if not self.is_ok(status) or not resp:
+ raise RuntimeError('failed to list cluster')
+
+ cluster = resp[0]
- return [m["id"] for m in resp]
+ return cluster['id']
def get_adapter(self):
"""get adapter."""
@@ -806,6 +818,18 @@ class CompassClient(object):
if not self.is_ok(status):
raise RuntimeError("deploy cluster failed")
+ def redeploy_clusters(self, cluster_id):
+ status, response = self.client.redeploy_cluster(
+ cluster_id
+ )
+
+ if not self.is_ok(status):
+ LOG.info(
+ 'deploy cluster %s status %s: %s',
+ cluster_id, status, response
+ )
+ raise RuntimeError("redeploy cluster failed")
+
def get_installing_progress(self, cluster_id):
"""get intalling progress."""
action_timeout = time.time() + 60 * float(CONF.action_timeout)
@@ -862,7 +886,8 @@ class CompassClient(object):
raise Exception(msg)
-def main():
+
+def deploy():
client = CompassClient()
machines = client.get_machines()
@@ -885,6 +910,23 @@ def main():
client.get_installing_progress(cluster_id)
client.check_dashboard_links(cluster_id)
+def redeploy():
+ client = CompassClient()
+
+ cluster_id = client.list_clusters()
+
+ client.redeploy_clusters(cluster_id)
+
+ client.get_installing_progress(cluster_id)
+ client.check_dashboard_links(cluster_id)
+
+def main():
+ if CONF.deploy_flag == "redeploy":
+ redeploy()
+ else:
+ deploy()
+
+
if __name__ == "__main__":
CONF(args=sys.argv[1:])
main()
diff --git a/deploy/compass_vm.sh b/deploy/compass_vm.sh
index 71d9ad6c..5b94b603 100644
--- a/deploy/compass_vm.sh
+++ b/deploy/compass_vm.sh
@@ -14,14 +14,26 @@ function tear_down_compass() {
}
function install_compass_core() {
+ install_compass "compass_nodocker.yml"
+}
+
+function set_compass_machine() {
+ local config_file=$WORK_DIR/installer/compass-install/install/group_vars/all
+
+ sed -i -e '/test: true/d' -e '/pxe_boot_macs/d' $config_file
+ echo "test: true" >> $config_file
+ echo "pxe_boot_macs: [${machines}]" >> $config_file
+
+ install_compass "compass_machine.yml"
+}
+
+function install_compass() {
local inventory_file=$compass_vm_dir/inventory.file
- log_info "install_compass_core enter"
sed -i "s/mgmt_next_ip:.*/mgmt_next_ip: ${COMPASS_SERVER}/g" $WORK_DIR/installer/compass-install/install/group_vars/all
echo "compass_nodocker ansible_ssh_host=$MGMT_IP ansible_ssh_port=22" > $inventory_file
- PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s' python /usr/local/bin/ansible-playbook -e pipeline=true --private-key=$rsa_file --user=root --connection=ssh --inventory-file=$inventory_file $WORK_DIR/installer/compass-install/install/compass_nodocker.yml
+ PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s' python /usr/local/bin/ansible-playbook -e pipeline=true --private-key=$rsa_file --user=root --connection=ssh --inventory-file=$inventory_file $WORK_DIR/installer/compass-install/install/$1
exit_status=$?
rm $inventory_file
- log_info "install_compass_core exit"
if [[ $exit_status != 0 ]];then
/bin/false
fi
diff --git a/deploy/deploy_host.sh b/deploy/deploy_host.sh
index e7dedb89..be392d71 100644
--- a/deploy/deploy_host.sh
+++ b/deploy/deploy_host.sh
@@ -5,7 +5,13 @@ function deploy_host(){
reboot_hosts
- python ${COMPASS_DIR}/deploy/client.py --compass_server="${HTTP_SERVER_URL}" \
+ if [[ "$REDEPLOY_HOST" == true ]]; then
+ deploy_flag="redeploy"
+ else
+ deploy_flag="deploy"
+ fi
+
+ python ${COMPASS_DIR}/deploy/client.py --deploy_flag=$deploy_flag --compass_server="${HTTP_SERVER_URL}" \
--compass_user_email="${COMPASS_USER_EMAIL}" --compass_user_password="${COMPASS_USER_PASSWORD}" \
--cluster_name="${CLUSTER_NAME}" --language="${LANGUAGE}" --timezone="${TIMEZONE}" \
--hostnames="${HOSTNAMES}" --partitions="${PARTITIONS}" --subnets="${SUBNETS}" \
diff --git a/deploy/host_baremetal.sh b/deploy/host_baremetal.sh
index 9e25c98d..0210cee8 100644
--- a/deploy/host_baremetal.sh
+++ b/deploy/host_baremetal.sh
@@ -6,10 +6,6 @@ function reboot_hosts() {
}
function get_host_macs() {
- local config_file=$WORK_DIR/installer/compass-install/install/group_vars/all
- echo "test: true" >> $config_file
- machine=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'`
- echo "pxe_boot_macs: [$machine]" >> $config_file
-
- echo $machine
+ machines=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'`
+ echo $machines
}
diff --git a/deploy/host_virtual.sh b/deploy/host_virtual.sh
index 4cb33613..c7e5f84e 100644
--- a/deploy/host_virtual.sh
+++ b/deploy/host_virtual.sh
@@ -1,10 +1,13 @@
host_vm_dir=$WORK_DIR/vm
function tear_down_machines() {
+ old_ifs=$IFS
+ IFS=,
for i in $HOSTNAMES; do
sudo virsh destroy $i
sudo virsh undefine $i
rm -rf $host_vm_dir/$i
done
+ IFS=$old_ifs
}
function reboot_hosts() {
@@ -14,7 +17,6 @@ function reboot_hosts() {
function launch_host_vms() {
old_ifs=$IFS
IFS=,
- tear_down_machines
#function_bod
mac_array=($machines)
log_info "bringing up pxe boot vms"
@@ -44,16 +46,18 @@ function launch_host_vms() {
}
function get_host_macs() {
- local config_file=$WORK_DIR/installer/compass-install/install/group_vars/all
local mac_generator=${COMPASS_DIR}/deploy/mac_generator.sh
local machines=
- chmod +x $mac_generator
- mac_array=`$mac_generator $VIRT_NUMBER`
- machines=`echo $mac_array|sed 's/ /,/g'`
+ if [[ $REDEPLOY_HOST == "true" ]]; then
+ mac_array=`cat $WORK_DIR/switch_machines`
+ else
+ chmod +x $mac_generator
+ mac_array=`$mac_generator $VIRT_NUMBER`
+ echo $mac_array > $WORK_DIR/switch_machines
+ fi
- echo "test: true" >> $config_file
- echo "pxe_boot_macs: [${machines}]" >> $config_file
+ machines=`echo $mac_array|sed 's/ /,/g'`
echo $machines
}
diff --git a/deploy/launch.sh b/deploy/launch.sh
index 273e27a9..7160612f 100755
--- a/deploy/launch.sh
+++ b/deploy/launch.sh
@@ -18,67 +18,56 @@ source ${COMPASS_DIR}/deploy/compass_vm.sh
source ${COMPASS_DIR}/deploy/deploy_host.sh
######################### main process
-old_ifs=$IFS
-IFS=,
-tear_down_machines
-IFS=$old_ifs
+print_logo
-if [[ "$DEPLOY_STEP" == "compass_only" || "$DEPLOY_STEP" == "all" ]]
-then
-if ! prepare_env;then
- echo "prepare_env failed"
- exit 1
+if [[ ! -z $VIRT_NUMBER ]];then
+ tear_down_machines
fi
log_info "########## get host mac begin #############"
machines=`get_host_macs`
-if [[ -z $machines ]];then
+if [[ -z $machines ]]; then
log_error "get_host_macs failed"
exit 1
fi
-log_info "deploy host macs: $machines"
export machines
-echo "export machines=\""$machines"\"" > $WORK_DIR/switch_machines
-log_info "########## set up network begin #############"
-if ! create_nets;then
- log_error "create_nets failed"
- exit 1
-fi
-if ! launch_compass;then
- log_error "launch_compass failed"
- exit 1
-fi
+if [[ "$DEPLOY_COMPASS" == "true" ]]; then
+ if ! prepare_env;then
+ echo "prepare_env failed"
+ exit 1
+ fi
-else
+ log_info "########## set up network begin #############"
+ if ! create_nets;then
+ log_error "create_nets failed"
+ exit 1
+ fi
-# test code
-if [[ -f $WORK_DIR/switch_machines ]]; then
- echo "using last generated machines"
- source $WORK_DIR/switch_machines
-else
- export machines="'00:00:3d:a4:ee:4c','00:00:63:35:3c:2b','00:00:f2:f2:b7:a5','00:00:2f:d3:88:28','00:00:46:67:11:e7'"
+ if ! launch_compass;then
+ log_error "launch_compass failed"
+ exit 1
+ fi
fi
+if [[ -z "$REDEPLOY_HOST" || "$REDEPLOY_HOST" == "false" ]]; then
+ if ! set_compass_machine; then
+ log_error "set_compass_machine fail"
+ fi
fi
-if [[ "$DEPLOY_STEP" == "host_only" || "$DEPLOY_STEP" == "all" ]]; then
+if [[ "$DEPLOY_HOST" == "true" || $REDEPLOY_HOST == "true" ]]; then
+ if [[ ! -z $VIRT_NUMBER ]];then
+ if ! launch_host_vms;then
+ log_error "launch_host_vms failed"
+ exit 1
+ fi
+ fi
-if [[ ! -z $VIRT_NUMBER ]];then
- if ! launch_host_vms;then
- log_error "launch_host_vms failed"
- exit 1
+ if ! deploy_host;then
+ exit 1
fi
fi
-if ! deploy_host;then
- #tear_down_machines
- #tear_down_compass
- exit 1
-else
- #tear_down_machines
- #tear_down_compass
- exit 0
-fi
-fi
+figlet -ctf slant Installation Complete!
diff --git a/deploy/network.sh b/deploy/network.sh
index 836af0f9..c6d0df5d 100755
--- a/deploy/network.sh
+++ b/deploy/network.sh
@@ -1,4 +1,9 @@
+function clear_forward_rejct_rules()
+{
+ while sudo iptables -nL FORWARD --line-number|grep -E 'REJECT +all +-- +0.0.0.0/0 +0.0.0.0/0 +reject-with icmp-port-unreachable'|head -1|awk '{print $1}'|xargs sudo iptables -D FORWARD; do :; done
+}
+
function setup_bridge_net()
{
net_name=$1
@@ -89,4 +94,5 @@ function create_nets() {
# create external network
setup_bridge_external
+ clear_forward_rejct_rules
}
diff --git a/deploy/prepare.sh b/deploy/prepare.sh
index e8b2103e..f1aacd98 100755
--- a/deploy/prepare.sh
+++ b/deploy/prepare.sh
@@ -1,4 +1,16 @@
+function print_logo()
+{
+ if ! apt --installed list 2>/dev/null | grep "figlet"
+ then
+ sudo apt-get update -y
+ sudo apt-get install -y --force-yes figlet
+ fi
+
+ figlet -ctf slant Compass Installer
+ set +x; sleep 2; set -x
+}
+
function download_iso()
{
iso_name=`basename $ISO_URL`
@@ -15,7 +27,6 @@ function download_iso()
curl --connect-timeout 10 -o $WORK_DIR/cache/$iso_name $ISO_URL
}
-
function prepare_env() {
export PYTHONPATH=/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages
sudo apt-get update -y
diff --git a/deploy/restful.py b/deploy/restful.py
index 4d86da82..44e461c4 100644
--- a/deploy/restful.py
+++ b/deploy/restful.py
@@ -647,6 +647,11 @@ class Client(object):
data['deploy'] = deploy
return self._post('/clusters/%s/action' % cluster_id, data=data)
+ def redeploy_cluster(self, cluster_id):
+ data = {}
+ data['redeploy'] = {}
+ return self._post('/clusters/%s/action' % cluster_id, data=data)
+
def get_cluster_state(self, cluster_id):
return self._get('/clusters/%s/state' % cluster_id)
diff --git a/deploy_compass.sh b/deploy_compass.sh
new file mode 100755
index 00000000..a92ecea2
--- /dev/null
+++ b/deploy_compass.sh
@@ -0,0 +1,3 @@
+export DEPLOY_COMPASS=${DEPLOY_COMPASS-"true"}
+
+./deploy.sh $*
diff --git a/deploy_compass_only.sh b/deploy_compass_only.sh
deleted file mode 100755
index 8cb31eb8..00000000
--- a/deploy_compass_only.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-export DEPLOY_STEP="compass_only"
-
-./deploy.sh $*
diff --git a/deploy_host.sh b/deploy_host.sh
new file mode 100755
index 00000000..1272aee0
--- /dev/null
+++ b/deploy_host.sh
@@ -0,0 +1,3 @@
+export DEPLOY_HOST=${DEPLOY_HOST-"true"}
+
+./deploy.sh $*
diff --git a/deploy_host_only.sh b/deploy_host_only.sh
deleted file mode 100755
index accade38..00000000
--- a/deploy_host_only.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-export DEPLOY_STEP="host_only"
-
-./deploy.sh $*
diff --git a/redeploy_host.sh b/redeploy_host.sh
new file mode 100755
index 00000000..9ae02fc7
--- /dev/null
+++ b/redeploy_host.sh
@@ -0,0 +1,3 @@
+export REDEPLOY_HOST=${REDEPLOY_HOST-"true"}
+
+./deploy.sh $*