Adapting BGPVPN scenario to new composable service
[apex.git] / lib / overcloud-deploy-functions.sh
index 1301e2c..d2ae027 100755 (executable)
@@ -29,32 +29,39 @@ function overcloud_deploy {
     if [ "${deploy_options_array['sfc']}" == 'True' ]; then
       DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight_sfc.yaml"
     elif [ "${deploy_options_array['vpn']}" == 'True' ]; then
-      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-bgpvpn.yaml"
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-bgpvpn-opendaylight.yaml"
       if [ "${deploy_options_array['gluon']}" == 'True' ]; then
         DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/services/gluon.yaml"
       fi
     elif [ "${deploy_options_array['vpp']}" == 'True' ]; then
-      if [ "${deploy_options_array['sdn_l3']}" == "True" ]; then
-        DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb.yaml"
+      if [ "${deploy_options_array['odl_vpp_netvirt']}" == "True" ]; then
+        DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-netvirt-vpp.yaml"
       else
-        DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb-l2.yaml"
+        DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-honeycomb.yaml"
       fi
     else
-      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight-l3.yaml"
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-opendaylight.yaml"
     fi
     SDN_IMAGE=opendaylight
   elif [ "${deploy_options_array['sdn_controller']}" == 'opendaylight-external' ]; then
     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/opendaylight-external.yaml"
     SDN_IMAGE=opendaylight
   elif [ "${deploy_options_array['sdn_controller']}" == 'onos' ]; then
-    echo -e "${red}ERROR: ONOS is unsupported in Danube...exiting${reset}"
-    exit 1
-    #if [ "${deploy_options_array['sfc']}" == 'True' ]; then
-    #  DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos_sfc.yaml"
-    #else
-    #  DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/onos.yaml"
-    #fi
-    #SDN_IMAGE=onos
+    if [ "${deploy_options_array['sfc']}" == 'True' ]; then
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-onos-sfc.yaml"
+    else
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-onos.yaml"
+    fi
+    SDN_IMAGE=onos
+  elif [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
+    if [[ "$ha_enabled" == "True" ]]; then
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn-ha.yaml"
+      echo "${red}OVN HA support is not not supported... exiting.${reset}"
+      exit 1
+    else
+      DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/neutron-ml2-ovn.yaml"
+    fi
+    SDN_IMAGE=opendaylight
   elif [ "${deploy_options_array['sdn_controller']}" == 'opencontrail' ]; then
     echo -e "${red}ERROR: OpenContrail is currently unsupported...exiting${reset}"
     exit 1
@@ -111,9 +118,9 @@ EOI
   if [ "${deploy_options_array['vpn']}" == 'True' ]; then
       echo -e "${blue}INFO: Enabling ZRPC and Quagga${reset}"
       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-      LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y install /root/quagga/*.rpm" \
-                                               --run-command "systemctl enable zrpcd" \
-                                               -a overcloud-full.qcow2
+      LIBGUESTFS_BACKEND=direct virt-customize \
+         --run-command "systemctl enable zrpcd" \
+         -a overcloud-full.qcow2
 EOI
   fi
 
@@ -156,6 +163,8 @@ EOI
 
   # upgrade ovs into ovs 2.5.90 with NSH function if SFC is enabled
   if [[ "${deploy_options_array['sfc']}" == 'True' && "${deploy_options_array['dataplane']}" == 'ovs' ]]; then
+    echo "ONOS SFC is currently unavailable. JIRA: APEX-417"
+    exit 1
     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
          LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum install -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_kmod_rpm_name}" \
                                                   --run-command "yum upgrade -y /root/ovs/rpm/rpmbuild/RPMS/x86_64/${ovs_rpm_name}" \
@@ -164,15 +173,18 @@ EOI
   fi
 
   # Patch neutron with using OVS external interface for router and add generic linux NS interface driver
-  if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
+  if [[ "${deploy_options_array['dataplane']}" == 'fdio' ]]; then
     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
       LIBGUESTFS_BACKEND=direct virt-customize --run-command "cd /usr/lib/python2.7/site-packages/ && patch -p1 < neutron-patch-NSDriver.patch" \
                                                -a overcloud-full.qcow2
 EOI
-    # Configure routing node for odl_l3-fdio
+
+    # Configure routing node and interface role mapping for odl-fdio
     if [[ "${deploy_options_array['sdn_l3']}" == 'True' ]]; then
       ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
         sed -i "/opendaylight::vpp_routing_node:/c\    opendaylight::vpp_routing_node: ${deploy_options_array['odl_vpp_routing_node']}.${domain_name}" ${ENV_FILE}
+        sed -i "/ControllerExtraConfig:/ c\  ControllerExtraConfig:\n    tripleo::profile::base::neutron::agents::honeycomb::interface_role_mapping:  \"['${tenant_nic_mapping_controller_members}:tenant-interface']\"" ${ENV_FILE}
+        sed -i "/NovaComputeExtraConfig:/ c\  NovaComputeExtraConfig:\n    tripleo::profile::base::neutron::agents::honeycomb::interface_role_mapping:  \"['${tenant_nic_mapping_compute_members}:tenant-interface','${external_nic_mapping_compute_members}:public-interface']\"" ${ENV_FILE}
 EOI
     fi
   fi
@@ -180,6 +192,22 @@ EOI
   if [ -n "${deploy_options_array['performance']}" ]; then
     ovs_dpdk_perf_flag="False"
     for option in "${performance_options[@]}" ; do
+      if [ "${arr[1]}" == "vpp" ]; then
+        if [ "${arr[0]}" == "Compute" ]; then
+          role='NovaCompute'
+        else
+          role=${arr[0]}
+        fi
+        if [ "${arr[2]}" == "main-core" ]; then
+          ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+            sed -i "/${role}ExtraConfig:/ c\  ${role}ExtraConfig:\n    fdio::vpp_cpu_main_core: \"'${arr[3]}'\"" ${ENV_FILE}
+EOI
+        elif [ "${arr[2]}" == "corelist-workers" ]; then
+          ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+            sed -i "/${role}ExtraConfig:/ c\  ${role}ExtraConfig:\n    fdio::vpp_cpu_corelist_workers: \"'${arr[3]}'\"" ${ENV_FILE}
+EOI
+        fi
+      fi
       arr=($option)
       # use compute's kernel settings for all nodes for now.
       if [ "${arr[0]}" == "Compute" ] && [ "${arr[1]}" == "kernel" ]; then
@@ -211,6 +239,7 @@ EOI
   if [[ -z "${deploy_options_array['sdn_controller']}" || "${deploy_options_array['sdn_controller']}" == 'False' ]]; then
     if [ "${deploy_options_array['dataplane']}" == "fdio" ]; then
       if [ "$tenant_nic_mapping_controller_members" == "$tenant_nic_mapping_compute_members" ]; then
+        echo -e "${blue}INFO: nosdn fdio deployment...installing correct vpp packages...${reset}"
         ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
           sed -i "/NeutronVPPAgentPhysnets:/c\  NeutronVPPAgentPhysnets: 'datacentre:${tenant_nic_mapping_controller_members}'" ${ENV_FILE}
 EOI
@@ -224,30 +253,37 @@ EOI
   # Set ODL version accordingly
   if [[ "${deploy_options_array['sdn_controller']}" == 'opendaylight' && -n "${deploy_options_array['odl_version']}" ]]; then
     case "${deploy_options_array['odl_version']}" in
-      beryllium) odl_version=''
-              ;;
-      boron)  odl_version='boron'
-              ;;
-      carbon) odl_version='master'
+      carbon) odl_version=''
               ;;
-      *) echo -e "${red}Invalid ODL version ${deploy_options_array['odl_version']}.  Please use 'carbon' or 'boron' values.${reset}"
+      *) echo -e "${red}Invalid ODL version ${deploy_options_array['odl_version']}.  Please use 'carbon'.${reset}"
          exit 1
          ;;
     esac
 
-    ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-      LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
-                                               --run-command "yum -y install /root/${odl_version}/*" \
-                                               -a overcloud-full.qcow2
+    if [[  -n "$odl_version" ]]; then
+        ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+          LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
+                                                   --run-command "yum -y install /root/${odl_version}/*" \
+                                                   -a overcloud-full.qcow2
 EOI
+    fi
+
+    # Overwrite puppet-opendaylight with carbon. By default we install boron branch.
+    if [ "${deploy_options_array['odl_version']}" == 'carbon' ]; then
+      ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+        LIBGUESTFS_BACKEND=direct virt-customize --run-command "rm -rf /etc/puppet/modules/opendaylight" \
+                                                 --run-command "cd /etc/puppet/modules/ && tar xzf /root/puppet-opendaylight-carbon.tar.gz" \
+                                                 -a overcloud-full.qcow2
+EOI
+    fi
   fi
 
-  # Override ODL if FDIO and ODL L2
-  if [[ "${deploy_options_array['vpp']}" == 'True' && "${deploy_options_array['sdn_controller']}" == 'opendaylight' && "${deploy_options_array['sdn_l3']}" == "False" ]]; then
+  # Override ODL if we enable netvirt for fdio
+  if [[ "${deploy_options_array['odl_vpp_netvirt']}" == 'True' && "${deploy_options_array['sdn_controller']}" == 'opendaylight' ]]; then
     ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
-         LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
-                                                  --run-command "yum -y install /root/fdio_l2/opendaylight*.rpm" \
-                                                  -a overcloud-full.qcow2
+      LIBGUESTFS_BACKEND=direct virt-customize --run-command "yum -y remove opendaylight" \
+                                               --run-command "yum -y install /root/opendaylight-7.0.0-0.1.20170531snap665.el7.noarch.rpm" \
+                                               -a overcloud-full.qcow2
 EOI
   fi
 
@@ -256,6 +292,17 @@ EOI
     DEPLOY_OPTIONS+=" -e /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml"
   fi
 
+  if [ "${deploy_options_array['sdn_controller']}" == 'ovn' ]; then
+    # The epoch in deloran's ovs is 1: and in leif's is 0:
+    # so we have to execute a downgrade instead of an update
+    ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI
+      LIBGUESTFS_BACKEND=direct virt-customize \
+        --run-command "cd /root/ovs27 && yum update -y *openvswitch*" \
+        --run-command "cd /root/ovs27 && yum downgrade -y *openvswitch*" \
+        -a overcloud-full.qcow2
+EOI
+  fi
+
   # get number of nodes available in inventory
   num_control_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:control /home/stack/instackenv.json")
   num_compute_nodes=$(ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "grep -c profile:compute /home/stack/instackenv.json")
@@ -290,6 +337,12 @@ EOI
   DEPLOY_OPTIONS+=" --control-flavor control --compute-flavor compute"
   if [[ "$virtual" == "TRUE" ]]; then
      DEPLOY_OPTIONS+=" -e virtual-environment.yaml"
+     echo 'Ensuring Virtual BMC device status'
+     for i in $(vbmc list | grep down | awk '{ print $2}'); do
+         vbmc start $i
+         sleep 5
+     done
+     vbmc list
   fi
 
   echo -e "${blue}INFO: Deploy options set:\n${DEPLOY_OPTIONS}${reset}"
@@ -313,41 +366,33 @@ echo "Uploading overcloud glance images"
 openstack overcloud image upload
 
 echo "Configuring undercloud and discovering nodes"
-openstack baremetal import --json instackenv.json
+
 
 if [[ -z "$virtual" ]]; then
-  openstack baremetal introspection bulk start
-  if [[ -n "$root_disk_list" ]]; then
-    openstack baremetal configure boot --root-device=${root_disk_list}
-  else
-    openstack baremetal configure boot
-  fi
+  openstack overcloud node import instackenv.json
+  openstack overcloud node introspect --all-manageable --provide
+  #if [[ -n "$root_disk_list" ]]; then
+    # TODO: replace node configure boot with ironic node-update
+    # TODO: configure boot is not used in ocata here anymore
+    #openstack overcloud node configure boot --root-device=${root_disk_list}
+    #https://github.com/openstack/tripleo-quickstart-extras/blob/master/roles/overcloud-prep-images/templates/overcloud-prep-images.sh.j2#L73-L130
+    #ironic node-update $ironic_node add properties/root_device='{"{{ node['key'] }}": "{{ node['value'] }}"}'
+  #fi
 else
-  openstack baremetal configure boot
+  openstack overcloud node import --provide instackenv.json
 fi
 
-echo "Configuring flavors"
-for flavor in baremetal control compute; do
-  echo -e "${blue}INFO: Updating flavor: \${flavor}${reset}"
-  if openstack flavor list | grep \${flavor}; then
-    openstack flavor delete \${flavor}
-  fi
-  openstack flavor create --id auto --ram 4096 --disk 39 --vcpus 1 \${flavor}
-  if ! openstack flavor list | grep \${flavor}; then
-    echo -e "${red}ERROR: Unable to create flavor \${flavor}${reset}"
-  fi
-done
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" baremetal
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="control" control
-openstack flavor set --property "cpu_arch"="x86_64" --property "capabilities:boot_option"="local" --property "capabilities:profile"="compute" compute
+openstack flavor set --property "cpu_arch"="x86_64" baremetal
+openstack flavor set --property "cpu_arch"="x86_64" control
+openstack flavor set --property "cpu_arch"="x86_64" compute
 echo "Configuring nameserver on ctlplane network"
 dns_server_ext=''
 for dns_server in ${dns_servers}; do
   dns_server_ext="\${dns_server_ext} --dns-nameserver \${dns_server}"
 done
-neutron subnet-update \$(neutron subnet-list | grep -Ev "id|tenant|external|storage" | grep -v \\\\-\\\\- | awk {'print \$2'}) \${dns_server_ext}
+openstack subnet set ctlplane-subnet \${dns_server_ext}
 sed -i '/CloudDomain:/c\  CloudDomain: '${domain_name} ${ENV_FILE}
-echo "Executing overcloud deployment, this should run for an extended period without output."
+echo "Executing overcloud deployment, this could run for an extended period without output."
 sleep 60 #wait for Hypervisor stats to check-in to nova
 # save deploy command so it can be used for debugging
 cat > deploy_command << EOF