Adapt network.yml to OpenStack Ansible 59/38259/14
authorHarry Huang <huangxiangyu5@huawei.com>
Tue, 25 Jul 2017 09:01:04 +0000 (17:01 +0800)
committerHarry Huang <huangxiangyu5@huawei.com>
Fri, 11 Aug 2017 07:06:29 +0000 (15:06 +0800)
JIRA:COMPASS-557

1. modify sys_intf_mappings and ip_settings in
network.yml to synchronize with OSA network.
networks compass build will be mgmt, external,
tenant, storage.
2. modify compass_conf to support new netwok.yml
3. fix some hard coding when transfer ip parameters
4. support heterogeneous network

Change-Id: Ib4a8af1f96a40e6456242e3dc2b456e0c8c17c2e
Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
22 files changed:
deploy/adapters/ansible/roles/config-compute/templates/compute.j2
deploy/adapters/ansible/roles/config-controller/templates/controller.j2
deploy/adapters/ansible/roles/config-osa/files/setup-ovs.yml
deploy/adapters/ansible/roles/config-osa/templates/openstack_user_config.yml.j2
deploy/adapters/ansible/roles/config-osa/templates/user_variables.yml.j2
deploy/adapters/ansible/roles/post-openstack/tasks/main.yml
deploy/adapters/ansible/roles/post-openstack/vars/main.yml
deploy/compass_conf/templates/ansible_installer/openstack_ocata/hosts/HA-ansible-multinodes.tmpl
deploy/compass_conf/templates/ansible_installer/openstack_ocata/vars/HA-ansible-multinodes.tmpl
deploy/compass_vm.sh
deploy/conf/base.conf
deploy/conf/compass.conf
deploy/conf/hardware_environment/huawei-pod1/network.yml
deploy/conf/vm_environment/huawei-virtual1/network.yml
deploy/conf/vm_environment/huawei-virtual2/network.yml
deploy/conf/vm_environment/network.yml
deploy/config_parse.py
deploy/deploy_host.sh
deploy/deploy_parameter.sh
deploy/host_virtual.sh
deploy/launch.sh
deploy/template/vm/host.xml

index 66c3297..c53708e 100644 (file)
@@ -5,21 +5,42 @@
 auto lo
 iface lo inet loopback
 
-
 # Physical interface
 auto eth0
 iface eth0 inet manual
 
+# external interface
+{% set intf_external = sys_intf_mappings["external"]["interface"] %}
+{% if sys_intf_mappings["external"]["vlan_tag"] != "None" %}
+{% set intf_external = intf_external + '.' + sys_intf_mappings["external"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_external }}
+iface {{ intf_external }} inet manual
+{% if sys_intf_mappings["external"]["vlan_tag"] != "None" %}
+    vlan-raw-device {{ intf_external }}
+{% endif %}
 
-# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface
-auto {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
-iface {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}} inet manual
-    vlan-raw-device {{sys_intf_mappings["mgmt"]["interface"]}}
+# tenant interface
+{% set intf_tenant = sys_intf_mappings["tenant"]["interface"] %}
+{% if sys_intf_mappings["tenant"]["interface"] != "None" %}
+{% set intf_tenant = intf_tenant + '.' + sys_intf_mappings["tenant"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_tenant }}
+iface {{ intf_tenant }} inet manual
+{% if sys_intf_mappings["tenant"]["interface"] != "None" %}
+    vlan-raw-device {{ intf_tenant }}
+{% endif %}
 
-# Storage network VLAN interface (optional)
-auto {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
-iface {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}} inet manual
-    vlan-raw-device {{sys_intf_mappings["storage"]["interface"]}}
+# storage interface
+{% set intf_storage = sys_intf_mappings["storage"]["interface"] %}
+{% if sys_intf_mappings["storage"]["interface"] != "None" %}
+{% set intf_storage = intf_storage + '.' + sys_intf_mappings["storage"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_storage }}
+iface {{ intf_storage }} inet manual
+{% if sys_intf_mappings["storage"]["interface"] != "None" %}
+    vlan-raw-device {{ intf_storage }}
+{% endif %}
 
 # Container/Host management bridge
 auto br-mgmt
@@ -28,29 +49,19 @@ iface br-mgmt inet static
     bridge_waitport 0
     bridge_fd 0
     bridge_ports eth0
-    address {{host_info[inventory_hostname].MGMT_IP}}
+    address {{ ip_settings[inventory_hostname]["mgmt"]["ip"] }}
     netmask 255.255.255.0
 
