add vm and role for regtest

Change-Id: I721ef92338478010048b9bbfecf0486ced95ce3b
This commit is contained in:
Jerry Zhao 2015-03-26 17:05:22 +00:00
parent 670c90c2b8
commit 03d782f728
10 changed files with 226 additions and 16 deletions

23
Vagrantfile vendored
View File

@ -1,15 +1,28 @@
Vagrant.configure("2") do |config|
config.vm.define :test_vm do |test_vm|
test_vm.vm.box = "precise64"
test_vm.vm.network :private_network, :ip=>"10.1.0.11", :libvirt__dhcp_enabled=>false
test_vm.vm.provider :libvirt do |domain|
config.vm.define :compass_vm do |compass_vm|
compass_vm.vm.box = "precise64"
compass_vm.vm.network :private_network, :ip=>"10.1.0.11", :libvirt__dhcp_enabled=>false
compass_vm.vm.provider :libvirt do |domain|
domain.memory = 2048
domain.cpus =2
domain.nested =true
domain.graphics_ip="0.0.0.0"
end
test_vm.vm.provision "ansible" do |ansible|
compass_vm.vm.provision "ansible" do |ansible|
ansible.playbook="install/allinone_nochef.yml"
end
end
config.vm.define :regtest_vm do |regtest_vm|
regtest_vm.vm.box = "centos65"
regtest_vm.vm.network :private_network, :ip=>"10.1.0.253", :libvirt__dhcp_enabled=>false
regtest_vm.vm.provider :libvirt do |domain|
domain.memory = 1024
domain.cpus = 2
domain.nested = true
domain.graphics_ip="0.0.0.0"
end
regtest_vm.vm.provision "ansible" do |ansible|
ansible.playbook="install/regtest.yml"
end
end
end

View File

@ -7,7 +7,7 @@ function mac_address_part() {
}
function mac_address() {
echo "00:00:$(mac_address_part):$(mac_address_part):$(mac_address_part):$(mac_address_part)"
echo "'00:00:$(mac_address_part):$(mac_address_part):$(mac_address_part):$(mac_address_part)'"
}
machines=''
@ -17,7 +17,7 @@ for i in `seq $1`; do
if [[ -z $machines ]]; then
machines="${mac}"
else
machines="${machines}, ${mac}"
machines="${machines} ${mac}"
fi
done
echo ${machines}

83
ci/test.sh Normal file
View File

@ -0,0 +1,83 @@
sudo apt-get update -y
sudo apt-get install git python-pip python-dev -y
vagrant_pkg_url=https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
wget ${vagrant_pkg_url}
sudo dpkg -i $(basename ${vagrant_pkg_url})
sudo apt-get install libxslt-dev libxml2-dev libvirt-dev build-essential qemu-utils qemu-kvm libvirt-bin virtinst -y
sudo service libvirt-bin restart
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-mutate
precise_box_vb_url=https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box
precise_box_vb_filename=$(basename ${precise_box_vb_url})
centos65_box_vb_url=https://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.5-x86_64-v20140504.box
centos65_box_vb_filename=$(basename ${centos65_box_vb_url})
wget ${precise_box_vb_url}
wget ${centos65_box_vb_url}
mv ${precise_box_vb_filename} precise64.box
mv ${centos65_box_vb_filename} centos65.box
vagrant mutate precise64.box libvirt
vagrant mutate centos65.box libvirt
sudo pip install ansible
git clone http://git.openstack.org/stackforge/compass-install
cd compass-install
function join { local IFS="$1"; shift; echo "$*"; }
if [[ ! -z $VIRT_NUMBER ]]; then
mac_array=$(ci/mac_generator.sh $VIRT_NUMBER)
mac_list=$(join , $mac_array)
echo "pxe_boot_macs: [${mac_list}]" >> install/group_vars/all
echo "test: true" >> install/group_vars/all
fi
sudo vagrant up compass_vm
if [[ $? != 0 ]]; then
sudo vagrant provision compass_vm
if [[ $? != 0 ]]; then
echo "provisioning of compass failed"
exit 1
fi
fi
echo "compass is up"
if [[ -n $mac_array ]]
echo "bringing up pxe boot vms"
i=0
for mac in "$mac_array"; do
echo "creating vm disk for instance pxe${i}"
sudo qemu-img create -f raw /home/pxe${i}.raw ${VIRT_DISK}
sudo virt-install --accelerate --hvm --connect qemu:///system \
--name pxe$i --ram=$VIRT_MEM --pxe --disk /home/pxe$i.raw,format=raw \
--vcpus=$VIRT_CPUS --graphics vnc,listen=0.0.0.0 \
--network=bridge:virbr2,mac=$mac \
--network=bridge:virbr2
--network=bridge:virbr2
--network=bridge:virbr2
--noautoconsole --autostart --os-type=linux --os-variant=rhel6
if [[ $? != 0 ]]; then
echo "launching pxe${i} failed"
exit 1
fi
echo "checking pxe${i} state"
state=$(virsh domstate pxe${i})
if [[ "$state" == "running" ]]; then
echo "pxe${i} is running"
sudo virsh destroy pxe${i}
fi
echo "add network boot option and make pxe${i} reboot if failing"
sudo sed -i "/<boot dev='hd'\/>/ a\ <boot dev='network'\/>" /etc/libvirt/qemu/pxe${i}.xml
sudo sed -i "/<boot dev='network'\/>/ a\ <bios useserial='yes' rebootTimeout='0'\/>" /etc/libvirt/qemu/pxe${i}.xml
sudo virsh define pxe${i}
sudo virsh start pxe${i}
let i=i+1
done
fi
sudo vagrant up regtest_vm
if [[ $? != 0 ]]; then
sudo vagrant provision regtest_vm
if [[ $? != 0 ]]; then
echo "deployment of cluster failed"
exit 1
fi
fi
echo "deployment of cluster complete"

