diff options
34 files changed, 391 insertions, 218 deletions
diff --git a/build/build.yaml b/build/build.yaml index 6694c8e7..75faa280 100644 --- a/build/build.yaml +++ b/build/build.yaml @@ -24,12 +24,12 @@ packages: - name: compass-deck description: "RESTful API and DB Handlers for Compass" get_method: docker - url: compass4nfv/compass-deck:7.0.0 + url: opnfv/compass-deck:latest - name: compass-tasks-osa description: "compass task container integrated with openstack-ansible" get_method: docker - url: compass4nfv/compass-tasks-osa:7.0.0 + url: opnfv/compass-tasks-osa:latest - name: compass-tasks-k8s description: "compass task container integrated with kubespray" diff --git a/deploy/client.py b/deploy/client.py index e612160b..3a9b0dec 100644 --- a/deploy/client.py +++ b/deploy/client.py @@ -79,8 +79,8 @@ opts = [ cfg.BoolOpt('poll_switches', help='if the client polls switches', default=True), - cfg.StrOpt('machines', - help='comma separated mac addresses of machines', + cfg.StrOpt('machine_file', + help='mac addresses and ipmi info of machines', default=''), cfg.StrOpt('subnets', help='comma seperated subnets', @@ -327,12 +327,12 @@ class CompassClient(object): 'get all machines status: %s, resp: %s', status, resp) raise RuntimeError('failed to get machines') - machines_to_add = list(set([ - machine for machine in CONF.machines.split(',') - if machine - ])) + with open(CONF.machine_file) as fd: + machines_to_add = [str(m["mac"]) for m in yaml.load(fd)] + resp = byteify(resp) machines_db = [str(m["mac"]) for m in resp] + LOG.info( 'machines in db: %s\n to add: %s', machines_db, @@ -983,8 +983,6 @@ class CompassClient(object): ansible_log = "%s/work/deploy/docker/ansible/run/%s-%s/ansible.log" \ % (compass_dir, CONF.adapter_name, CONF.cluster_name) os.system("sudo touch %s" % ansible_log) - os.system("sudo chmod +x -R %s/work/deploy/docker/ansible/run/" - % compass_dir) ansible_print = multiprocessing.Process(target=print_log, args=(ansible_log,)) ansible_print.start() diff --git a/deploy/compass_conf/templates/cobbler/ubuntu-16.04.3-server-x86_64/system.tmpl b/deploy/compass_conf/templates/cobbler/ubuntu-16.04.3-server-x86_64/system.tmpl index cfcc883e..366cbc13 100755 --- a/deploy/compass_conf/templates/cobbler/ubuntu-16.04.3-server-x86_64/system.tmpl +++ b/deploy/compass_conf/templates/cobbler/ubuntu-16.04.3-server-x86_64/system.tmpl @@ -11,36 +11,38 @@ "proxy": "$getVar('http_proxy', '')", "modify_interface": #set networks = $networks + #set mac = $mac #set rekeyed = {} #set promic_nic = "" - #for $nic, $val in $networks.iteritems(): - #set ip_key = '-'.join(('ipaddress', $nic)) - #set netmask_key = '-'.join(('netmask', $nic)) - #set mgmt_key = '-'.join(('management', $nic)) - #set static_key = '-'.join(('static', $nic)) - #set $rekeyed[$ip_key] = $val.ip - #set $rekeyed[$netmask_key] = $val.netmask - #set $rekeyed[$static_key] = True + #for $nic in $mac + #set mac_key = '-'.join(('macaddress', $nic)) + #set $rekeyed[$mac_key] = $mac[$nic] + #if $nic in $networks + #set val = $networks[$nic] + #set ip_key = '-'.join(('ipaddress', $nic)) + #set netmask_key = '-'.join(('netmask', $nic)) + #set mgmt_key = '-'.join(('management', $nic)) + #set static_key = '-'.join(('static', $nic)) + #set $rekeyed[$ip_key] = $val.ip + #set $rekeyed[$netmask_key] = $val.netmask + #set $rekeyed[$static_key] = True - #set dns_key = '-'.join(('dnsname', $nic)) - #if $val.is_mgmt - #set $rekeyed[$dns_key] = $dns - #else - #if '.' in $dns - #set $dns_name, $dns_domain = $dns.split('.', 1) - #set $dns_nic = '%s-%s.%s' % ($dns_name, $nic, $dns_domain) + #set dns_key = '-'.join(('dnsname', $nic)) + #if $val.is_mgmt + #set $rekeyed[$dns_key] = $dns #else - #set $dns_nic = '%s-%s' % ($dns, $nic) + #if '.' in $dns + #set $dns_name, $dns_domain = $dns.split('.', 1) + #set $dns_nic = '%s-%s.%s' % ($dns_name, $nic, $dns_domain) + #else + #set $dns_nic = '%s-%s' % ($dns, $nic) + #end if + #set $rekeyed[$dns_key] = $dns_nic #end if - #set $rekeyed[$dns_key] = $dns_nic - #end if - #if $val.is_promiscuous: - #set promic_nic = $nic - #end if - #if $val.is_mgmt: - #set mac_key = '-'.join(('macaddress', $nic)) - #set $rekeyed[$mac_key] = $mac + #if $val.is_promiscuous + #set promic_nic = $nic + #end if #end if #end for #set nic_info = json.dumps($rekeyed, encoding='utf-8') @@ -71,5 +73,9 @@ "ignore_proxy": "$no_proxy", "local_repo": "$getVar('local_repo', '')", "disk_num": "1" - } + }, + "power_address": "$power_manage.ip", + "power_user": "$power_manage.username", + "power_pass": "$power_manage.password", + "power_type": "$getVar('power_type', 'ipmilan')" } diff --git a/deploy/compass_vm.sh b/deploy/compass_vm.sh index f7bc378e..edce626b 100755 --- a/deploy/compass_vm.sh +++ b/deploy/compass_vm.sh @@ -12,15 +12,15 @@ rsa_file=$compass_vm_dir/boot.rsa ssh_args="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $rsa_file" function check_container_alive() { - docker exec -it compass-deck bash -c "exit" 1>/dev/null 2>&1 + sudo docker exec -it compass-deck bash -c "exit" local deck_state=$? - docker exec -it compass-tasks bash -c "exit" 1>/dev/null 2>&1 + sudo docker exec -it compass-tasks bash -c "exit" local tasks_state=$? - docker exec -it compass-cobbler bash -c "exit" 1>/dev/null 2>&1 + sudo docker exec -it compass-cobbler bash -c "exit" local cobbler_state=$? - docker exec -it compass-db bash -c "exit" 1>/dev/null 2>&1 + sudo docker exec -it compass-db bash -c "exit" local db_state=$? - docker exec -it compass-mq bash -c "exit" 1>/dev/null 2>&1 + sudo docker exec -it compass-mq bash -c "exit" local mq_state=$? if [ $((deck_state||tasks_state||cobbler_state||db_state||mq_state)) == 0 ]; then @@ -47,9 +47,7 @@ function install_compass_core() { } function set_compass_machine() { - local config_file=$WORK_DIR/installer/docker-compose/group_vars/all - sed -i '/pxe_boot_macs/d' $config_file - echo "pxe_boot_macs: [${machines}]" >> $config_file + cp $WORK_DIR/script/machine $WORK_DIR/docker/ ansible-playbook $WORK_DIR/installer/docker-compose/add_machine.yml } diff --git a/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-nofeature-ha.yml index 2cedcf4d..29ca9ac0 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-nofeature-ha.yml @@ -31,7 +31,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - kube_master @@ -39,10 +39,10 @@ hosts: - ha - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - kube_master diff --git a/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-stor4nfv-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-stor4nfv-ha.yml index 6cf62db7..6efdadc3 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-stor4nfv-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/k8-nosdn-stor4nfv-ha.yml @@ -34,7 +34,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - kube_master @@ -42,10 +42,10 @@ hosts: - ha - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - kube_master diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-bar-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-bar-ha.yml index 59e7180a..32f561d5 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-bar-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-bar-ha.yml @@ -35,7 +35,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -43,10 +43,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-kvm-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-kvm-ha.yml index 9c00916b..03267ffc 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-kvm-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-kvm-ha.yml @@ -35,7 +35,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -43,10 +43,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-nofeature-ha.yml index 6b329be6..7ca9e795 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-nofeature-ha.yml @@ -32,7 +32,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -40,10 +40,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-openo-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-openo-ha.yml index 6027bddb..b2440ee4 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-openo-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-openo-ha.yml @@ -40,7 +40,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -48,10 +48,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-stor4nfv-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-stor4nfv-ha.yml index 5045975f..5ce9b47a 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-stor4nfv-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-nosdn-stor4nfv-ha.yml @@ -35,7 +35,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -43,10 +43,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-ocl-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-ocl-nofeature-ha.yml index 287383b2..bfab0151 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-ocl-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-ocl-nofeature-ha.yml @@ -33,17 +33,17 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - compute - ceph-osd - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - compute diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-odl-sfc-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-odl-sfc-ha.yml index 8095fe03..c5fd84ee 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-odl-sfc-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-odl-sfc-ha.yml @@ -38,7 +38,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -47,10 +47,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-moon-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-moon-ha.yml index d2447c1d..71b114f2 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-moon-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-moon-ha.yml @@ -37,7 +37,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -46,10 +46,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-nofeature-ha.yml index 71edf08c..2c2757a6 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l2-nofeature-ha.yml @@ -36,7 +36,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -45,10 +45,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l3-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l3-nofeature-ha.yml index e3e71d0b..cc621d76 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-odl_l3-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-odl_l3-nofeature-ha.yml @@ -38,7 +38,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -47,10 +47,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-onos-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-onos-nofeature-ha.yml index fb4b1788..57d0a2d5 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-onos-nofeature-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-onos-nofeature-ha.yml @@ -33,7 +33,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -42,10 +42,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/hardware_environment/huawei-pod1/os-onos-sfc-ha.yml b/deploy/conf/hardware_environment/huawei-pod1/os-onos-sfc-ha.yml index 1f40241f..c8aee2dc 100644 --- a/deploy/conf/hardware_environment/huawei-pod1/os-onos-sfc-ha.yml +++ b/deploy/conf/hardware_environment/huawei-pod1/os-onos-sfc-ha.yml @@ -35,7 +35,7 @@ hosts: mac: 'D8:49:0B:DA:5A:B7' interfaces: - eth1: 'D8:49:0B:DA:5A:B8' - ipmiIp: 172.16.130.27 + ipmiIp: 172.16.130.29 ipmiPass: Opnfv@pod1 roles: - controller @@ -44,10 +44,10 @@ hosts: - ceph-mon - name: host3 - mac: '78:D7:52:A0:B1:99' + mac: '70:7B:E8:77:7B:60' interfaces: - - eth1: '78:D7:52:A0:B1:9A' - ipmiIp: 172.16.130.29 + - eth1: '70:7B:E8:77:7B:5F' + ipmiIp: 172.16.130.27 ipmiPass: Opnfv@pod1 roles: - controller diff --git a/deploy/conf/vm_environment/k8-nosdn-onap-noha.yml b/deploy/conf/vm_environment/k8-nosdn-onap-noha.yml new file mode 100644 index 00000000..d7b85a85 --- /dev/null +++ b/deploy/conf/vm_environment/k8-nosdn-onap-noha.yml @@ -0,0 +1,46 @@ +############################################################################## +# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD 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 +############################################################################## + +--- +TYPE: virtual +FLAVOR: cluster + +plugins: + - onap: "Enable" + +hosts: + - name: host1 + roles: + - kube_master + - etcd + - ha + + - name: host2 + roles: + - kube_node + + - name: host3 + roles: + - kube_node + + - name: host4 + roles: + - kube_node + + - name: host5 + roles: + - kube_node + + - name: host6 + roles: + - kube_node + + - name: host7 + roles: + - kube_node diff --git a/deploy/config_parse.py b/deploy/config_parse.py index 9cdf1acb..88a31e9a 100644 --- a/deploy/config_parse.py +++ b/deploy/config_parse.py @@ -11,27 +11,44 @@ import os import netaddr import yaml import sys +import random from Cheetah.Template import Template -def init(file): +def load_yaml(file): with open(file) as fd: return yaml.safe_load(fd) -def export_env_dict(env_dict, ofile, direct=False): - if not os.path.exists(ofile): - raise IOError("output file: %s not exist" % ofile) +def dump_yaml(data, file): + with open(file, "w") as fd: + yaml.safe_dump(data, fd, default_flow_style=False) + + +def mac_generator(): + def random_hex(): + return random.choice("0123456789ABCDEF") + mac = "00:00" + for i in xrange(4): + mac += ":{0}{1}".format(random_hex(), random_hex()) + return mac + + +def export_env_dict(env_dict, output_path, direct=False): + if not os.path.exists(output_path): + raise IOError("output file: %s not exist" % output_path) if direct: for k, v in env_dict.items(): - os.system("echo 'export %s=\"%s\"' >> %s" % (k, v, ofile)) + os.system("echo 'export %s=\"%s\"' >> %s" % + (k, v, output_path)) else: for k, v in env_dict.items(): - os.system("echo 'export %s=${%s:-%s}' >> %s" % (k, k, v, ofile)) + os.system("echo 'export %s=${%s:-%s}' >> %s" % + (k, k, v, output_path)) def decorator(func): - def wrapter(s, seq): + def wrapter(s, seq=None): host_list = s.get('hosts', []) result = [] for host in host_list: @@ -41,8 +58,10 @@ def decorator(func): result.append(s) if len(result) == 0: return "" - else: + elif seq: return "\"" + seq.join(result) + "\"" + else: + return result return wrapter @@ -57,11 +76,15 @@ def hostroles(s, seq, host=None): @decorator -def hostmacs(s, seq, host=None): - return host.get('mac', '') +def hostmachines(s, seq, host=None): + return {'mac': host.get('interfaces', {}), + 'power_type': host.get('power_type', ''), + 'power_ip': host.get('power_ip', ''), + 'power_user': host.get('power_user', ''), + 'power_pass': host.get('power_pass', '')} -def export_network_file(dha, network, ofile): +def export_network_file(dha, network, output_path): install_network_env = {} host_network_env = {} ip_settings = network['ip_settings'] @@ -79,7 +102,7 @@ def export_network_file(dha, network, ofile): install_network_env.update({'INSTALL_NETMASK': mgmt_netmask}) install_network_env.update({'INSTALL_IP_RANGE': dhcp_ip_range}) install_network_env.update({'VIP': internal_vip}) - export_env_dict(install_network_env, ofile) + export_env_dict(install_network_env, output_path) pxe_nic = os.environ['PXE_NIC'] host_ip_range = mgmt_net['ip_ranges'][0] @@ -94,10 +117,10 @@ def export_network_file(dha, network, ofile): host_network_env.update({'NETWORK_MAPPING': "install=" + pxe_nic}) host_network_env.update({'HOST_NETWORKS': ';'.join(host_networks)}) host_network_env.update({'SUBNETS': ','.join(host_subnets)}) - export_env_dict(host_network_env, ofile, True) + export_env_dict(host_network_env, output_path, True) -def export_dha_file(dha, dha_file, ofile): +def export_dha_file(dha, output_path, machine_path): env = {} env.update(dha) if env.get('hosts', []): @@ -121,19 +144,28 @@ def export_dha_file(dha, dha_file, ofile): env.update({'FLAVOR': dha.get('FLAVOR', "cluster")}) env.update({'HOSTNAMES': hostnames(dha, ',')}) env.update({'HOST_ROLES': hostroles(dha, ';')}) - env.update({'DHA': dha_file}) - value = hostmacs(dha, ',') - if len(value) > 0: - env.update({'HOST_MACS': value}) + machine = [] + if dha.get('TYPE') == "virtual": + virtual_mac = [] + for host in dha.get('hosts'): + mac = mac_generator() + machine.append({"mac": {"eth0": mac}, "power_type": "libvirt"}) + virtual_mac.append(mac) + env.update({'HOST_MACS': ",".join(virtual_mac)}) + else: + value = hostmachines(dha) + for item in value: + machine.append(item) + dump_yaml(machine, machine_path) if dha.get('TYPE', "virtual") == "virtual": env.update({'VIRT_NUMBER': len(dha['hosts'])}) - export_env_dict(env, ofile) + export_env_dict(env, output_path) -def export_reset_file(dha, tmpl_dir, output_dir, ofile): +def export_reset_file(dha, tmpl_dir, output_dir, output_path): tmpl_file_name = dha.get('POWER_TOOL', '') if not tmpl_file_name: return @@ -151,28 +183,31 @@ def export_reset_file(dha, tmpl_dir, output_dir, ofile): f.write(tmpl.respond()) power_manage_env = {'POWER_MANAGE': reset_file_name} - export_env_dict(power_manage_env, ofile, True) + export_env_dict(power_manage_env, output_path, True) if __name__ == "__main__": - if len(sys.argv) != 6: - print("parameter wrong%d %s" % (len(sys.argv), sys.argv)) + if len(sys.argv) != 7: + print("parameter wrong %d %s" % (len(sys.argv), sys.argv)) sys.exit(1) - _, dha_file, network_file, tmpl_dir, output_dir, output_file = sys.argv + _, dha_file, network_file, tmpl_dir, output_dir, output_file,\ + machine_file = sys.argv if not os.path.exists(dha_file): print("%s is not exist" % dha_file) sys.exit(1) - ofile = os.path.join(output_dir, output_file) - os.system("touch %s" % ofile) - os.system("echo \#config file deployment parameter > %s" % ofile) + output_path = os.path.join(output_dir, output_file) + machine_path = os.path.join(output_dir, machine_file) + os.system("touch %s" % output_path) + os.system("echo \#config file deployment parameter > %s" % output_path) + os.system("touch %s" % machine_path) - dha_data = init(dha_file) - network_data = init(network_file) + dha_data = load_yaml(dha_file) + network_data = load_yaml(network_file) - export_dha_file(dha_data, dha_file, ofile) - export_network_file(dha_data, network_data, ofile) - export_reset_file(dha_data, tmpl_dir, output_dir, ofile) + export_dha_file(dha_data, output_path, machine_path) + export_network_file(dha_data, network_data, output_path) + export_reset_file(dha_data, tmpl_dir, output_dir, output_path) sys.exit(0) diff --git a/deploy/deploy_host.sh b/deploy/deploy_host.sh index 94abf768..7a7b5dd5 100755 --- a/deploy/deploy_host.sh +++ b/deploy/deploy_host.sh @@ -43,7 +43,7 @@ function deploy_host(){ --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=${machines//\'} --switch_credential="${SWITCH_CREDENTIAL}" --deploy_type="${TYPE}" \ + --machine_file=${machine_file} --switch_credential="${SWITCH_CREDENTIAL}" --deploy_type="${TYPE}" \ --deployment_timeout="${DEPLOYMENT_TIMEOUT}" --${POLL_SWITCHES_FLAG} --dashboard_url="${DASHBOARD_URL}" \ --cluster_vip="${VIP}" --network_cfg="$NETWORK" --neutron_cfg="$NEUTRON" \ --enable_secgroup="${ENABLE_SECGROUP}" --enable_fwaas="${ENABLE_FWAAS}" --expansion="${EXPANSION}" \ diff --git a/deploy/deploy_parameter.sh b/deploy/deploy_parameter.sh index 78223fcd..d45d4171 100755 --- a/deploy/deploy_parameter.sh +++ b/deploy/deploy_parameter.sh @@ -100,7 +100,7 @@ function process_default_para() "$DHA" "$NETWORK" \ "${COMPASS_DIR}/deploy/template" \ "${WORK_DIR}/script" \ - "deploy_config.sh" + "deploy_config.sh" machine echo ${WORK_DIR}/script/deploy_config.sh } diff --git a/deploy/host_baremetal.sh b/deploy/host_baremetal.sh index 4c63f823..3c303567 100755 --- a/deploy/host_baremetal.sh +++ b/deploy/host_baremetal.sh @@ -15,14 +15,6 @@ function reboot_hosts() { } function get_host_macs() { - if [[ "$EXPANSION" == "false" ]]; then - machines=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'` - echo $machines > $WORK_DIR/switch_machines - else - machines_old=`cat $WORK_DIR/switch_machines` - machines_add=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'` - echo $machines_add $machines_old > $WORK_DIR/switch_machines - machines=`echo $machines_add $machines_old|sed 's/ /,/g'` - fi + local 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 d955b747..c3133cf6 100755 --- a/deploy/host_virtual.sh +++ b/deploy/host_virtual.sh @@ -25,20 +25,21 @@ function tear_down_machines() { } function reboot_hosts() { + echo "reboot" # We do need it for aarch64 - if [ "$COMPASS_ARCH" = "aarch64" ]; then - old_ifs=$IFS - IFS=, - for i in $HOSTNAMES; do - sudo virsh destroy $i - sleep 3 - sudo virsh start $i - sleep 3 - done - IFS=$old_ifs - else - log_warn "reboot_hosts do nothing" - fi +# if [ "$COMPASS_ARCH" = "aarch64" ]; then +# old_ifs=$IFS +# IFS=, +# for i in $HOSTNAMES; do +# sudo virsh destroy $i +# sleep 3 +# sudo virsh start $i +# sleep 3 +# done +# IFS=$old_ifs +# else +# log_warn "reboot_hosts do nothing" +# fi } function launch_host_vms() { @@ -97,37 +98,7 @@ function recover_host_vms() { } function get_host_macs() { - local mac_generator=${COMPASS_DIR}/deploy/mac_generator.sh - local machines= - - if [[ $REDEPLOY_HOST == "true" ]]; then - mac_array=`cat $WORK_DIR/switch_machines` - machines=`echo $mac_array|sed 's/ /,/g'` - else - if [[ -z $HOST_MACS ]]; then - if [[ "$EXPANSION" == "false" ]]; then - chmod +x $mac_generator - mac_array=`$mac_generator $VIRT_NUMBER` - echo $mac_array > $WORK_DIR/switch_machines - machines=`echo $mac_array|sed 's/ /,/g'` - else - machines_old=`cat $WORK_DIR/switch_machines` - chmod +x $mac_generator - machines_add=`$mac_generator $VIRT_NUMBER` - echo $machines_add $machines_old > $WORK_DIR/switch_machines - machines=`echo $machines_add $machines_old|sed 's/ /,/g'` - fi - else - if [[ "$EXPANSION" == "false" ]]; then - machines=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'` - else - machines_old=`cat $WORK_DIR/switch_machines` - machines_add=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'` - echo $machines_add $machines_old > $WORK_DIR/switch_machines - machines=`echo $machines_add $machines_old|sed 's/ /,/g'` - fi - fi - fi + local machines=`echo $HOST_MACS | sed -e 's/,/'\',\''/g' -e 's/^/'\''/g' -e 's/$/'\''/g'` echo $machines } diff --git a/deploy/launch.sh b/deploy/launch.sh index 8a009003..b11127ca 100755 --- a/deploy/launch.sh +++ b/deploy/launch.sh @@ -53,6 +53,7 @@ if [[ "$EXPANSION" == "false" ]]; then exit 1 fi + export machine_file=$WORK_DIR/script/machine export machines CONTAINER_ALIVE=$(check_container_alive) diff --git a/deploy/prepare.sh b/deploy/prepare.sh index 38d98e1d..f11ae74c 100755 --- a/deploy/prepare.sh +++ b/deploy/prepare.sh @@ -48,7 +48,14 @@ function extract_tar() function prepare_env() { sudo sed -i -e 's/^#user =.*/user = "root"/g' /etc/libvirt/qemu.conf sudo sed -i -e 's/^#group =.*/group = "root"/g' /etc/libvirt/qemu.conf + sudo sed -i 's/^.\?listen_tls.*/listen_tls = 0/g' /etc/libvirt/libvirtd.conf + sudo sed -i 's/^.\?listen_tcp.*/listen_tcp = 1/g' /etc/libvirt/libvirtd.conf + sudo sed -i 's/^.\?tcp_port.*/tcp_port = "16509"/g' /etc/libvirt/libvirtd.conf + sudo sed -i 's/^.\?listen_addr.*/listen_addr = "0.0.0.0"/g' /etc/libvirt/libvirtd.conf + sudo sed -i 's/^.\?auth_tcp.*/auth_tcp = "none"/g' /etc/libvirt/libvirtd.conf + sudo sed -i 's/^.\?libvirtd_opts.*/libvirtd_opts="-d -l"/g' /etc/default/libvirt-bin sudo service libvirt-bin restart + if sudo service openvswitch-switch status|grep stop; then sudo service openvswitch-switch start fi diff --git a/manager.py.patch b/manager.py.patch deleted file mode 100644 index 198ff5be..00000000 --- a/manager.py.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- manager.py 2018-11-07 03:51:22.764685289 -0800 -+++ manager.py.new 2018-11-07 03:58:21.014139558 -0800 -@@ -314,8 +314,7 @@ - if self._events is None: - # NOTE(danms): We really should have a more specific error - # here, but this is what we use for our default error case -- raise exception.NovaException('In shutdown, no new events ' -- 'can be scheduled') -+ self._events = {} - - @utils.synchronized(self._lock_name(instance)) - def _create_or_get_event(): diff --git a/plugins/onap/roles/tasks/Ubuntu.yml b/plugins/onap/roles/tasks/Ubuntu.yml new file mode 100644 index 00000000..a51e5f17 --- /dev/null +++ b/plugins/onap/roles/tasks/Ubuntu.yml @@ -0,0 +1,117 @@ +--- +- name: download helm + get_url: + url: "{{ helm_url }}" + dest: /tmp/helm.tar.gz + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: prepare helm + shell: + tar -zxf /tmp/helm.tar.gz -C /tmp; + mv /tmp/linux-amd64/helm /usr/local/bin/helm + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: install tiller + shell: > + kubectl create serviceaccount --namespace kube-system tiller; + kubectl create clusterrolebinding tiller-cluster-rule + --clusterrole=cluster-admin + --serviceaccount=kube-system:tiller; + helm init --service-account tiller + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: git clone oom + git: + repo: "{{ oom_repo }}" + dest: "{{ oom_dest }}" + version: "{{ oom_version }}" + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: prepare local repo + shell: + nohup /bin/sh -c "helm serve &" + while true; do curl -s 127.0.0.1:8879 > /dev/null; if [ $? -eq 0 ]; then break; fi; done + helm repo add local http://127.0.0.1:8879 + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: add helm plugin + shell: + cp -rf "{{ oom_dest }}/kubernetes/helm/plugins" ~/.helm/ + when: inventory_hostname == groups['kube_master'][0] + run_once: true + +- name: make + shell: + make all + args: + chdir: "{{ oom_dest }}/kubernetes" + when: inventory_hostname == groups['kube_master'][0] + +- name: install nfs master + apt: + pkg: "nfs-kernel-server" + state: "present" + update_cache: "yes" + when: inventory_hostname == groups['kube_master'][0] + +- name: create /dockerdata-nfs + file: + path: /dockerdata-nfs + owner: nobody + group: nogroup + state: directory + mode: 0777 + when: inventory_hostname == groups['kube_master'][0] + +- name: install nfs slave + apt: + pkg: "nfs-common" + state: "present" + update_cache: "yes" + when: inventory_hostname != groups['kube_master'][0] + +- name: create /dockerdata-nfs + file: + path: /dockerdata-nfs + state: directory + when: inventory_hostname != groups['kube_master'][0] + +- name: render /etc/exports + template: + src: exports.j2 + dest: /etc/exports + when: inventory_hostname == groups['kube_master'][0] + +- name: restart nfs service + shell: + exportfs -a; + systemctl restart nfs-kernel-server + when: inventory_hostname == groups['kube_master'][0] + +- name: register master hostname + debug: + msg: "{{ ip_settings[groups['kube_master'][0]]['external']['ip'] }}" + register: master_ip + +- name: + shell: + mount {{ master_ip.msg }}:/dockerdata-nfs /dockerdata-nfs/ + when: inventory_hostname != groups['kube_master'][0] + +# yamllint disable rule:line-length +- name: add mount info + lineinfile: + path: /etc/fstab + line: "{{ master_ip.msg }}:/dockerdata-nfs /dockerdata-nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0" + when: inventory_hostname != groups['kube_master'][0] +# yamllint enable rule:line-length + +- name: deploy onap + shell: + helm deploy dev local/onap --namespace onap + when: inventory_hostname == groups['kube_master'][0] diff --git a/plugins/onap/roles/tasks/main.yml b/plugins/onap/roles/tasks/main.yml new file mode 100644 index 00000000..c9e80427 --- /dev/null +++ b/plugins/onap/roles/tasks/main.yml @@ -0,0 +1,11 @@ +############################################################################# +# Copyright (c) 2019 Intel Corp. +# +# 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 +############################################################################# +--- +- include: "{{ ansible_distribution }}.yml" + when: onap is defined and onap == "Enable" diff --git a/plugins/onap/roles/templates/exports.j2 b/plugins/onap/roles/templates/exports.j2 new file mode 100644 index 00000000..8f5a3f65 --- /dev/null +++ b/plugins/onap/roles/templates/exports.j2 @@ -0,0 +1 @@ +/dockerdata-nfs{% for host in groups.all %}{% if host != groups.kube_master[0] %} {{ ip_settings[host]['external']['ip'] }}(rw,sync,no_root_squash,no_subtree_check){% endif %}{% endfor %} diff --git a/plugins/onap/roles/vars/main.yml b/plugins/onap/roles/vars/main.yml new file mode 100644 index 00000000..83b591a5 --- /dev/null +++ b/plugins/onap/roles/vars/main.yml @@ -0,0 +1,13 @@ +############################################################################# +# Copyright (c) 2019 HUAWEI TECHNOLOGIES CO.,LTD 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 +############################################################################## +--- +helm_url: https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz +oom_repo: https://gerrit.onap.org/r/oom +oom_dest: /home/oom +oom_version: casablanca diff --git a/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml b/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml index c0044322..d441f420 100644 --- a/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml +++ b/plugins/stor4nfv/roles/os-stor4nfv/tasks/post-install.yml @@ -140,3 +140,4 @@ osdsctl profile create '{"name": "default", "description": "default policy"}' when: - inventory_hostname in groups['ceph_adm'] + ignore_errors: "true" diff --git a/util/check_valid.py b/util/check_valid.py index e6a72e71..9348d272 100644 --- a/util/check_valid.py +++ b/util/check_valid.py @@ -98,25 +98,19 @@ def check_dha_file(dha): invalid = False if dha['TYPE'] == 'baremetal': for i in dha['hosts']: - if not is_valid_mac(i['mac']): - err_print('''invalid address: - hosts: - - name: %s - mac: %s''' % (i['name'], i['mac'])) - invalid = True for j in i['interfaces']: - if not is_valid_mac(j.values()[0]): + if not is_valid_mac(i['interfaces'].get(j)): err_print('''invalid address: hosts: - name: %s interfaces: - - %s: %s''' % (i['name'], j.keys()[0], j.values()[0])) # noqa: E501 + - %s: %s''' % (i['name'], j, i['interfaces'].get(j))) # noqa: E501 invalid = True - if not is_valid_ip(i['ipmiIp']): + if not is_valid_ip(i['power_ip']): err_print('''invalid address: hosts: - name: %s - ipmiIp: %s''' % (i['name'], i['ipmiIp'])) + power_ip: %s''' % (i['name'], i['power_ip'])) invalid = True if not invalid: diff --git a/util/docker-compose/roles/machines/tasks/main.yml b/util/docker-compose/roles/machines/tasks/main.yml index 365a9d90..7b4a9f18 100755 --- a/util/docker-compose/roles/machines/tasks/main.yml +++ b/util/docker-compose/roles/machines/tasks/main.yml @@ -1,21 +1,15 @@ --- -- name: create switch file if test mode enabled - template: src=switch_machines_file.j2 - dest="{{ docker_compose_dir }}/switch_machines_file" - tags: - - redploy - - name: docker cp switch_machines_file shell: | - docker cp "{{ docker_compose_dir }}/switch_machines_file" \ - compass-deck:/tmp/switch_machines_file + docker cp "{{ docker_compose_dir }}/machine" \ + compass-deck:/tmp/machine tags: - redploy - name: inject switches and mac addresses shell: | docker exec compass-deck bash -c \ - "/opt/compass/bin/manage_db.py set_switch_machines \ - --switch_machines_file /tmp/switch_machines_file" + "/opt/compass/bin/manage_db.py set_machine \ + --machine_file /tmp/machine" tags: - redploy |