-# compute1 VXLAN (tunnel/overlay) bridge config
-auto br-vxlan
-iface br-vxlan inet static
-    bridge_stp off
-    bridge_waitport 0
-    bridge_fd 0
-    bridge_ports {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
-    address {{host_info[inventory_hostname].VXLAN_IP}}
-    netmask 255.255.252.0
-
 # OpenStack Networking VLAN bridge
-auto br-vlan
-iface br-vlan inet static
+auto br-external
+iface br-external inet static
     bridge_stp off
     bridge_waitport 0
     bridge_fd 0
-    bridge_ports {{ network_cfg["provider_net_mappings"][0]["interface"] }}
-    address {{ip_settings[inventory_hostname]["br-prv"]["ip"]}}
+    bridge_ports {{ intf_external }}
+    address {{ ip_settings[inventory_hostname]["external"]["ip"] }}
     netmask 255.255.255.0
-    gateway {{ip_settings[inventory_hostname]["br-prv"]["gw"]}}
+    gateway {{ ip_settings[inventory_hostname]["external"]["gw"] }}
     offload-sg off
     # Create veth pair, don't bomb if already exists
     pre-up ip link add br-vlan-veth type veth peer name eth12 || true
@@ -61,21 +72,22 @@ iface br-vlan inet static
     post-down ip link del br-vlan-veth || true
     bridge_ports br-vlan-veth
 
-# Add an additional address to br-vlan
-iface br-vlan inet static
-    # Flat network default gateway
-    # -- This needs to exist somewhere for network reachability
-    # -- from the router namespace for floating IP paths.
-    # -- Putting this here is primarily for tempest to work.
-    address {{host_info[inventory_hostname].VLAN_IP_SECOND}}
-    netmask 255.255.252.0
+# VXLAN (tunnel/overlay) bridge config
+auto br-tenant
+iface br-tenant inet static
+    bridge_stp off
+    bridge_waitport 0
+    bridge_fd 0
+    bridge_ports {{ intf_tenant }}
+    address {{ ip_settings[inventory_hostname]["tenant"]["ip"] }}
+    netmask 255.255.255.0
 
-# compute storage bridge
+# storage bridge
 auto br-storage
 iface br-storage inet static
     bridge_stp off
     bridge_waitport 0
     bridge_fd 0
-    bridge_ports {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
-    address {{ip_settings[inventory_hostname]["storage"]["ip"]}}
-    netmask 255.255.252.0
+    bridge_ports {{ intf_storage }}
+    address {{ ip_settings[inventory_hostname]["storage"]["ip"] }}
+    netmask 255.255.255.0
index 215807f..2aeb9a0 100755 (executable)
@@ -9,15 +9,38 @@ iface lo inet loopback
 auto eth0
 iface eth0 inet manual
 
-# OpenStack Networking VXLAN (tunnel/overlay) VLAN interface
-auto {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
-iface {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}} inet manual
-    vlan-raw-device {{sys_intf_mappings["mgmt"]["interface"]}}
+# external interface
+{% set intf_external = sys_intf_mappings["external"]["interface"] %}
+{% if sys_intf_mappings["external"]["vlan_tag"] != "None" %}
+{% set intf_external = intf_external + '.' + sys_intf_mappings["external"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_external }}
+iface {{ intf_external }} inet manual
+{% if sys_intf_mappings["external"]["vlan_tag"] != "None" %}
+    vlan-raw-device {{ intf_external }}
+{% endif %}
 
-# Storage network VLAN interface (optional)
-auto {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
-iface {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}} inet manual
-    vlan-raw-device {{sys_intf_mappings["storage"]["interface"]}}
+# tenant interface
+{% set intf_tenant = sys_intf_mappings["tenant"]["interface"] %}
+{% if sys_intf_mappings["tenant"]["interface"] != "None" %}
+{% set intf_tenant = intf_tenant + '.' + sys_intf_mappings["tenant"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_tenant }}
+iface {{ intf_tenant }} inet manual
+{% if sys_intf_mappings["tenant"]["interface"] != "None" %}
+    vlan-raw-device {{ intf_tenant }}
+{% endif %}
+
+# storage interface
+{% set intf_storage = sys_intf_mappings["storage"]["interface"] %}
+{% if sys_intf_mappings["storage"]["interface"] != "None" %}
+{% set intf_storage = intf_storage + '.' + sys_intf_mappings["storage"]["vlan_tag"]|string %}
+{% endif %}
+auto {{ intf_storage }}
+iface {{ intf_storage }} inet manual
+{% if sys_intf_mappings["storage"]["interface"] != "None" %}
+    vlan-raw-device {{ intf_storage }}
+{% endif %}
 
 # Container/Host management bridge
 auto br-mgmt
@@ -26,8 +49,19 @@ iface br-mgmt inet static
     bridge_waitport 0
     bridge_fd 0
     bridge_ports eth0
-    address {{host_info[inventory_hostname].MGMT_IP}}
+    address {{ ip_settings[inventory_hostname]["mgmt"]["ip"] }}
+    netmask 255.255.255.0
+
+# OpenStack Networking VLAN bridge
+auto br-external
+iface br-external inet static
+    bridge_stp off
+    bridge_waitport 0
+    bridge_fd 0
+    bridge_ports {{ intf_external }}
+    address {{ ip_settings[inventory_hostname]["external"]["ip"] }}
     netmask 255.255.255.0
+    gateway {{ ip_settings[inventory_hostname]["external"]["gw"] }}
 
 # OpenStack Networking VXLAN (tunnel/overlay) bridge
 #
@@ -36,30 +70,19 @@ iface br-mgmt inet static
 # IP addresses are assigned to containers which use this
 # bridge.
 #
-auto br-vxlan
-iface br-vxlan inet manual
+auto br-tenant
+iface br-tenant inet manual
     bridge_stp off
     bridge_waitport 0
     bridge_fd 0
-    bridge_ports {{sys_intf_mappings["mgmt"]["interface"]}}.{{sys_intf_mappings["mgmt"]["vlan_tag"]}}
+    bridge_ports {{ intf_tenant }}
 
-# OpenStack Networking VLAN bridge
-auto br-vlan
-iface br-vlan inet static
-    bridge_stp off
-    bridge_waitport 0
-    bridge_fd 0
-    bridge_ports {{ network_cfg["provider_net_mappings"][0]["interface"] }}
-    address {{ ip_settings[inventory_hostname]["br-prv"]["ip"] }}
-    netmask 255.255.255.0
-    gateway {{ ip_settings[inventory_hostname]["br-prv"]["gw"] }}
-
-# compute1 Storage bridge
+# Storage bridge
 auto br-storage
 iface br-storage inet static
     bridge_stp off
     bridge_waitport 0
     bridge_fd 0
-    bridge_ports {{sys_intf_mappings["storage"]["interface"]}}.{{sys_intf_mappings["storage"]["vlan_tag"]}}
+    bridge_ports {{ intf_storage }}
     address {{ ip_settings[inventory_hostname]["storage"]["ip"] }}
-    netmask 255.255.252.0
+    netmask 255.255.255.0
index 9f65cd5..e906ed4 100644 (file)
@@ -32,7 +32,7 @@
         dest: /etc/neutron/plugins/ml2/openvswitch_agent.ini
         regexp: '^bridge_mappings'
         insertafter: '^bridge_mappings'
-        line: "local_ip = {{hostvars[inventory_hostname]['ansible_br_vxlan']['ipv4']['address']}}"
+        line: "local_ip = {{hostvars[inventory_hostname]['ansible_br_tenant']['ipv4']['address']}}"
       notify:
         - Restart neutron-openvswitch-agent
       when:
index 2a24113..d69674f 100644 (file)
@@ -1,20 +1,25 @@
 ---
 cidr_networks:
-  container: 10.1.0.0/24
-  tunnel: 172.29.240.0/22
-  storage: 172.16.2.0/24
+  container: {{ mgmt_cidr }}
+  tunnel: {{ tenant_cidr }}
+  storage: {{ storage_cidr }}
 
 used_ips:
-  - "10.1.0.1,10.1.0.55"
-  - "10.1.0.100,10.1.0.110"
-  - "172.29.240.1,172.29.240.50"
-  - "172.16.2.1,172.16.2.50"
-  - "172.29.248.1,172.29.248.50"
+{% for item in network_cfg["ip_settings"] %}
+  - "{{ ','.join(item["ip_ranges"][0]) }}"
+{% if item["name"] == "mgmt" %}
+  - "{{ ','.join(item["dhcp_ranges"][0]) }}"
+{% endif %}
+{% if "gw" in item %}
+  - "{{ item["gw"] }}"
+{% endif %}
+{% endfor %}
+  - "{{ internal_vip.ip }}"
 
 global_overrides:
-  internal_lb_vip_address: 10.1.0.22
+  internal_lb_vip_address: {{ internal_vip.ip }}
   external_lb_vip_address: {{ public_vip.ip }}
-  tunnel_bridge: "br-vxlan"
+  tunnel_bridge: "br-tenant"
   management_bridge: "br-mgmt"
   provider_networks:
     - network:
@@ -29,7 +34,7 @@ global_overrides:
         is_container_address: true
         is_ssh_address: true
     - network:
-        container_bridge: "br-vxlan"
+        container_bridge: "br-tenant"
         container_type: "veth"
         container_interface: "eth10"
         ip_from_q: "tunnel"
@@ -43,7 +48,7 @@ global_overrides:
           - neutron_openvswitch_agent
 {% endif %}
     - network:
-        container_bridge: "br-vlan"
+        container_bridge: "br-external"
         container_type: "veth"
         container_interface: "eth12"
         host_bind_override: "eth12"
@@ -56,7 +61,7 @@ global_overrides:
           - neutron_openvswitch_agent
 {% endif %}
     - network:
-        container_bridge: "br-vlan"
+        container_bridge: "br-external"
         container_type: "veth"
         container_interface: "eth11"
         type: "vlan"
index 7f29d5f..2b4a959 100644 (file)
@@ -22,8 +22,8 @@
 debug: false
 
 haproxy_keepalived_external_vip_cidr: "{{ public_vip.ip }}/32"
-haproxy_keepalived_internal_vip_cidr: "10.1.0.22/32"
-haproxy_keepalived_external_interface: br-vlan
+haproxy_keepalived_internal_vip_cidr: "{{ internal_vip.ip }}/32"
+haproxy_keepalived_external_interface: br-external
 haproxy_keepalived_internal_interface: br-mgmt
 keepalived_ping_address: "{{ ntp_server }}"
 
index 10d8f72..6a8299d 100644 (file)
@@ -31,8 +31,8 @@
 - name: replace internalURL with publicURL in openrc
   replace:
     dest: /opt/openrc
-    regexp: "{{internal_vip}}"
-    replace: "{{ public_vip['ip']}}"
+    regexp: "{{ internal_vip['ip'] }}"
+    replace: "{{ public_vip['ip'] }}"
 
 - name: change the endpoint type
   replace:
index 19d9e22..d9c36d4 100644 (file)
@@ -7,7 +7,6 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-internal_vip: "10.1.0.22"
 flavors:
   - id: 0
     name: m1.nano
index 9d628b5..4c98066 100755 (executable)
 # controller
 #for worker in $controllers
     #set worker_hostname = $worker.hostname
-    #set worker_ip = $ip_settings[$worker_hostname].mgmt.ip
+    #set worker_ip = $ip_settings[$worker_hostname]["tenant"]["ip"]
 $worker_ip $worker_hostname
 #end for
 # compute
 #for worker in $computes
     #set worker_hostname = $worker.hostname
-    #set worker_ip = $ip_settings[$worker_hostname].mgmt.ip
+    #set worker_ip = $ip_settings[$worker_hostname]["tenant"]["ip"]
 $worker_ip $worker_hostname
 #end for
index 1fdc5d5..3e68e5a 100755 (executable)
 
 #set controllers = $getVar('controller', [])
 #set computes = $getVar('compute', [])
-#set vlan_ip_sec_start = $getVar('vlan_ip_sec_start', '173.29.241.1')
-#set vxlan_ip_start = $getVar('vxlan_ip_start', '172.29.240.13')
-
-#def ipadd($ip, $inc)
-    #set list = $ip.split('.')
-    #set $list[3] = str(int($list[3]) + $inc)
-    #set res = '.'.join($list)
-$res
-#end def
-
-#set host_info = {}
-#for host in controllers
-    #set $host_info[$host['hostname']] = {'MGMT_IP': $host['install']['ip']}
-#end for
-
-#set inc = 0
-#for host in computes
-    #set info = {}
-    #set $info['MGMT_IP'] = $host['install']['ip']
-    #set $info['VLAN_IP_SECOND'] = $ipadd($vlan_ip_sec_start, $inc).strip('\n').encode('utf-8')
-    #set $info['VXLAN_IP'] = $ipadd($vxlan_ip_start, $inc).strip('\n').encode('utf-8')
-    #set $host_info[$host['hostname']] = $info
-    #set $inc = $inc + 1
-#end for
-host_info: $host_info
 
 #set ip_settings={}
 #for k,v in $getVar('ip_settings', {}).items()
@@ -45,17 +20,34 @@ host_info: $host_info
 #set $ip_settings[$k]=$host_ip_settings
 #end for
 
+#for item in $network_cfg["ip_settings"]
+#if $item["name"] == "mgmt"
+#set mgmt_cfg = $item
+#end if
+#if $item["name"] == "external"
+#set external_cfg = $item
+#end if
+#if $item["name"] == "tenant"
+#set tenant_cfg = $item
+#end if
+#if $item["name"] == "storage"
+#set storage_cfg = $item
+#end if
+#end for
+
 #set neutron_cfg = $getVar('neutron_config', {})
 #set ovs_config = $neutron_cfg.openvswitch
 
 #set has = $getVar('ha', [])
 #set ha_vip = $getVar('ha_vip', [])
+
 run_dir: $getVar('run_dir', '')
 
 enable_secgroup: $getVar('enable_secgroup', True)
 enable_fwaas: $getVar('enable_fwaas', True)
 enable_vpnaas: $getVar('enable_vpnaas', True)
 odl_l3_agent: $getVar('odl_l3_agent', 'Disable')
+moon: $getVar('moon', 'Disable')
 ha_network: $getVar('ha_network', 'Disable')
 onos_nic: $getVar('onos_nic', 'eth2')
 onos_sfc: $getVar('onos_sfc', 'Disable')
@@ -64,9 +56,10 @@ network_cfg: $network_cfg
 sys_intf_mappings: $sys_intf_mappings
 deploy_type: $getVar('deploy_type', 'virtual')
 
-public_cidr: $computes[0]['install']['subnet']
-storage_cidr: "{{ ip_settings[inventory_hostname]['storage']['cidr'] }}"
-mgmt_cidr: "{{ ip_settings[inventory_hostname]['mgmt']['cidr'] }}"
+mgmt_cidr: $mgmt_cfg["cidr"]
+external_cidr: $external_cfg["cidr"]
+tenant_cidr: $tenant_cfg["cidr"]
+storage_cidr: $storage_cfg["cidr"]
 
 public_net_info: "{{ network_cfg.public_net_info }}"
 host_ip_settings: "{{ ip_settings[inventory_hostname] }}"
@@ -93,8 +86,8 @@ public_vip:
 db_host: "{{ internal_vip.ip }}"
 rabbit_host: "{{ internal_vip.ip }}"
 
-internal_ip: "{{ ip_settings[inventory_hostname]['mgmt']['ip'] }}"
-internal_nic: mgmt
+internal_ip: "{{ ip_settings[inventory_hostname]['tenant']['ip'] }}"
+internal_nic: tenant
 
 #set random_id = randint(1, 255)
 vrouter_id_internal: $random_id
@@ -111,7 +104,7 @@ dashboard_host: "{{ internal_ip }}"
 haproxy_hosts:
 #for $item in $has
 #set $hostname=$item["hostname"]
-  $hostname: $ip_settings[$hostname]["mgmt"]["ip"]
+  $hostname: $ip_settings[$hostname]["tenant"]["ip"]
 #end for
 
 host_index:
@@ -186,13 +179,6 @@ CONGRESS_PASS: $congress_pass
 DEMO_PASS: $demo_pass
 ADMIN_PASS: $admin_pass
 
-#set plugins = $getVar('plugins', [])
-#for item in plugins
-#set keys = $item.keys()
-#set values = $item.values()
-$keys[0]: $values[0]
-#end for
-
 #set neutron_service_plugins=['router']
 
 #if $getVar('enable_fwaas', True)
@@ -246,9 +232,3 @@ odl_base_features: ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'ma
 odl_extra_features: ['odl-l2switch-switch', 'odl-ovsdb-plugin', 'odl-ovsdb-openstack', 'odl-ovsdb-northbound','odl-dlux-core', 'odl-restconf-all', 'odl-mdsal-clustering', 'odl-openflowplugin-flow-services', 'odl-netconf-connector', 'odl-netconf-connector-ssh', 'jolokia-osgi']
 odl_features: "{{ odl_base_features + odl_extra_features }}"
 odl_api_port: 8080
-
-#set moon_cfg = $getVar('moon_cfg', {})
-moon_master: $moon_cfg.master.flag
-moon_slave: $moon_cfg.slave.flag
-moon_slave_name: $moon_cfg.slave.name
-moon_master_ip: $moon_cfg.slave.master_ip
index 5817345..6d97656 100755 (executable)
@@ -137,6 +137,11 @@ function launch_compass() {
     sed -i "s#^\(compass_db:\).*#\1 $COMPASS_DB#g" $group_vars
     sed -i "s#^\(compass_mq:\).*#\1 $COMPASS_MQ#g" $group_vars
 
+    sed -i "s#^\(host_ip:\).*#\1 $INSTALL_IP#g" $group_vars
+    sed -i "s#^\(install_subnet:\).*#\1 ${INSTALL_CIDR%/*}#g" $group_vars
+    sed -i "s#^\(install_prefix:\).*#\1 ${INSTALL_CIDR##*/}#g" $group_vars
+    sed -i "s#^\(install_netmask:\).*#\1 $INSTALL_NETMASK#g" $group_vars
+    sed -i "s#^\(install_ip_range:\).*#\1 $INSTALL_IP_RANGE#g" $group_vars
     ansible-playbook $WORK_DIR/installer/compass-docker-compose/bring_up_compass.yml
 }
 
index bdbea45..c2bf529 100644 (file)
@@ -3,11 +3,6 @@ export NEUTRON=${NEUTRON:-$COMPASS_DIR/deploy/conf/neutron_cfg.yaml}
 export NETWORK=${NETWORK:-$COMPASS_DIR/deploy/conf/network_cfg.yaml}
 export TAR_URL=${TAR_URL:-file://`pwd`/work/building/compass.tar.gz}
 export INSTALL_IP=${INSTALL_IP:-10.1.0.1}
-export INSTALL_MASK=${INSTALL_MASK:-255.255.255.0}
-export INSTALL_GW=${INSTALL_GW:-10.1.0.1}
-export INSTALL_IP_START=${INSTALL_IP_START:-10.1.0.1}
-export INSTALL_IP_END=${INSTALL_IP_END:-10.1.0.254}
-export MGMT_IP=${MGMT_IP:-10.1.0.1}
 export EXT_NAT_MASK=${EXT_NAT_MASK:-255.255.252.0}
 export EXT_NAT_GW=${EXT_NAT_GW:-192.16.1.1}
 export EXT_NAT_IP_START=${EXT_NAT_IP_START:-192.16.1.3}
@@ -28,34 +23,6 @@ export ENABLE_UBUNTU_THEME=${ENABLE_UBUNTU_THEME:-"true"}
 
 export EXPANSION=${EXPANSION:-"false"}
 
-function next_ip {
-    ip_addr=$1
-    ip_base="$(echo $ip_addr | cut -d. -f'1 2 3')"
-    ip_last="$(echo $ip_addr | cut -d. -f4)"
-    let ip_last_next=$ip_last+1
-    echo "${ip_base}.${ip_last_next}"
-}
-
-if [ -z "$HOST_NETWORKS" ]; then
-    IFS=, read -a HOSTNAME_LIST <<< "$HOSTNAMES"
-    MANAGE_IP=${MANAGEMENT_IP_START}
-    TENANT_IP=${TENANT_IP_START}
-    PUBLIC_IP=${PUBLIC_IP_START}
-    STORAGE_IP=${STORAGE_IP_START}
-    for HOSTNAME in ${HOSTNAME_LIST[@]}; do
-        if [ -z "$HOST_NETWORKS" ]; then
-            HOST_NETWORKS="${HOSTNAME}:${MANAGEMENT_INTERFACE}=${MANAGE_IP}|is_mgmt"
-        else
-            HOST_NETWORKS="${HOST_NETWORKS};${HOSTNAME}:${MANAGEMENT_INTERFACE}=${MANAGE_IP}|is_mgmt"
-        fi
-        MANAGE_IP=$(next_ip ${MANAGE_IP})
-        TENANT_IP=$(next_ip ${TENANT_IP})
-        PUBLIC_IP=$(next_ip ${PUBLIC_IP})
-        STORAGE_IP=$(next_ip ${STORAGE_IP})
-    done
-    export HOST_NETWORKS
-fi
-
 export NETWORK_MAPPING=${NETWORK_MAPPING:-"install=${MANAGEMENT_INTERFACE}"}
 
 export PROXY=""
index 4ea087d..4102fb9 100644 (file)
@@ -1,8 +1,8 @@
 export COMPASS_VIRT_CPUS=4
 export COMPASS_VIRT_MEM=4096
 export COMPASS_SERVER=$INSTALL_IP
-export COMPASS_SERVER_URL="http://$MGMT_IP:5050/api"
-export HTTP_SERVER_URL="http://$MGMT_IP:5050/api"
+export COMPASS_SERVER_URL="http://$INSTALL_IP:5050/api"
+export HTTP_SERVER_URL="http://$INSTALL_IP:5050/api"
 export COMPASS_USER_EMAIL="admin@huawei.com"
 export COMPASS_USER_PASSWORD="admin"
 export COMPASS_DNS1=${COMPASS_DNS1:-'8.8.8.8'}
index f6deed4..cba041d 100644 (file)
@@ -12,7 +12,7 @@ nic_mappings: []
 bond_mappings: []
 
 provider_net_mappings:
-  - name: br-prv
+  - name: br-provider
     network: physnet
     interface: eth1
     type: ovs
@@ -22,9 +22,15 @@ provider_net_mappings:
 
 sys_intf_mappings:
   - name: mgmt
+    interface: eth0
+    vlan_tag: None
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     interface: eth1
     vlan_tag: 101
-    type: vlan
     role:
       - controller
       - compute
@@ -32,20 +38,32 @@ sys_intf_mappings:
   - name: storage
     interface: eth1
     vlan_tag: 102
-    type: vlan
     role:
       - controller
       - compute
 
   - name: external
-    interface: br-prv
-    type: ovs
+    interface: eth1
+    vlan_tag: None
     role:
       - controller
       - compute
 
 ip_settings:
   - name: mgmt
+    ip_ranges:
+      - - "10.1.0.100"
+        - "10.1.0.220"
+    dhcp_ranges:
+      - - "10.1.0.2"
+        - "10.1.0.49"
+    cidr: "10.1.0.0/24"
+    gw: "10.1.0.1"
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     ip_ranges:
       - - "172.16.1.1"
         - "172.16.1.254"
@@ -74,12 +92,12 @@ ip_settings:
       - compute
 
 internal_vip:
-  ip: 172.16.1.222
+  ip: 10.1.0.222
   netmask: "24"
   interface: mgmt
 
 public_vip:
-  ip: 192.168.10.51
+  ip: 192.16.1.222
   netmask: "24"
   interface: external
 
@@ -88,7 +106,7 @@ public_net_info:
   enable: "True"
   network: ext-net
   type: flat
-  segment_id: 10
+  segment_id: 1000
   subnet: ext-subnet
   provider_network: physnet
   router: router-ext
index ab485a8..fe5f8b5 100644 (file)
@@ -12,7 +12,7 @@ nic_mappings: []
 bond_mappings: []
 
 provider_net_mappings:
-  - name: br-prv
+  - name: br-provider
     network: physnet
     interface: eth1
     type: ovs
@@ -22,9 +22,15 @@ provider_net_mappings:
 
 sys_intf_mappings:
   - name: mgmt
+    interface: eth0
+    vlan_tag: None
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     interface: eth1
     vlan_tag: 101
-    type: vlan
     role:
       - controller
       - compute
@@ -32,23 +38,35 @@ sys_intf_mappings:
   - name: storage
     interface: eth1
     vlan_tag: 102
-    type: vlan
     role:
       - controller
       - compute
 
   - name: external
-    interface: br-prv
-    type: ovs
+    interface: eth1
+    vlan_tag: None
     role:
       - controller
       - compute
 
 ip_settings:
   - name: mgmt
+    ip_ranges:
+      - - "10.1.0.50"
+        - "10.1.0.100"
+    dhcp_ranges:
+      - - "10.1.0.2"
+        - "10.1.0.49"
+    cidr: "10.1.0.0/24"
+    gw: "10.1.0.1"
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     ip_ranges:
       - - "172.16.1.1"
-        - "172.16.1.254"
+        - "172.16.1.50"
     cidr: "172.16.1.0/24"
     role:
       - controller
@@ -57,7 +75,7 @@ ip_settings:
   - name: storage
     ip_ranges:
       - - "172.16.2.1"
-        - "172.16.2.254"
+        - "172.16.2.50"
     cidr: "172.16.2.0/24"
     role:
       - controller
@@ -74,7 +92,7 @@ ip_settings:
       - compute
 
 internal_vip:
-  ip: 172.16.1.222
+  ip: 10.1.0.222
   netmask: "24"
   interface: mgmt
 
@@ -88,7 +106,7 @@ public_net_info:
   enable: "True"
   network: ext-net
   type: flat
-  segment_id: 1000
+  segment_id: 10
   subnet: ext-subnet
   provider_network: physnet
   router: router-ext
index ab485a8..fe5f8b5 100644 (file)
@@ -12,7 +12,7 @@ nic_mappings: []
 bond_mappings: []
 
 provider_net_mappings:
-  - name: br-prv
+  - name: br-provider
     network: physnet
     interface: eth1
     type: ovs
@@ -22,9 +22,15 @@ provider_net_mappings:
 
 sys_intf_mappings:
   - name: mgmt
+    interface: eth0
+    vlan_tag: None
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     interface: eth1
     vlan_tag: 101
-    type: vlan
     role:
       - controller
       - compute
@@ -32,23 +38,35 @@ sys_intf_mappings:
   - name: storage
     interface: eth1
     vlan_tag: 102
-    type: vlan
     role:
       - controller
       - compute
 
   - name: external
-    interface: br-prv
-    type: ovs
+    interface: eth1
+    vlan_tag: None
     role:
       - controller
       - compute
 
 ip_settings:
   - name: mgmt
+    ip_ranges:
+      - - "10.1.0.50"
+        - "10.1.0.100"
+    dhcp_ranges:
+      - - "10.1.0.2"
+        - "10.1.0.49"
+    cidr: "10.1.0.0/24"
+    gw: "10.1.0.1"
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     ip_ranges:
       - - "172.16.1.1"
-        - "172.16.1.254"
+        - "172.16.1.50"
     cidr: "172.16.1.0/24"
     role:
       - controller
@@ -57,7 +75,7 @@ ip_settings:
   - name: storage
     ip_ranges:
       - - "172.16.2.1"
-        - "172.16.2.254"
+        - "172.16.2.50"
     cidr: "172.16.2.0/24"
     role:
       - controller
@@ -74,7 +92,7 @@ ip_settings:
       - compute
 
 internal_vip:
-  ip: 172.16.1.222
+  ip: 10.1.0.222
   netmask: "24"
   interface: mgmt
 
@@ -88,7 +106,7 @@ public_net_info:
   enable: "True"
   network: ext-net
   type: flat
-  segment_id: 1000
+  segment_id: 10
   subnet: ext-subnet
   provider_network: physnet
   router: router-ext
index ab485a8..fe5f8b5 100644 (file)
@@ -12,7 +12,7 @@ nic_mappings: []
 bond_mappings: []
 
 provider_net_mappings:
-  - name: br-prv
+  - name: br-provider
     network: physnet
     interface: eth1
     type: ovs
@@ -22,9 +22,15 @@ provider_net_mappings:
 
 sys_intf_mappings:
   - name: mgmt
+    interface: eth0
+    vlan_tag: None
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     interface: eth1
     vlan_tag: 101
-    type: vlan
     role:
       - controller
       - compute
@@ -32,23 +38,35 @@ sys_intf_mappings:
   - name: storage
     interface: eth1
     vlan_tag: 102
-    type: vlan
     role:
       - controller
       - compute
 
   - name: external
-    interface: br-prv
-    type: ovs
+    interface: eth1
+    vlan_tag: None
     role:
       - controller
       - compute
 
 ip_settings:
   - name: mgmt
+    ip_ranges:
+      - - "10.1.0.50"
+        - "10.1.0.100"
+    dhcp_ranges:
+      - - "10.1.0.2"
+        - "10.1.0.49"
+    cidr: "10.1.0.0/24"
+    gw: "10.1.0.1"
+    role:
+      - controller
+      - compute
+
+  - name: tenant
     ip_ranges:
       - - "172.16.1.1"
-        - "172.16.1.254"
+        - "172.16.1.50"
     cidr: "172.16.1.0/24"
     role:
       - controller
@@ -57,7 +75,7 @@ ip_settings:
   - name: storage
     ip_ranges:
       - - "172.16.2.1"
-        - "172.16.2.254"
+        - "172.16.2.50"
     cidr: "172.16.2.0/24"
     role:
       - controller
@@ -74,7 +92,7 @@ ip_settings:
       - compute
 
 internal_vip:
-  ip: 172.16.1.222
+  ip: 10.1.0.222
   netmask: "24"
   interface: mgmt
 
@@ -88,7 +106,7 @@ public_net_info:
   enable: "True"
   network: ext-net
   type: flat
-  segment_id: 1000
+  segment_id: 10
   subnet: ext-subnet
   provider_network: physnet
   router: router-ext
index 8a1ac54..3d8dedc 100644 (file)
@@ -8,16 +8,30 @@
 ##############################################################################
 
 import os
+import netaddr
 import yaml
 import sys
 from Cheetah.Template import Template
 
+PXE_INTF = "eth0"
+
 
 def init(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)
+    if direct:
+        for k, v in env_dict.items():
+            os.system("echo 'export %s=\"%s\"' >> %s" % (k, v, ofile))
+    else:
+        for k, v in env_dict.items():
+            os.system("echo 'export %s=${%s:-%s}' >> %s" % (k, k, v, ofile))
+
+
 def decorator(func):
     def wrapter(s, seq):
         host_list = s.get('hosts', [])
@@ -49,9 +63,38 @@ def hostmacs(s, seq, host=None):
     return host.get('mac', '')
 
 
-def export_dha_file(s, dha_file, conf_dir, ofile):
+def export_network_file(dha, network, ofile):
+    env = {}
+
+    mgmt_net = [item for item in network['ip_settings']
+                if item['name'] == 'mgmt'][0]
+    mgmt_gw = mgmt_net['gw']
+    mgmt_cidr = mgmt_net['cidr']
+    prefix = int(mgmt_cidr.split('/')[1])
+    mgmt_netmask = '.'.join([str((0xffffffff << (32 - prefix) >> i) & 0xff)
+                             for i in [24, 16, 8, 0]])
+    dhcp_ip_range = ' '.join(mgmt_net['dhcp_ranges'][0])
+    env.update({'INSTALL_GW': mgmt_gw})
+    env.update({'INSTALL_CIDR': mgmt_cidr})
+    env.update({'INSTALL_NETMASK': mgmt_netmask})
+    env.update({'INSTALL_IP_RANGE': dhcp_ip_range})
+    export_env_dict(env, ofile)
+
+    host_ip_range = mgmt_net['ip_ranges'][0]
+    host_ips = netaddr.iter_iprange(host_ip_range[0], host_ip_range[1])
+    host_networks = []
+    for host in dha['hosts']:
+        host_name = host['name']
+        host_ip = str(host_ips.next())
+        host_networks.append(
+            "{0}:{1}={2}|is_mgmt".format(host_name, PXE_INTF, host_ip))
+    host_network_env = {"HOST_NETWORKS": ';'.join(host_networks)}
+    export_env_dict(host_network_env, ofile, True)
+
+
+def export_dha_file(dha, dha_file, ofile):
     env = {}
-    env.update(s)
+    env.update(dha)
     if env.get('hosts', []):
         env.pop('hosts')
     if 'plugins' in env:
@@ -61,23 +104,21 @@ def export_dha_file(s, dha_file, conf_dir, ofile):
             plugin_list.append(plugin_str)
         env.update({'plugins': ','.join(plugin_list)})
 
-    env.update({'TYPE': s.get('TYPE', "virtual")})
-    env.update({'FLAVOR': s.get('FLAVOR', "cluster")})
-    env.update({'HOSTNAMES': hostnames(s, ',')})
-    env.update({'HOST_ROLES': hostroles(s, ';')})
+    env.update({'TYPE': dha.get('TYPE', "virtual")})
+    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(s, ',')
+    value = hostmacs(dha, ',')
     if len(value) > 0:
         env.update({'HOST_MACS': value})
 
-    os.system("echo \#config file deployment parameter > %s" % ofile)
-    for k, v in env.items():
-        os.system("echo 'export %s=${%s:-%s}' >> %s" % (k, k, v, ofile))
+    export_env_dict(env, ofile)
 
 
-def export_reset_file(s, tmpl_dir, output_dir, output_file):
-    tmpl_file_name = s.get('POWER_TOOL', '')
+def export_reset_file(dha, tmpl_dir, output_dir, ofile):
+    tmpl_file_name = dha.get('POWER_TOOL', '')
     if not tmpl_file_name:
         return
 
@@ -87,42 +128,35 @@ def export_reset_file(s, tmpl_dir, output_dir, output_file):
             'power',
             tmpl_file_name +
             '.tmpl'),
-        searchList=s)
+        searchList=dha)
 
     reset_file_name = os.path.join(output_dir, tmpl_file_name + '.sh')
     with open(reset_file_name, 'w') as f:
         f.write(tmpl.respond())
 
