Create Deployment Hardware Adapter (DHA) file for compass 87/2987/5
authorbaigk <baiguoku@huawei.com>
Tue, 3 Nov 2015 07:23:52 +0000 (23:23 -0800)
committerbaigk <baiguoku@huawei.com>
Tue, 3 Nov 2015 16:47:58 +0000 (08:47 -0800)
JIRA: COMPASS-132

Change-Id: I8e3f73b93acd8dae9f40dd43548679bc2eb1ea3c
Signed-off-by: baigk <baiguoku@huawei.com>
deploy/conf/hardware_environment/huawei_us_lab/pod1/dha.yml [new file with mode: 0644]
deploy/conf/hardware_environment/huawei_us_lab/pod1/network.yml [new file with mode: 0644]
deploy/config_parse.py
deploy/deploy_host.sh
deploy/deploy_parameter.sh
deploy/launch.sh

diff --git a/deploy/conf/hardware_environment/huawei_us_lab/pod1/dha.yml b/deploy/conf/hardware_environment/huawei_us_lab/pod1/dha.yml
new file mode 100644 (file)
index 0000000..0d5e9b4
--- /dev/null
@@ -0,0 +1,42 @@
+
+TYPE: baremetal
+FLAVOR: cluster
+POWER_TOOL: ipmitool
+
+ipmiUser: root
+ipmiPass: root
+ipmiVer: '2.0'
+
+hosts:
+  - name: host1
+    mac: '80:FB:06:35:8C:84'
+    ipmiIp: 10.145.140.201
+    roles:
+      - controller
+      - ha
+
+  - name: host2
+    mac: '4C:B1:6C:90:57:CF'
+    ipmiIp: 10.145.140.202
+    roles:
+      - controller
+      - ha
+
+  - name: host3
+    mac: '4C:B1:6C:90:57:E4'
+    ipmiIp: 10.145.140.203
+    roles:
+      - controller
+      - ha
+
+  - name: host4
+    mac: '4C:B1:6C:90:57:D8'
+    ipmiIp: 10.145.140.204
+    roles:
+      - compute
+
+  - name: host5
+    mac: '4C:B1:6C:90:57:D2'
+    ipmiIp: 10.145.140.205
+    roles:
+      - compute
diff --git a/deploy/conf/hardware_environment/huawei_us_lab/pod1/network.yml b/deploy/conf/hardware_environment/huawei_us_lab/pod1/network.yml
new file mode 100644 (file)
index 0000000..38e5b6e
--- /dev/null
@@ -0,0 +1,90 @@
+nic_mappings: []
+bond_mappings: []
+
+provider_net_mappings:
+  - name: br-prv
+    network: physnet
+    interface: eth1
+    type: ovs
+    role:
+      - controller
+      - compute
+
+sys_intf_mappings:
+  - name: mgmt
+    interface: eth1
+    vlan_tag: 101
+    type: vlan
+    role:
+      - controller
+      - compute
+
+  - name: storage
+    interface: eth1
+    vlan_tag: 102
+    type: vlan
+    role:
+      - controller
+      - compute
+
+  - name: external
+    interface: br-prv
+    vlan_tag: 1411
+    type: vlan
+    role:
+      - controller
+      - compute
+
+ip_settings:
+  - name: mgmt
+    ip_ranges:
+    - - "172.16.1.1"
+      - "172.16.1.254"
+    cidr: "172.16.1.0/24"
+    role:
+      - controller
+      - compute
+
+  - name: storage
+    ip_ranges:
+    - - "172.16.2.1"
+      - "172.16.2.254"
+    cidr: "172.16.2.0/24"
+    role:
+      - controller
+      - compute
+
+  - name: external
+    ip_ranges:
+    - - "10.145.140.100"
+      - "10.145.140.110"
+    cidr: "10.145.140.0/23"
+    gw: "10.145.140.1"
+    role:
+      - controller
+      - compute
+
+internal_vip:
+  ip: 172.16.1.222
+  netmask: "24"
+  interface: mgmt
+
+public_vip:
+  ip: 10.145.140.111
+  netmask: "23"
+  interface: external
+
+public_net_info:
+  enable: False
+  network: ext-net
+  type: vlan
+  segment_id: 1000
+  subnet: ext-subnet
+  provider_network: physnet
+  router: router-ext
+  enable_dhcp: False
+  no_gateway: False
+  external_gw: "192.168.50.1"
+  floating_ip_cidr: "192.168.50.0/24"
+  floating_ip_start: "192.168.50.221"
+  floating_ip_end: "192.168.50.231"
index f6c0dfa..172388c 100644 (file)
@@ -34,12 +34,15 @@ def hostroles(s, seq, host=None):
 def hostmacs(s, seq, host=None):
     return host.get('mac', '')
 
