diff options
-rwxr-xr-x | ci/deploy/deploy.sh | 41 | ||||
-rwxr-xr-x | deploy/get_conf.py | 28 | ||||
-rw-r--r-- | deploy/tempest.py | 5 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rw-r--r-- | templates/virtual_environment/vms/computer.xml | 12 | ||||
-rw-r--r-- | templates/virtual_environment/vms/computer01.xml | 136 | ||||
-rw-r--r-- | templates/virtual_environment/vms/computer02.xml | 136 | ||||
-rw-r--r-- | templates/virtual_environment/vms/computer03.xml | 132 | ||||
-rw-r--r-- | templates/virtual_environment/vms/computer04.xml | 132 | ||||
-rw-r--r-- | templates/virtual_environment/vms/controller.xml | 12 | ||||
-rw-r--r-- | templates/virtual_environment/vms/controller01.xml | 136 | ||||
-rw-r--r-- | templates/virtual_environment/vms/controller02.xml | 136 | ||||
-rw-r--r-- | templates/virtual_environment/vms/controller03.xml | 136 | ||||
-rw-r--r-- | test-requirements.txt | 1 | ||||
-rw-r--r-- | tests/conftest.py | 17 | ||||
-rw-r--r-- | tests/data/lab_conf/deploy_virtual1.yml | 31 | ||||
-rw-r--r-- | tests/data/lab_conf/network_virtual1.yml | 69 | ||||
-rw-r--r-- | tests/unit/test_get_conf.py | 64 |
18 files changed, 246 insertions, 979 deletions
diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index f6299a1b..31382623 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -158,8 +158,15 @@ VMDEPLOY_DAISY_SERVER_VM=$WORKSPACE/templates/virtual_environment/vms/daisy.xml VMDEPLOY_TARGET_NODE_VM=$WORKSPACE/templates/virtual_environment/vms/all_in_one.xml VMDEPLOY_NODE=[] -for ((i=0;i<${#VM_MULTINODE[@]};i++));do +for ((i=0; i < ${#VM_MULTINODE[@]}; i++)); do + if [[ ${VM_MULTINODE[$i]} == *controller* ]]; then + nodename_prefix="controller" + else + nodename_prefix="computer" + fi VMDEPLOY_NODE[$i]=$WORKSPACE/templates/virtual_environment/vms/${VM_MULTINODE[$i]}.xml + cp $WORKSPACE/templates/virtual_environment/vms/${nodename_prefix}.xml ${VMDEPLOY_NODE[$i]} + sed -i "s/nodename/${VM_MULTINODE[$i]}/g" ${VMDEPLOY_NODE[$i]} echo ${VMDEPLOY_NODE[$i]} done @@ -268,25 +275,31 @@ function update_config fi } -function clean_up +function clean_up_virtual_env() { - local vm_name=$1 - local network_name=$2 + local vms=$(virsh list --all | tail -n +3 | awk '{print $2}') + local active_vms=$(virsh list | tail -n +3 | awk '{print $2}') + for vm_name in ${VM_MULTINODE[@]} all_in_one daisy; do + if [[ $(echo $vms | tr " " "\n" | grep ^$vm_name$) ]]; then + [[ $(echo $active_vms | tr " " "\n" | grep ^$vm_name$) ]] && virsh destroy $vm_name + virsh undefine $vm_name + fi + done - virsh destroy $vm_name - virsh undefine $vm_name - virsh net-destroy $network_name - virsh net-undefine $network_name + local nets=$(virsh net-list --all | tail -n +3 |awk '{print $1}') + local active_nets=$(virsh net-list | tail -n +3 |awk '{print $1}') + for net_template in ${VMDELOY_DAISY_SERVER_NET} ${VMDEPLOY_TARGET_NODE_NET} ${VMDEPLOY_TARGET_KEEPALIVED_NET}; do + network_name=$(grep "<name>" $net_template | awk -F "<|>" '{print $3}') + if [[ $(echo $nets | tr " " "\n" | grep ^$network_name$) ]]; then + [[ $(echo $active_nets | tr " " "\n" | grep ^$network_name$) ]] && virsh net-destroy $network_name + virsh net-undefine $network_name + fi + done } echo "====== clean up all node and network ======" if [ $IS_BARE == 0 ];then - clean_up all_in_one daisy2 - for ((i=0;i<${#VM_MULTINODE[@]};i++));do - virsh destroy ${VM_MULTINODE[$i]} - virsh undefine ${VM_MULTINODE[$i]} - done - clean_up daisy daisy1 + clean_up_virtual_env else virsh destroy daisy virsh undefine daisy diff --git a/deploy/get_conf.py b/deploy/get_conf.py index 1f4500a4..4d112589 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -25,8 +25,8 @@ def init(file): def decorator_mk(types): def decorator(func): - def wrapter(s): - item_list = s.get(types, []) + def wrapter(data): + item_list = data.get(types, []) result = {} for item in item_list: ret = func(item) @@ -88,15 +88,15 @@ def mac_address(host=None): return map -def network_config_parse(s, dha_file): - network_map = network(s) - vip = s.get('internal_vip') - interface_map = interface(s) +def network_config_parse(network_data): + network_map = network(network_data) + vip = network_data.get('internal_vip') + interface_map = interface(network_data) return network_map, vip, interface_map -def dha_config_parse(s, dha_file): - host_role_map = role(s) +def dha_config_parse(dha_data): + host_role_map = role(dha_data) hosts_name = [] for name in host_role_map: hosts_name.append(name) @@ -104,12 +104,12 @@ def dha_config_parse(s, dha_file): def config(dha_file, network_file): - data = init(dha_file) - ceph_disk_name = data.get('ceph_disk_name') - hosts_name = dha_config_parse(data, dha_file) - mac_address_map = mac_address(data) - data = init(network_file) - network_map, vip, interface_map = network_config_parse(data, network_file) + dha_data = init(dha_file) + ceph_disk_name = dha_data.get('ceph_disk_name') + hosts_name = dha_config_parse(dha_data) + mac_address_map = mac_address(dha_data) + network_data = init(network_file) + network_map, vip, interface_map = network_config_parse(network_data) return interface_map, hosts_name, network_map, vip, ceph_disk_name, mac_address_map diff --git a/deploy/tempest.py b/deploy/tempest.py index b154e72d..f9f9e978 100644 --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -219,10 +219,9 @@ def add_hosts_interface(cluster_id, hosts_info, hosts_name, mac_address_map, def add_host_role(cluster_id, host_id, host_exp_name, host_real_name, vip): role_meta = {'filters': {'cluster_id': cluster_id}} role_list_generator = client.roles.list(**role_meta) - role_list = [role for role in role_list_generator] - lb_role_id = [role.id for role in role_list if + lb_role_id = [role.id for role in role_list_generator if role.name == "CONTROLLER_LB"][0] - computer_role_id = [role.id for role in role_list if + computer_role_id = [role.id for role in role_list_generator if role.name == "COMPUTER"][0] if host_exp_name in ['all_in_one']: role_lb_update_meta = {'nodes': [host_id], diff --git a/requirements.txt b/requirements.txt index 7a329b1e..3d4d50be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ jsonschema paramiko pyyaml scp +oslo_config diff --git a/templates/virtual_environment/vms/computer.xml b/templates/virtual_environment/vms/computer.xml index 0add4367..d3c974ed 100644 --- a/templates/virtual_environment/vms/computer.xml +++ b/templates/virtual_environment/vms/computer.xml @@ -1,5 +1,5 @@ <domain type='kvm' id='4'> - <name>computer</name> + <name>nodename</name> <memory unit='KiB'>8388608</memory> <currentMemory unit='KiB'>8388608</currentMemory> <vcpu placement='static'>4</vcpu> @@ -32,12 +32,20 @@ <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer.qcow2'/> + <source file='/home/qemu/vms/nodename.qcow2'/> <backingStore/> <target dev='hda' bus='ide'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='/home/qemu/vms/nodename_data.qcow2'/> + <backingStore/> + <target dev='hdb' bus='ide'/> + <alias name='ide0-0-1'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> <controller type='usb' index='0' model='ich9-ehci1'> <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> diff --git a/templates/virtual_environment/vms/computer01.xml b/templates/virtual_environment/vms/computer01.xml deleted file mode 100644 index 5f7f88ba..00000000 --- a/templates/virtual_environment/vms/computer01.xml +++ /dev/null @@ -1,136 +0,0 @@ -<domain type='kvm' id='4'> - <name>computer01</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer01.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer01_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy3' bridge='daisy3'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/computer02.xml b/templates/virtual_environment/vms/computer02.xml deleted file mode 100644 index bad307cf..00000000 --- a/templates/virtual_environment/vms/computer02.xml +++ /dev/null @@ -1,136 +0,0 @@ -<domain type='kvm' id='4'> - <name>computer02</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer02.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer02_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy3' bridge='daisy3'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/computer03.xml b/templates/virtual_environment/vms/computer03.xml deleted file mode 100644 index 235ff745..00000000 --- a/templates/virtual_environment/vms/computer03.xml +++ /dev/null @@ -1,132 +0,0 @@ -<domain type='kvm' id='4'> - <name>computer03</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer03.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer03_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/computer04.xml b/templates/virtual_environment/vms/computer04.xml deleted file mode 100644 index 2a5cd3aa..00000000 --- a/templates/virtual_environment/vms/computer04.xml +++ /dev/null @@ -1,132 +0,0 @@ -<domain type='kvm' id='4'> - <name>computer04</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer04.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/computer04_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/controller.xml b/templates/virtual_environment/vms/controller.xml index 72d255e6..0b605104 100644 --- a/templates/virtual_environment/vms/controller.xml +++ b/templates/virtual_environment/vms/controller.xml @@ -1,5 +1,5 @@ <domain type='kvm' id='4'> - <name>controller</name> + <name>nodename</name> <memory unit='KiB'>12582912</memory> <currentMemory unit='KiB'>12582912</currentMemory> <vcpu placement='static'>4</vcpu> @@ -32,12 +32,20 @@ <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller.qcow2'/> + <source file='/home/qemu/vms/nodename.qcow2'/> <backingStore/> <target dev='hda' bus='ide'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='/home/qemu/vms/nodename_data.qcow2'/> + <backingStore/> + <target dev='hdb' bus='ide'/> + <alias name='ide0-0-1'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> <controller type='usb' index='0' model='ich9-ehci1'> <alias name='usb'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> diff --git a/templates/virtual_environment/vms/controller01.xml b/templates/virtual_environment/vms/controller01.xml deleted file mode 100644 index e2919996..00000000 --- a/templates/virtual_environment/vms/controller01.xml +++ /dev/null @@ -1,136 +0,0 @@ -<domain type='kvm' id='4'> - <name>controller01</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller01.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller01_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy3' bridge='daisy3'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/controller02.xml b/templates/virtual_environment/vms/controller02.xml deleted file mode 100644 index cec3c517..00000000 --- a/templates/virtual_environment/vms/controller02.xml +++ /dev/null @@ -1,136 +0,0 @@ -<domain type='kvm' id='4'> - <name>controller02</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller02.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller02_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy3' bridge='daisy3'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/templates/virtual_environment/vms/controller03.xml b/templates/virtual_environment/vms/controller03.xml deleted file mode 100644 index b86f82b9..00000000 --- a/templates/virtual_environment/vms/controller03.xml +++ /dev/null @@ -1,136 +0,0 @@ -<domain type='kvm' id='4'> - <name>controller03</name> - <memory unit='KiB'>8388608</memory> - <currentMemory unit='KiB'>8388608</currentMemory> - <vcpu placement='static'>4</vcpu> - <resource> - <partition>/machine</partition> - </resource> - <os> - <type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type> - <boot dev='network'/> - <boot dev='hd'/> - </os> - <features> - <acpi/> - <apic/> - </features> - <cpu mode="host-model"/> - <clock offset='utc'> - <timer name='rtc' tickpolicy='catchup'/> - <timer name='pit' tickpolicy='delay'/> - <timer name='hpet' present='no'/> - </clock> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>restart</on_crash> - <pm> - <suspend-to-mem enabled='no'/> - <suspend-to-disk enabled='no'/> - </pm> - <devices> - <emulator>/usr/libexec/qemu-kvm</emulator> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller03.qcow2'/> - <backingStore/> - <target dev='hda' bus='ide'/> - <alias name='ide0-0-0'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <disk type='file' device='disk'> - <driver name='qemu' type='qcow2'/> - <source file='/home/qemu/vms/controller03_data.qcow2'/> - <backingStore/> - <target dev='hdb' bus='ide'/> - <alias name='ide0-0-1'/> - <address type='drive' controller='0' bus='0' target='0' unit='1'/> - </disk> - <controller type='usb' index='0' model='ich9-ehci1'> - <alias name='usb'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci1'> - <alias name='usb'/> - <master startport='0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci2'> - <alias name='usb'/> - <master startport='2'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/> - </controller> - <controller type='usb' index='0' model='ich9-uhci3'> - <alias name='usb'/> - <master startport='4'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/> - </controller> - <controller type='pci' index='0' model='pci-root'> - <alias name='pci.0'/> - </controller> - <controller type='ide' index='0'> - <alias name='ide'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='virtio-serial' index='0'> - <alias name='virtio-serial0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> - </controller> - <interface type='network'> - <source network='daisy1' bridge='daisy1'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy2' bridge='daisy2'/> - <model type='rtl8139'/> - </interface> - <interface type='network'> - <source network='daisy3' bridge='daisy3'/> - <model type='rtl8139'/> - </interface> - <serial type='pty'> - <source path='/dev/pts/4'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <console type='pty' tty='/dev/pts/4'> - <source path='/dev/pts/4'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> - <channel type='spicevmc'> - <target type='virtio' name='com.redhat.spice.0' state='connected'/> - <alias name='channel0'/> - <address type='virtio-serial' controller='0' bus='0' port='1'/> - </channel> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5903' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> - <image compression='off'/> - </graphics> - <sound model='ich6'> - <alias name='sound0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> - </sound> - <video> - <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/> - <alias name='video0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir0'/> - </redirdev> - <redirdev bus='usb' type='spicevmc'> - <alias name='redir1'/> - </redirdev> - <memballoon model='virtio'> - <alias name='balloon0'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> - </memballoon> - </devices> - <seclabel type='dynamic' model='selinux' relabel='yes'> - <label>system_u:system_r:svirt_t:s0:c182,c195</label> - <imagelabel>system_u:object_r:svirt_image_t:s0:c182,c195</imagelabel> - </seclabel> -</domain> diff --git a/test-requirements.txt b/test-requirements.txt index 1def47c3..9ab1fa4a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,3 +7,4 @@ pytest-faker pytest-mock pyyaml scp +oslo_config diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..6a8dd68f --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,17 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +from os import path + +import pytest + + +@pytest.fixture(scope='session') +def data_root(): + return path.join(path.dirname(__file__), 'data') diff --git a/tests/data/lab_conf/deploy_virtual1.yml b/tests/data/lab_conf/deploy_virtual1.yml new file mode 100644 index 00000000..7fdfc3ba --- /dev/null +++ b/tests/data/lab_conf/deploy_virtual1.yml @@ -0,0 +1,31 @@ +adapter: libvirt +hosts: +- name: 'controller01' + roles: + - 'CONTROLLER_LB' + template: 'templates/virtual_environment/vms/controller.xml' +- name: 'controller02' + roles: + - 'CONTROLLER_LB' + template: 'templates/virtual_environment/vms/controller.xml' +- name: 'controller03' + roles: + - 'CONTROLLER_LB' + template: 'templates/virtual_environment/vms/controller.xml' +- name: 'computer01' + roles: + - 'COMPUTER' + template: 'templates/virtual_environment/vms/computer.xml' +- name: 'computer02' + roles: + - 'COMPUTER' + template: 'templates/virtual_environment/vms/computer.xml' +disks: + daisy: 50 + controller: 110 + compute: 110 + ceph: 110 +daisy_passwd: 'r00tme' +daisy_ip: '10.20.11.2' +daisy_gateway: '10.20.11.1' +ceph_disk_name: '/dev/sdb'
\ No newline at end of file diff --git a/tests/data/lab_conf/network_virtual1.yml b/tests/data/lab_conf/network_virtual1.yml new file mode 100644 index 00000000..d0fc26bf --- /dev/null +++ b/tests/data/lab_conf/network_virtual1.yml @@ -0,0 +1,69 @@ +############################################################################## +# Copyright (c) 2016 ZTE Coreporation and others. +# hu.zhijiang@zte.com.cn +# sun.jing22@zte.com.cn +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +network-config-metadata: + title: 'zte-virtual1 network config' + version: '0.1' + created: 'Tue Apr 11 2017' + comment: 'five vm node deploy' +networks: + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - start: '10.20.11.3' + end: '10.20.11.10' + name: 'MANAGEMENT' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - start: '10.20.11.3' + end: '10.20.11.10' + name: 'STORAGE' + - cidr: '172.10.101.0/24' + gateway: '172.10.101.1' + ip_ranges: + - start: '172.10.101.2' + end: '172.10.101.20' + name: 'EXTERNAL' + network_name: 'admin_external' + mapping: 'physnet1' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - start: '10.20.11.3' + end: '10.20.11.10' + name: 'PUBLICAPI' + - cidr: '10.20.11.0/24' + gateway: '10.20.11.1' + ip_ranges: + - start: '10.20.11.3' + end: '10.20.11.10' + name: 'TENANT' + - cidr: '100.20.11.0/24' + gateway: '100.20.11.1' + ip_ranges: + - start: '100.20.11.3' + end: '100.20.11.10' + name: 'HEARTBEAT' +interfaces: + - name: 'EXTERNAL' + interface: 'ens8' + - name: 'MANAGEMENT' + interface: 'ens3' + - name: 'PUBLICAPI' + interface: 'ens3' + - name: 'STORAGE' + interface: 'ens3' + - name: 'TENANT' + interface: 'ens3' + - name: 'HEARTBEAT' + interface: 'ens9' +internal_vip: '10.20.11.11' +public_vip: '10.20.11.11'
\ No newline at end of file diff --git a/tests/unit/test_get_conf.py b/tests/unit/test_get_conf.py new file mode 100644 index 00000000..66fb2261 --- /dev/null +++ b/tests/unit/test_get_conf.py @@ -0,0 +1,64 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corp and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +import os +import pytest + +from deploy.get_conf import ( + get_yml_para, + config +) + + +@pytest.fixture(scope="session") +def deploy_file(data_root): + return os.path.join(data_root, 'lab_conf', 'deploy_virtual1.yml') + + +@pytest.fixture(scope="session") +def network_file(data_root): + return os.path.join(data_root, 'lab_conf', 'network_virtual1.yml') + + +def test_get_yml_para(deploy_file): + assert get_yml_para(deploy_file) == (50, 110, 110, 'r00tme', '10.20.11.2', '10.20.11.1', 5) + + +def test_config(deploy_file, network_file): + assert config(deploy_file, network_file) == ({'ens8': [{'ip': '', 'name': 'EXTERNAL'}], + 'ens3': [{'ip': '', 'name': 'MANAGEMENT'}, + {'ip': '', 'name': 'PUBLICAPI'}, + {'ip': '', 'name': 'STORAGE'}, + {'ip': '', 'name': 'physnet1'}], + 'ens9': [{'ip': '', 'name': 'HEARTBEAT'}]}, + ['computer01', 'computer02', 'controller01', 'controller02', + 'controller03'], + {'MANAGEMENT': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1', + 'ip_ranges': [{'start': '10.20.11.3', + 'end': '10.20.11.10'}]}, + 'STORAGE': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1', + 'ip_ranges': [{'start': '10.20.11.3', + 'end': '10.20.11.10'}]}, + 'EXTERNAL': {'cidr': '172.10.101.0/24', 'gateway': '172.10.101.1', + 'ip_ranges': [{'start': '172.10.101.2', + 'end': '172.10.101.20'}], + 'network_name': 'admin_external', + 'mapping': 'physnet1'}, + 'PUBLICAPI': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1', + 'ip_ranges': [{'start': '10.20.11.3', + 'end': '10.20.11.10'}]}, + 'physnet1': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1', + 'ip_ranges': [{'start': '10.20.11.3', + 'end': '10.20.11.10'}]}, + 'HEARTBEAT': {'cidr': '100.20.11.0/24', 'gateway': '100.20.11.1', + 'ip_ranges': [{'start': '100.20.11.3', + 'end': '100.20.11.10'}]}}, + '10.20.11.11', '/dev/sdb', + {'controller01': [], 'controller02': [], 'controller03': [], + 'computer01': [], 'computer02': []}) |