-    os.system(
-        "echo 'export POWER_MANAGE=%s' >> %s" %
-        (reset_file_name, output_file))
+    power_manage_env = {'POWER_MANAGE': reset_file_name}
+    export_env_dict(power_manage_env, ofile, True)
 
 if __name__ == "__main__":
     if len(sys.argv) != 6:
         print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
         sys.exit(1)
 
-    _, dha_file, conf_dir, tmpl_dir, output_dir, output_file = sys.argv
+    _, dha_file, network_file, tmpl_dir, output_dir, output_file = sys.argv
 
     if not os.path.exists(dha_file):
         print("%s is not exist" % dha_file)
         sys.exit(1)
 
-    data = init(dha_file)
-
-    export_dha_file(
-        data,
-        dha_file,
-        conf_dir,
-        os.path.join(
-            output_dir,
-            output_file))
-    export_reset_file(
-        data,
-        tmpl_dir,
-        output_dir,
-        os.path.join(
-            output_dir,
-            output_file))
+    ofile = os.path.join(output_dir, output_file)
+    os.system("touch %s" % ofile)
+    os.system("echo \#config file deployment parameter > %s" % ofile)
+
+    dha_data = init(dha_file)
+    network_data = init(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)
 
     sys.exit(0)
index aa90dca..5fa950c 100755 (executable)
 rsa_file=$compass_vm_dir/boot.rsa
 
 function rename_nics(){
-    python $COMPASS_DIR/deploy/rename_nics.py $DHA $rsa_file $MGMT_IP $OS_VERSION
+    python $COMPASS_DIR/deploy/rename_nics.py $DHA $rsa_file $INSTALL_IP $OS_VERSION
 }
 
 function add_bonding(){
-    python $COMPASS_DIR/deploy/bonding.py $NETWORK $rsa_file $MGMT_IP
+    python $COMPASS_DIR/deploy/bonding.py $NETWORK $rsa_file $INSTALL_IP
 }
 
 function deploy_host(){
index 92e3467..78223fc 100755 (executable)
@@ -97,7 +97,7 @@ function process_default_para()
 
     get_conf_name $*
     python ${COMPASS_DIR}/deploy/config_parse.py \
-           "$DHA" "$conf_dir" \
+           "$DHA" "$NETWORK" \
            "${COMPASS_DIR}/deploy/template" \
            "${WORK_DIR}/script" \
            "deploy_config.sh"
index 52f8a7b..bd2f49a 100755 (executable)
@@ -43,7 +43,6 @@ function launch_host_vms() {
           -e "s/REPLACE_BOOT_MAC/${mac_array[i]}/g" \
           -e "s/REPLACE_NET_INSTALL/install/g" \
           -e "s/REPLACE_NET_IAAS/external_nat/g" \
-          -e "s/REPLACE_NET_TENANT/external_nat/g" \
           $COMPASS_DIR/deploy/template/vm/host.xml\
           > $vm_dir/libvirt.xml
 
index 8bba340..6cbad1f 100755 (executable)
@@ -104,15 +104,6 @@ if [[ "$DEPLOY_HOST" == "true" || $REDEPLOY_HOST == "true" ]]; then
     echo $HOST_ROLES
     echo $TYPE
     echo $DHA
-    if [[ `echo $HOST_ROLES | grep opencontrail` ]]; then
-        ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
-        vgw_ip=$(sshpass -p 'root' ssh $ssh_options root@$MGMT_IP 'cat /home/opencontrail1.rc')
-        externet_cidr=$(sshpass -p 'root' ssh $ssh_options root@$MGMT_IP 'cat /home/opencontrail2.rc')
-        sudo ip route add $externet_cidr via $vgw_ip dev br-external 2>/dev/null
-        sleep 60
-        sudo python ${COMPASS_DIR}/deploy/reset_compute.py $TYPE $DHA
-        sleep 600
-    fi
 fi
 
 public_vip=$(get_public_vip)
index 092f0ec..059e46b 100644 (file)
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </interface>
     <interface type='network'>
-      <source network='REPLACE_NET_TENANT'/>
+      <source network='default'/>
       <model type='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
     </interface>
+    <interface type='network'>
+      <source network='default'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+    </interface>
     <serial type='pty'>
       <source path='/dev/pts/0'/>
     </serial>