-def export_config_file(s, ofile):
+def export_config_file(s, conf_dir, ofile):
     env = {}
     env.update(s)
     if env.get('hosts', []):
         env.pop('hosts')
 
+    env.update({'NEUTRON': os.path.join(conf_dir, "neutron_cfg.yaml")})
+    env.update({'NETWORK': os.path.join(conf_dir, "network_cfg.yaml")})
+
     env.update({'TYPE': s.get('TYPE', "virtual")})
     env.update({'FLAVOR': s.get('FLAVOR', "cluster")})
     env.update({'HOSTNAMES': hostnames(s, ',')})
@@ -67,19 +70,19 @@ def export_reset_file(s, tmpl_dir, output_dir, output_file):
     os.system("echo 'export POWER_MANAGE=%s' >> %s" % (reset_file_name, output_file))
 
 if __name__ == "__main__":
-    if len(sys.argv) != 5:
+    if len(sys.argv) != 6:
         print("parameter wrong%d %s" % (len(sys.argv), sys.argv))
         sys.exit(1)
 
-    _, config_file, tmpl_dir, output_dir, output_file = sys.argv
-    config_file += '.yml'
+    _, config_file, conf_dir, tmpl_dir, output_dir, output_file = sys.argv
+
     if not os.path.exists(config_file):
         print("%s is not exist" % config_file)
         sys.exit(1)
 
     data = init(config_file)
 
-    export_config_file(data, os.path.join(output_dir, output_file))
+    export_config_file(data, conf_dir, os.path.join(output_dir, output_file))
     export_reset_file(data, tmpl_dir, output_dir, os.path.join(output_dir, output_file))
 
     sys.exit(0)
