diff options
-rw-r--r-- | .gitignore | 64 | ||||
-rw-r--r-- | ci/build_rpm/Dockerfile | 2 | ||||
-rwxr-xr-x | ci/build_rpm/build_rpms.sh | 75 | ||||
-rwxr-xr-x | ci/deploy/deploy.sh | 2 | ||||
-rw-r--r-- | deploy/config/vm_environment/zte-virtual1/deploy.yml | 28 | ||||
-rw-r--r-- | deploy/config/vm_environment/zte-virtual1/network.yml | 60 | ||||
-rwxr-xr-x | deploy/get_conf.py | 82 | ||||
-rw-r--r-- | templates/virtual_environment/networks/daisy1.xml | 12 | ||||
-rw-r--r-- | templates/virtual_environment/networks/daisy2.xml | 12 | ||||
-rw-r--r-- | templates/virtual_environment/vms/all_in_one.xml | 126 | ||||
-rw-r--r-- | templates/virtual_environment/vms/daisy.xml | 121 |
11 files changed, 441 insertions, 143 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..078f1c9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# Normal for all project +*~ +.*.sw? +/docs_build/ +/docs_output/ +/releng/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*.confc + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +eggs/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache + +# Log files: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# SublimeText +*.sublime-project +*.sublime-workspace + +# macos preview +.DS_Store + +# PyCharm +.idea/ + diff --git a/ci/build_rpm/Dockerfile b/ci/build_rpm/Dockerfile index 3dffbe4a..f10d95e4 100644 --- a/ci/build_rpm/Dockerfile +++ b/ci/build_rpm/Dockerfile @@ -1,7 +1,7 @@ FROM centos:7 LABEL daisy_image_version=1.0 RUN yum -y update -RUN yum -y install centos-release-openstack-mitaka +RUN yum -y install centos-release-openstack-newton RUN yum -y install \ wget \ coreutils \ diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh index 2d5d23e0..279340cd 100755 --- a/ci/build_rpm/build_rpms.sh +++ b/ci/build_rpm/build_rpms.sh @@ -13,54 +13,51 @@ DAISYDIR=$1 OPNFV_ARTIFACT_VERSION=$2 function build_rpm_pkg { - # Cleanup prev build resutls - rm -rf $DAISYDIR/build_output - mkdir -p $DAISYDIR/build_output - - sudo docker build -t daisy4nfv_rpm . - sudo docker run --rm -v $DAISYDIR:/opt/daisy4nfv -v $CACHE_DIRECTORY:/home/cache -t daisy4nfv_rpm \ - /opt/daisy4nfv/ci/build_rpm/build_rpms_docker.sh $OPNFV_ARTIFACT_VERSION - - # Here to collect build result from $DAISYDIR/build_output + # Cleanup prev build resutls + rm -rf $DAISYDIR/build_output + mkdir -p $DAISYDIR/build_output + + sudo docker build -t daisy4nfv_rpm . + sudo docker run --rm -v $DAISYDIR:/opt/daisy4nfv \ + -v $CACHE_DIRECTORY:/home/cache \ + -t daisy4nfv_rpm \ + /opt/daisy4nfv/ci/build_rpm/build_rpms_docker.sh \ + $OPNFV_ARTIFACT_VERSION } function cleanup_container { - containers_to_kill=$(sudo docker ps --filter "label=daisy_image_version" \ - --format "{{.Names}}" -a) - - if [[ -z "$containers_to_kill" ]]; then - echo "No containers to cleanup." - else - volumes_to_remove=$(sudo docker inspect -f \ - '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' \ - ${containers_to_kill} | egrep -v '(^\s*$)' | sort | uniq) - echo "Stopping containers... $containers_to_kill" - sudo docker stop -t 2 ${containers_to_kill} >/dev/null 2>&1 - - echo "Removing containers... $containers_to_kill" - sudo docker rm -v -f ${containers_to_kill} >/dev/null 2>&1 - - if [[ -z "$volumes_to_remove" ]]; then - echo "No volumes to cleanup." - else - echo "Removing volumes... $volumes_to_remove" - sudo docker volume rm ${volumes_to_remove} >/dev/null 2>&1 - fi + containers_to_kill=$(sudo docker ps -a \ + --filter "label=daisy_image_version" \ + --format "{{.Names}}") + + if [[ ! -z "$containers_to_kill" ]]; then + ops='{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' + volumes_to_remove=$(sudo docker inspect -f \ + $ops ${containers_to_kill} \ + | egrep -v '(^\s*$)' \ + | sort | uniq) + + sudo docker stop -t 2 ${containers_to_kill} >/dev/null 2>&1 + sudo docker rm -v -f ${containers_to_kill} >/dev/null 2>&1 + + if [[ ! -z "$volumes_to_remove" ]]; then + sudo docker volume rm ${volumes_to_remove} >/dev/null 2>&1 fi + fi } function cleanup_docker_image { - images_to_delete=$(sudo docker images -a --filter "label=daisy_image_version" \ - --format "{{.ID}}") - - echo "Removing images... $images_to_delete" - if [[ -z "$images_to_delete" ]]; then - echo "No images to cleanup" - else - sudo docker rmi -f ${images_to_delete} >/dev/null 2>&1 - fi + images_to_delete=$(sudo docker images -a \ + --format "{{.ID}}" \ + --filter "label=daisy_image_version") + + echo "Removing images... $images_to_delete" + if [[ ! -z "$images_to_delete" ]]; then + sudo docker rmi -f ${images_to_delete} >/dev/null 2>&1 + fi } cleanup_container build_rpm_pkg cleanup_container + diff --git a/ci/deploy/deploy.sh b/ci/deploy/deploy.sh index 11865b4a..6d7addd2 100755 --- a/ci/deploy/deploy.sh +++ b/ci/deploy/deploy.sh @@ -43,7 +43,7 @@ python $tempest_path/tempest.py --dha $DHA --network $NETWORK echo "======daisy install kolla(openstack)===========" cluster_id=`daisy cluster-list | awk -F "|" '{print $2}' | sed -n '4p'` daisy install $cluster_id -echo "check installing proess..." +echo "check installing process..." var=1 while [ $var -eq 1 ]; do echo "loop for judge openstack installing progress..." diff --git a/deploy/config/vm_environment/zte-virtual1/deploy.yml b/deploy/config/vm_environment/zte-virtual1/deploy.yml index 5390ecf9..0cb8f62b 100644 --- a/deploy/config/vm_environment/zte-virtual1/deploy.yml +++ b/deploy/config/vm_environment/zte-virtual1/deploy.yml @@ -1,20 +1,20 @@ hosts: - name: 'Node5' roles: - - 'CONTROLLER_LB' - - 'COMPUTER' + - 'CONTROLLER_LB' + - 'COMPUTER' ip: '192.168.122.152' password: 'ossdbg1' interface: - - 'ens3': - - name: 'MANAGEMENT' - ip: '192.168.122.152' - - name: 'PUBLICAPI' - ip: - - name: 'physnet1' - ip: - - name: 'STORAGE' - ip: - 'ens8': - - name: 'EXTERNAL' - ip: + - 'ens3': + - name: 'MANAGEMENT' + ip: '192.168.122.152' + - name: 'PUBLICAPI' + ip: + - name: 'physnet1' + ip: + - name: 'STORAGE' + ip: + - 'ens8': + - name: 'EXTERNAL' + ip: diff --git a/deploy/config/vm_environment/zte-virtual1/network.yml b/deploy/config/vm_environment/zte-virtual1/network.yml index 50fca1be..ea08117d 100644 --- a/deploy/config/vm_environment/zte-virtual1/network.yml +++ b/deploy/config/vm_environment/zte-virtual1/network.yml @@ -14,36 +14,36 @@ network-config-metadata: created: 'Mon Oct 31 2016' comment: networks: -- cidr: '192.168.122.0/24' - gateway: '192.168.122.1' - ip_ranges: - - 'start': '192.168.122.1' - 'end': '192.168.122.254' - name: 'MANAGEMENT' -- cidr: '192.168.122.0/24' - gateway: '192.168.122.1' - ip_ranges: - - start: '192.168.122.1' - end: '192.168.122.254' - name: 'STORAGE' -- cidr: '192.168.2.0/24' - gateway: '192.168.2.1' - ip_ranges: - - 'start': '192.168.2.1' - 'end': '192.168.2.254' - 'name': 'EXTERNAL' -- cidr: '192.168.122.0/24' - gateway: '192.168.122.1' - ip_ranges: - - 'start': '192.168.122.1' - 'end': '192.168.122.254' - name: 'PUBLICAPI' -- cidr: '192.168.122.0/24' - gateway: '192.168.122.1' - ip_ranges: - - 'start': '192.168.122.1' - 'end': '192.168.122.254' - name: 'physnet1' + - cidr: '192.168.122.0/24' + gateway: '192.168.122.1' + ip_ranges: + - 'start': '192.168.122.1' + 'end': '192.168.122.254' + name: 'MANAGEMENT' + - cidr: '192.168.122.0/24' + gateway: '192.168.122.1' + ip_ranges: + - start: '192.168.122.1' + end: '192.168.122.254' + name: 'STORAGE' + - cidr: '192.168.2.0/24' + gateway: '192.168.2.1' + ip_ranges: + - 'start': '192.168.2.1' + 'end': '192.168.2.254' + 'name': 'EXTERNAL' + - cidr: '192.168.122.0/24' + gateway: '192.168.122.1' + ip_ranges: + - 'start': '192.168.122.1' + 'end': '192.168.122.254' + name: 'PUBLICAPI' + - cidr: '192.168.122.0/24' + gateway: '192.168.122.1' + ip_ranges: + - 'start': '192.168.122.1' + 'end': '192.168.122.254' + name: 'physnet1' internal_vip: '192.168.122.144' diff --git a/deploy/get_conf.py b/deploy/get_conf.py index 31ccaca0..309b331b 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -16,56 +16,22 @@ def init(file): return yaml.safe_load(fd) -def networkdecorator(func): - def wrapter(s, seq): - network_list = s.get('networks', []) - result = {} - for network in network_list: - s = func(s, seq, network) - if not s: - continue - result.update(s) - if len(result) == 0: - return "" - else: +def decorator_mk(types): + def decorator(func): + def wrapter(s): + item_list = s.get(types, []) + result = {} + for item in item_list: + ret = func(item) + if ret: + result.update(ret) return result - return wrapter - - -def hostdecorator(func): - def wrapter(s, seq): - host_list = s.get('hosts', []) - result = {} - for host in host_list: - s = func(s, seq, host) - if not s: - continue - result.update(s) - if len(result) == 0: - return "" - else: - return result - return wrapter - - -def decorator(func): - def wrapter(s, seq): - host_list = s.get('hosts', []) - result = [] - for host in host_list: - s = func(s, seq, host) - if not s: - continue - result.append(s) - if len(result) == 0: - return "" - else: - return result - return wrapter + return wrapter + return decorator -@networkdecorator -def network(s, seq, network=None): +@decorator_mk('networks') +def network(network=None): net_plane = network.get('name', '') network.pop('name') map = {} @@ -73,17 +39,17 @@ def network(s, seq, network=None): return map -@hostdecorator -def interface(s, seq, host=None): +@decorator_mk('hosts') +def interface(host=None): hostname = host.get('name', '') - interface = host.get('interface', '')[0] + interface = host.get('interface', '') map = {} map[hostname] = interface return map -@hostdecorator -def role(s, seq, host=None): +@decorator_mk('hosts') +def role(host=None): hostname = host.get('name', '') role = host.get('roles', '') map = {} @@ -91,8 +57,8 @@ def role(s, seq, host=None): return map -@decorator -def host(s, seq, host=None): +@decorator_mk('hosts') +def host(host=None): hostip = host.get('ip', []) passwd = host.get('password', []) map = {} @@ -101,15 +67,15 @@ def host(s, seq, host=None): def network_config_parse(s, dha_file): - network_map = network(s, ',') + network_map = network(s) vip = s.get('internal_vip') return network_map, vip def dha_config_parse(s, dha_file): - host_interface_map = interface(s, ',') - host_role_map = role(s, ',') - host_ip_passwd_map = host(s, ',') + host_interface_map = interface(s) + host_role_map = role(s) + host_ip_passwd_map = host(s) return host_interface_map, host_role_map, host_ip_passwd_map diff --git a/templates/virtual_environment/networks/daisy1.xml b/templates/virtual_environment/networks/daisy1.xml new file mode 100644 index 00000000..91b2dff4 --- /dev/null +++ b/templates/virtual_environment/networks/daisy1.xml @@ -0,0 +1,12 @@ +<network connections='1'> + <name>daisy1</name> + <forward mode='nat'> + <nat> + <port start='1024' end='65535'/> + </nat> + </forward> + <bridge name='daisy1' stp='on' delay='0'/> + <domain name='daisy1'/> + <ip address='10.20.11.1' netmask='255.255.255.0'> + </ip> +</network> diff --git a/templates/virtual_environment/networks/daisy2.xml b/templates/virtual_environment/networks/daisy2.xml new file mode 100644 index 00000000..f8e86830 --- /dev/null +++ b/templates/virtual_environment/networks/daisy2.xml @@ -0,0 +1,12 @@ +<network connections='1'> + <name>daisy2</name> + <forward mode='nat'> + <nat> + <port start='1024' end='65535'/> + </nat> + </forward> + <bridge name='daisy2' stp='on' delay='0'/> + <domain name='daisy2'/> + <ip address='172.10.101.1' netmask='255.255.255.0'> + </ip> +</network> diff --git a/templates/virtual_environment/vms/all_in_one.xml b/templates/virtual_environment/vms/all_in_one.xml new file mode 100644 index 00000000..75caed25 --- /dev/null +++ b/templates/virtual_environment/vms/all_in_one.xml @@ -0,0 +1,126 @@ +<domain type='kvm' id='4'> + <name>all_in_one</name> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</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='custom' match='exact'> + <model fallback='allow'>IvyBridge</model> + </cpu> + <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/all_in_one.qcow2'/> + <backingStore/> + <target dev='hda' bus='ide'/> + <alias name='ide0-0-0'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </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/daisy.xml b/templates/virtual_environment/vms/daisy.xml new file mode 100644 index 00000000..c95219b8 --- /dev/null +++ b/templates/virtual_environment/vms/daisy.xml @@ -0,0 +1,121 @@ +<domain type='kvm' id='4'> + <name>daisy</name> + <memory unit='KiB'>4194304</memory> + <currentMemory unit='KiB'>4194304</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='hd'/> + </os> + <features> + <acpi/> + <apic/> + </features> + <cpu mode='custom' match='exact'> + <model fallback='allow'>IvyBridge</model> + </cpu> + <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='/tmp/workdir/daisy/centos7.qcow2'/> + <backingStore/> + <target dev='hda' bus='ide'/> + <alias name='ide0-0-0'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </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> + <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> |