View File

@ -1,6 +1,6 @@
---
- hosts: allinone
- hosts: compass_vm
sudo: True
roles:
- common

View File

@ -5,8 +5,8 @@ rebuild: True
# Auto-generated IP values
chef_server: "10.145.89.139"
cobbler_server: "10.145.89.139"
compass-server: "10.145.89.139"
cobbler_server: "10.1.0.11"
compass-server: "10.1.0.11"
# Auto-generated
dockerized_cobbler: True
@ -43,16 +43,16 @@ compass0_router: "192.168.100.1"
compass0_dhcp_range: "192.168.100.150 192.168.100.160"
# management subnet ip of the cluster you want to deploy
mgmt_subnet_ip: "10.145.88.0"
mgmt_subnet_ip: "10.1.0.11"
# management subnet router ip
mgmt_router: "10.145.88.1"
mgmt_router: "10.1.0.1"
# management subnet subnet mask
mgmt_subnet_mask: "255.255.254.0"
mgmt_subnet_mask: "255.255.255.0"
# management subnet dhcp range
mgmt_dhcp_range: "10.145.88.10 10.145.89.150"
mgmt_dhcp_range: "10.1.0.100 10.1.0.150"
@ -171,5 +171,5 @@ docker_apt_key_server: hkp://keyserver.ubuntu.com:80
docker_apt_key: 36A1D7869245C8950F966E92D8576A8BA88D21E9
# pxe boot macs
pxe_boot_macs: ['00:00:37:ed:95:4e', '00:00:79:ad:ce:6b', '00:00:0a:f6:6e:d7']
test: true
#pxe_boot_macs: ['00:00:37:ed:95:4e', '00:00:79:ad:ce:6b', '00:00:0a:f6:6e:d7']
#test: true

45
install/regtest.yml Normal file
View File

@ -0,0 +1,45 @@
---
- hosts: regtest_vm
sudo: True
roles:
- regtest-compass
# - regtest-ansible-openstack
vars:
- COMPASS_PATH: "/opt/compass-core"
- COMPASS_SERVER_URL: "http://10.1.0.11:5000/api"
- COMPASS_USER_EMAIL: "admin@huawei.com"
- COMPASS_USER_PASSWORD: "admin"
- CLUSTER_NAME: "opnfv"
- LANGUAGE: "EN"
- TIMEZONE: "America/Los_Angeles"
- HOSTNAMES: "allinone"
- NTP_SERVER: "10.1.0.11"
- NAMESERVERS: "10.1.0.11"
- DOMAIN: "ods.com"
- PARTITIONS: "/home=5%,/tmp=5%,/var=20%"
- SUBNETS: "10.1.0.0/24,172.16.2.0/24,172.16.3.0/24,172.16.4.0/24"
- ADAPTER_OS_PATTERN: '"(?i)ubuntu-14\.04.*"'
- ADAPTER_NAME: "os_only"
- ADAPTER_TARGET_SYSTEM_PATTERN: ""
- ADAPTER_FLAVOR_PATTERN: ""
- PROXY: ""
- IGNORE_PROXY: ""
- SEARCH_PATH: "ods.com"
- GATEWAY: "10.1.0.1"
- SERVER_CREDENTIAL: "root"
- LOCAL_REPO_URL: ""
- OS_CONFIG_FILENAME: ""
- SERVICE_CREDENTIALS: "service"
- CONSOLE_CREDENTIALS: "console"
- HOST_NETWORKS: "allinone:eth0=10.1.0.100|is_mgmt,eth1=172.16.2.100,eth2=172.16.3.100,eth3=172.16.4.100"
- NETWORK_MAPPING: "management=eth0,tenant=eth1,storage=eth3,external=eth2"
- PACKAGE_CONFIG_FILENAME: ""
- HOST_ROLES: ""
- DEFAULT_ROLES: ""
- SWITCH_IPS: "1.1.1.1"
- MACHINES: ""
- SWITCH_CREDENTIAL: "version=2c,community=public"
- DEPLOYMENT_TIMEOUT: "90"
- POLL_SWITCHES_FLAG: "nopoll_switches"
- DASHBOARD_URL: ""