index a055702..02a53cd 100644 (file)
@@ -1,8 +1,5 @@
 function deploy_host(){
-    NETWORK_FILE=${COMPASS_DIR}/deploy/conf/network_cfg.yaml
-    NEUTRON_FILE=${COMPASS_DIR}/deploy/conf/neutron_cfg.yaml
 
-    pip install oslo.config
     ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/compass/bin/ansible_callbacks
     scp $ssh_args -r ${COMPASS_DIR}/deploy/status_callback.py root@${MGMT_IP}:/opt/compass/bin/ansible_callbacks/status_callback.py
 
@@ -25,6 +22,6 @@ function deploy_host(){
     --host_roles="${HOST_ROLES}" --default_roles="${DEFAULT_ROLES}" --switch_ips="${SWITCH_IPS}" \
     --machines=${machines//\'} --switch_credential="${SWITCH_CREDENTIAL}" --deploy_type="${TYPE}" \
     --deployment_timeout="${DEPLOYMENT_TIMEOUT}" --${POLL_SWITCHES_FLAG} --dashboard_url="${DASHBOARD_URL}" \
-    --cluster_vip="${VIP}" --network_cfg="$NETWORK_FILE" --neutron_cfg="$NEUTRON_FILE"
+    --cluster_vip="${VIP}" --network_cfg="$NETWORK" --neutron_cfg="$NEUTRON"
 
 }
index 8fade10..8b2e769 100755 (executable)
@@ -12,11 +12,15 @@ function get_option_flag_list()
 
 function get_conf_name()
 {
+    if [[ -n $DHA ]]; then
+        return
+    fi
+
     cfg_file=`ls $COMPASS_DIR/deploy/conf/*.conf`
     option_name=`get_option_name_list "$cfg_file"`
     option_flag=`get_option_flag_list "$option_name"`
 
-    TEMP=`getopt -o h -l $option_flag -n 'deploy_parameter.sh' -- "$@"`
+    TEMP=`getopt -o h -l dha:,network:,neutron:,conf-dir:,$option_flag -n 'deploy_parameter.sh' -- "$@"`
 
     if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
     eval set -- "$TEMP"
@@ -29,11 +33,20 @@ function get_conf_name()
     done
 
     if [[ $# -eq 0 ]]; then
-        echo "virtual_cluster"
+        export DHA="$COMPASS_DIR/deploy/conf/virtual_cluster.yml"
     elif [[ "$1" == "five" ]];then
-        echo "virtual_five"
+        export DHA="$COMPASS_DIR/deploy/conf/virtual_five.yml"
     else
-        echo $1
+        file=${1%*.yml}.yml
+        if [[ -f $file ]]; then
+            export DHA=$file
+        elif [[ -f $CONF_DIR/$file ]]; then
+            export DHA=$CONF_DIR/$file
+        elif [[ -f $COMPASS_DIR/deploy/conf/$file ]]; then
+            export DHA=$COMPASS_DIR/deploy/conf/$file
+        else
+            exit 1
+        fi
     fi
 }
 
@@ -47,7 +60,7 @@ function generate_input_env_file()
     option_name=`get_option_name_list "$cfg_file"`
     option_flag=`get_option_flag_list "$option_name"`
 
-    TEMP=`getopt -o h -l conf-name:,$option_flag -n 'deploy_parameter.sh' -- "$@"`
+    TEMP=`getopt -o h -l dha:,network:,neutron:,conf-dir:,$option_flag -n 'deploy_parameter.sh' -- "$@"`
 
     if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
     eval set -- "$TEMP"
@@ -58,15 +71,10 @@ function generate_input_env_file()
         fi
 
         option=`echo ${1##-?} | tr [:lower:] [:upper:] | sed 's/-/_/g'`
-        echo "$option_name" | grep -w $option > /dev/null
-        if [[ $? -eq 0 ]]; then
-            echo "export $option=$2" >> $ofile
-            shift 2
-            continue
-        fi
+        echo "export $option=$2" >> $ofile
+        shift 2
+        continue
 
-        echo "Internal error!"
-        exit 1
     done
 
     echo $ofile
@@ -74,8 +82,15 @@ function generate_input_env_file()
 
 function process_default_para()
 {
+    if [[ -z $CONF_DIR ]]; then
+         local set conf_dir=${COMPASS_DIR}/deploy/conf
+    else
+         local set conf_dir=$CONF_DIR
+    fi
+
+    get_conf_name $*
     python ${COMPASS_DIR}/deploy/config_parse.py \
-           "${COMPASS_DIR}/deploy/conf/`get_conf_name $*`" \
+           "$DHA" "$conf_dir" \
            "${COMPASS_DIR}/deploy/template" \
            "${WORK_DIR}/script" \
            "deploy_config.sh"
index d191766..bad03cf 100755 (executable)
@@ -5,8 +5,8 @@ mkdir -p $WORK_DIR/script
 
 source ${COMPASS_DIR}/util/log.sh
 source ${COMPASS_DIR}/deploy/deploy_parameter.sh
-source $(process_default_para $*) || exit 1
 source $(process_input_para $*) || exit 1
+source $(process_default_para $*) || exit 1
 source ${COMPASS_DIR}/deploy/conf/${FLAVOR}.conf
 source ${COMPASS_DIR}/deploy/conf/${TYPE}.conf
 source ${COMPASS_DIR}/deploy/conf/base.conf