summaryrefslogtreecommitdiffstats
path: root/compass-deck/misc/ci
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2017-11-01 11:56:50 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2017-11-03 11:48:46 +0800
commit905b0231e93ce2409a45dd6c4f5f983689fdb790 (patch)
tree8b3c8c78773194e048072368fe793135a05e44f1 /compass-deck/misc/ci
parent3656ab7b5e3f2f26f7c98f9dcc97b3c461fa2a76 (diff)
Add compass-deck
RESTful API and DB Handlers for Compass Change-Id: I1ce411f279943764c286ea48dca9185d453cf254 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
Diffstat (limited to 'compass-deck/misc/ci')
-rwxr-xr-xcompass-deck/misc/ci/prepare_node_compass.sh28
-rwxr-xr-xcompass-deck/misc/ci/pxe-deploy.sh14
-rwxr-xr-xcompass-deck/misc/ci/pxe-prepare.sh29
-rwxr-xr-xcompass-deck/misc/ci/tempest_run.sh81
-rwxr-xr-xcompass-deck/misc/ci/test-install.sh22
5 files changed, 174 insertions, 0 deletions
diff --git a/compass-deck/misc/ci/prepare_node_compass.sh b/compass-deck/misc/ci/prepare_node_compass.sh
new file mode 100755
index 0000000..b9c40db
--- /dev/null
+++ b/compass-deck/misc/ci/prepare_node_compass.sh
@@ -0,0 +1,28 @@
+#!/bin/bash -x
+echo 0 > /selinux/enforce
+yum clean all
+yum -y update --skip-broken
+yum install -y virt-install libvirt qemu-kvm figlet rsyslog logrotate iproute openssh-clients python git wget python-setuptools python-netaddr python-flask python-flask-sqlalchemy python-amqplib amqp python-paramiko python-mock dhcp bind rsync yum-utils xinetd tftp-server gcc net-snmp-utils net-snmp net-snmp-python python-daemon unzip openssl openssl098e createrepo mkisofs python-cheetah python-simplejson python-urlgrabber PyYAML Django cman debmirror pykickstart libxml2-devel libxslt-devel python-devel sshpass bc
+service libvirtd start
+sed -i "s/Defaults requiretty/#Defaults requiretty/" /etc/sudoers
+brctl show |grep installation > /dev/null
+if [[ $? -eq 0 ]] ; then
+ echo "bridge already exists"
+else
+ brctl addbr installation
+ brctl addif installation eth1
+ ifconfig eth1 up
+ dhclient -r eth1
+ dhclient -r installation
+ dhclient installation
+fi
+git clone http://git.openstack.org/openstack/compass-core -b dev/experimental ||exit $?
+cd compass-core
+source install/install.conf.template
+source install/install.conf
+source install/setup_env.sh
+source install/dependency.sh
+source install/prepare.sh
+sync
+sleep 5
+echo "image preparation done"
diff --git a/compass-deck/misc/ci/pxe-deploy.sh b/compass-deck/misc/ci/pxe-deploy.sh
new file mode 100755
index 0000000..545c95a
--- /dev/null
+++ b/compass-deck/misc/ci/pxe-deploy.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -xe
+ln -s /var/log/cobbler/anamon cobbler_logs
+ln -s /var/log/compass compass_logs
+ln -s /var/log/chef chef_logs
+cp compass-core/compass/apiclient/example.py /tmp/test.py
+chmod +x /tmp/test.py
+virsh destroy pxe01
+virsh start pxe01
+virsh list
+source compass-core/install/install.conf.template
+/usr/bin/python /tmp/test.py
+if [ "$tempest" == "true" ]; then
+ ./tempest_run.sh
+fi
diff --git a/compass-deck/misc/ci/pxe-prepare.sh b/compass-deck/misc/ci/pxe-prepare.sh
new file mode 100755
index 0000000..08f5eb3
--- /dev/null
+++ b/compass-deck/misc/ci/pxe-prepare.sh
@@ -0,0 +1,29 @@
+#!/bin/bash -x
+if [[ ! -e /tmp/pxe01.raw ]]; then
+ qemu-img create -f raw /tmp/pxe01.raw 20G
+else
+ rm -rf /tmp/pxe01.raw
+ qemu-img create -f raw /tmp/pxe01.raw 20G
+fi
+virsh list |grep pxe01
+vmrc=$?
+if [[ $vmrc -eq 0 ]] ; then
+ virsh destroy pxe01
+ virsh undefine pxe01
+else
+ echo "no legacy pxe vm found"
+fi
+virt-install --accelerate --hvm --connect qemu:///system \
+ --network=bridge:installation,mac=00:11:20:30:40:01 --pxe \
+ --network=network:default \
+ --name pxe01 --ram=8192 \
+ --disk /tmp/pxe01.raw,format=raw \
+ --vcpus=10 \
+ --graphics vnc,listen=0.0.0.0 --noautoconsole \
+ --os-type=linux --os-variant=rhel6
+rm -rf switch-file
+echo "machine,10.145.81.220,5,1,00:11:20:30:40:01" > switch-file
+echo "switch,10.145.81.220,huawei,v2c,public,under_monitoring" >> switch-file
+/usr/bin/python /opt/compass/bin/manage_db.py set_switch_machines --switch_machines_file switch-file
+/usr/bin/python /opt/compass/bin/manage_db.py clean_clusters
+/usr/bin/python /opt/compass/bin/manage_db.py clean_installation_progress
diff --git a/compass-deck/misc/ci/tempest_run.sh b/compass-deck/misc/ci/tempest_run.sh
new file mode 100755
index 0000000..7ac2212
--- /dev/null
+++ b/compass-deck/misc/ci/tempest_run.sh
@@ -0,0 +1,81 @@
+#!/bin/bash -xe
+# Determinate is the given option present in the INI file
+# ini_has_option config-file section option
+function ini_has_option {
+ local xtrace=$(set +o | grep xtrace)
+ set +o xtrace
+ local file=$1
+ local section=$2
+ local option=$3
+ local line
+ line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
+ $xtrace
+ [ -n "$line" ]
+}
+# Set an option in an INI file
+# iniset config-file section option value
+function iniset {
+ local xtrace=$(set +o | grep xtrace)
+ set +o xtrace
+ local file=$1
+ local section=$2
+ local option=$3
+ local value=$4
+
+ [[ -z $section || -z $option ]] && return
+
+ if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then
+ # Add section at the end
+ echo -e "\n[$section]" >>"$file"
+ fi
+ if ! ini_has_option "$file" "$section" "$option"; then
+ # Add it
+ sed -i -e "/^\[$section\]/ a\\
+$option = $value
+" "$file"
+ else
+ local sep=$(echo -ne "\x01")
+ # Replace it
+ sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
+ fi
+ $xtrace
+}
+#Install prerequites for Tempest
+pip install tox==1.6.1
+#Install setuptools twice so that it is really upgraded
+pip install -U setuptools
+pip install -U setuptools
+pip install -U virtualenvwrapper
+yum install -y libxml2-devel libxslt-devel python-devel sshpass
+if [[ ! -e /tmp/tempest ]]; then
+ git clone http://git.openstack.org/openstack/tempest /tmp/tempest
+ cd /tmp/tempest
+else
+ cd /tmp/tempest
+ git remote set-url origin http://git.openstack.org/openstack/tempest
+ git remote update
+ git reset --hard
+ git clean -x -f -d -q
+ git checkout remotes/origin/master
+fi
+source `which virtualenvwrapper.sh`
+set +e
+if ! lsvirtualenv |grep tempest>/dev/null; then
+ mkvirtualenv tempest
+ workon tempest
+else
+ workon tempest
+fi
+set -e
+cd /tmp/tempest
+#Install Tempest including dependencies
+pip install -e .
+nova_api_host=$(knife search node 'roles:os-compute-api' | grep 'IP:' | awk '{print $2}' | head -1)
+sshpass -p 'root' scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r root@$nova_api_host:/root/openrc /root/.
+source /root/openrc
+# wait for nova-compute neutron-agent and cinder-volume to report health
+# In some scenarios, nova-compute is up before conductor and has to retry
+# to register to conductor and there is some wait time between retries.
+timeout 180s sh -c "while ! nova service-list --binary nova-compute | grep 'enabled.*\ up\ '; do sleep 3; done"
+timeout 180s sh -c '''while ! neutron agent-list -f csv -c alive -c agent_type -c host | grep "\":-).*Open vSwitch agent.*\"" ; do sleep 3; done'''
+timeout 180s sh -c "cinder service-list --binary cinder-volume | grep 'enabled.*\ up\ '"
diff --git a/compass-deck/misc/ci/test-install.sh b/compass-deck/misc/ci/test-install.sh
new file mode 100755
index 0000000..22fd5d4
--- /dev/null
+++ b/compass-deck/misc/ci/test-install.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -x
+# create a bridge named 'installation' so that compass and pxeboot vm are in the
+# same l2 network.
+brctl show |grep installation > /dev/null
+if [[ $? -eq 0 ]] ; then
+ echo "bridge already exists"
+else
+ brctl addbr installation
+ brctl addif installation eth1
+fi
+
+ifconfig installation 172.16.0.1 broadcast 172.16.0.0 netmask 255.255.0.0 up
+ifconfig eth1 up
+
+# kill the dhcp service started by libvirt to avoid conflict with dhcpd
+killall dnsmasq
+source compass-core/install/install.conf.template
+/bin/bash -x compass-core/install/install.sh || exit $?
+# echo "cache_peer 10.145.81.137 parent 3128 3130 default" >> /etc/squid/squid.conf
+# service squid restart
+# service squid status |grep running || exit $?
+# sleep 5