PoC for ironic provisioning of physical_mcp11_ovs_dpdk

Change-Id: I257a061ceaf34bc8ca310a94335371a480db301d
Reviewed-on: https://review.gerrithub.io/363525
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/ironic_standalone/underlay--user-data-ironic.yaml b/tcp_tests/templates/ironic_standalone/underlay--user-data-ironic.yaml
index 0544ae6..f35127d 100644
--- a/tcp_tests/templates/ironic_standalone/underlay--user-data-ironic.yaml
+++ b/tcp_tests/templates/ironic_standalone/underlay--user-data-ironic.yaml
@@ -47,8 +47,8 @@
 
    - echo "172.18.248.114    jenkins.mcp.mirantis.net  gerrit.mcp.mirantis.net" >> /etc/hosts;
    - echo "185.135.196.10    apt-mk.mirantis.com" >> /etc/hosts;
-   - echo "nameserver 172.18.208.44 >> /etc/resolv.conf;
-   - echo "nameserver 8.8.8.8 >> /etc/resolv.conf;
+   - echo "nameserver 172.18.208.44" >> /etc/resolv.conf;
+   - echo "nameserver 8.8.8.8" >> /etc/resolv.conf;
    - which wget >/dev/null || (apt-get update; apt-get install -y wget);
    - apt-get install -y ntp
 
@@ -63,6 +63,18 @@
    - ip a a $IRONIC_PXE_INTERFACE_ADDRESS/$IRONIC_DHCP_POOL_NETMASK_PREFIX dev $IRONIC_PXE_INTERFACE_NAME
    - curl https://raw.githubusercontent.com/dis-xcom/underpillar/master/bootstrap.sh -o ./bootstrap.sh && bash ./bootstrap.sh
 
+   # Disable dnsmasq in favour to external DHCP provider
+   #- systemctl disable dnsmasq
+   # - service dnsmasq stop
+
+   {%- if os_env('IRONIC_DNSMASQ_HOSTFILE', '') %}
+   - echo "dhcp-hostsfile=/var/lib/libvirt/dnsmasq/{{ IRONIC_ENV_NAME }}.hostsfile" >> /etc/dnsmasq.conf
+   - service dnsmasq restart
+   {%- endif %}
+
+   # Enable SNAT to allow internet access for deploying nodes using ironic node as a gateway
+   - iptables -t nat -A POSTROUTING -s {{ os_env('IRONIC_DHCP_POOL_START', '10.0.175.100') }}/{{ os_env('IRONIC_DHCP_POOL_NETMASK_PREFIX', '24') }} ! -d {{ os_env('IRONIC_DHCP_POOL_START', '10.0.175.100') }}/{{ os_env('IRONIC_DHCP_POOL_NETMASK_PREFIX', '24') }} -j MASQUERADE
+
    - echo "Building ironic agent image (stable/newton) ..."
    - apt-get install -y docker.io gzip uuid-runtime cpio findutils grep gnupg make
    - service docker start
@@ -130,3 +142,12 @@
             ServerAliveCountMax 10
             StrictHostKeyChecking no
             UserKnownHostsFile /dev/null
+
+   {%- if os_env('IRONIC_DNSMASQ_HOSTFILE', '') %}
+   - path: /var/lib/libvirt/dnsmasq/{{ IRONIC_ENV_NAME }}.hostsfile
+     permissions: '0644'
+     content: |
+     {%- for host in os_env('IRONIC_DNSMASQ_HOSTFILE').splitlines() %}
+       {{ host }}
+     {%- endfor %}
+   {%- endif %}
diff --git a/tcp_tests/templates/ironic_standalone/underlay.yaml b/tcp_tests/templates/ironic_standalone/underlay.yaml
index 0753174..39a998e 100644
--- a/tcp_tests/templates/ironic_standalone/underlay.yaml
+++ b/tcp_tests/templates/ironic_standalone/underlay.yaml
@@ -1,5 +1,8 @@
 # Set the repository suite, one of the: 'nightly', 'testing', 'stable', or any other required
 {% set REPOSITORY_SUITE = os_env('REPOSITORY_SUITE', 'stable') %}
+{% set DOMAIN_NAME = os_env('LAB_CONFIG_NAME', 'standalone') + '.local' %}
+{% set HOSTNAME_IRONIC = os_env('HOSTNAME_IRONIC', 'ironic_master') %}
+{% set IRONIC_ENV_NAME = os_env('IRONIC_ENV_NAME', 'ironic_' + DOMAIN_NAME + '_' + REPOSITORY_SUITE + '_' + os_env('BUILD_NUMBER', '')) %}
 
 {% import 'ironic_standalone/underlay--meta-data.yaml' as CLOUDINIT_META_DATA with context %}
 {% import 'ironic_standalone/underlay--user-data-ironic.yaml' as CLOUDINIT_USER_DATA_IRONIC with context %}
@@ -10,13 +13,10 @@
  - &cloudinit_meta_data {{ CLOUDINIT_META_DATA }}
  - &cloudinit_user_data_ironic {{ CLOUDINIT_USER_DATA_IRONIC }}
 
-{% set DOMAIN_NAME = os_env('LAB_CONFIG_NAME', 'standalone') + '.local' %}
-{% set HOSTNAME_IRONIC = os_env('HOSTNAME_IRONIC', 'ironic_master') %}
-
 
 template:
   devops_settings:
-    env_name: {{ os_env('IRONIC_ENV_NAME', 'ironic_' + DOMAIN_NAME + '_' + REPOSITORY_SUITE + '_' + os_env('BUILD_NUMBER', '')) }}
+    env_name: {{ IRONIC_ENV_NAME }}
 
     address_pools:
 
@@ -66,10 +66,11 @@
           provisioning:
             address_pool: provisioning-pool01
             dhcp: false
+            forward:
+              mode: !os_env IRONIC_LAB_PXE_IFACE_MODE, bridge
             parent_iface:
               phys_dev: !os_env IRONIC_LAB_PXE_IFACE
 
-
         nodes:
           - name: {{ HOSTNAME_IRONIC }}
             role: ironic_master