View File

@ -108,6 +108,8 @@
- name: fork image and run a new cobbler container
shell: docker run --name=cobbler-dev -d {{ cobbler_port_mapping }} {{ image_volume_mapping }} -i -t cobbler
notify:
restart dhcp-relay
- name: extract cobbler ip info
shell: echo `docker inspect cobbler-dev | awk -F '"' '/IPAdd/ {print $4}'` > /tmp/ip

View File

@ -0,0 +1,5 @@
DEFAULT_LOGLEVEL = 'info'
DEFAULT_LOGDIR = '/var/log/compass'
DEFAULT_LOGINTERVAL = 6
DEFAULT_LOGINTERVAL_UNIT = 'h'
DEFAULT_LOGFORMAT = '%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s'

View File

@ -0,0 +1,45 @@
---
- name: install essentials
yum: name={{ item }} state=present
with_items:
- git
- python-setuptools
- python-devel
- mysql-devel
- name: install pip
easy_install: name=pip
- name: install virtualenv
pip: name=virtualenv
- name: cloning compass-core
git: repo=http://git.openstack.org/stackforge/compass-core.git
dest={{ COMPASS_PATH }}
version=dev/experimental
- name: pip install compass into virtualenv
pip: name={{ COMPASS_PATH }} virtualenv={{ COMPASS_PATH }}/venv
- name: write compass setting file
copy: src=setting dest=/etc/compass/setting
- name: create log dir
file: path=/var/log/compass state=directory
- name: write python home into switch virtualenv
lineinfile: dest={{ COMPASS_PATH }}/bin/switch_virtualenv.py.template
regexp="^virtual\_env\ \=\ \'\$PythonHome\'"
line="virtual_env = '/opt/compass-core/venv'"
- name: rename switch_virtualenv template
command: mv {{ COMPASS_PATH }}/bin/switch_virtualenv.py.template {{ COMPASS_PATH }}/bin/switch_virtualenv.py
- name: copy client script
template: src=client.sh.j2 dest=/opt/client.sh mode=0755
- name: initiate deployment
shell: /opt/client.sh > /var/log/regtest.log
async: 360
poll: 60

View File

@ -0,0 +1,17 @@
{{ COMPASS_PATH }}/bin/client.py --logfile= --loglevel=debug --logdir= --compass_server={{ COMPASS_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 }} \
--adapter_os_pattern={{ ADAPTER_OS_PATTERN }} --adapter_name={{ ADAPTER_NAME }} \
--adapter_target_system_pattern={{ ADAPTER_TARGET_SYSTEM_PATTERN }} \
--adapter_flavor_pattern={{ ADAPTER_FLAVOR_PATTERN }} \
--http_proxy={{ PROXY }} --https_proxy={{ PROXY }} --no_proxy={{ IGNORE_PROXY }} \
--ntp_server={{ NTP_SERVER }} --dns_servers={{ NAMESERVERS }} --domain={{ DOMAIN }} \
--search_path={{ SEARCH_PATH }} --default_gateway={{ GATEWAY }} \
--server_credential={{ SERVER_CREDENTIAL }} --local_repo_url={{ LOCAL_REPO_URL }} \
--os_config_json_file={{ OS_CONFIG_FILENAME }} --service_credentials={{ SERVICE_CREDENTIALS }} \
--console_credentials={{ CONSOLE_CREDENTIALS }} --host_networks={{ HOST_NETWORKS }} \
--network_mapping={{ NETWORK_MAPPING }} --package_config_json_file={{ PACKAGE_CONFIG_FILENAME }} \
--host_roles={{ HOST_ROLES }} --default_roles={{ DEFAULT_ROLES }} --switch_ips={{ SWITCH_IPS }} \
--machines={{ pxe_boot_macs |join(',') }} --switch_credential={{ SWITCH_CREDENTIAL }} \
--deployment_timeout={{ DEPLOYMENT_TIMEOUT }} --${POLL_SWITCHES_FLAG} --dashboard_url={{ DASHBOARD_URL }}