Bind specific iface names to interfaces in baremetal dpdk

also, bind to a specific fuel-devops commit because of
using {address} for udev rules

Change-Id: I1377bd21d6533d297f2a85cd666df8d2bd5c84fd
Reviewed-on: https://review.gerrithub.io/363616
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/requirements.txt b/tcp_tests/requirements.txt
index b323301..0a69202 100644
--- a/tcp_tests/requirements.txt
+++ b/tcp_tests/requirements.txt
@@ -1,4 +1,4 @@
-git+git://github.com/openstack/fuel-devops.git
+git+git://github.com/openstack/fuel-devops.git@5d68ed0
 git+git://github.com/dis-xcom/fuel-devops-driver-ironic
 paramiko
 six
diff --git a/tcp_tests/templates/physical_mcp11_ovs_dpdk/salt.yaml b/tcp_tests/templates/physical_mcp11_ovs_dpdk/salt.yaml
index 80843fa..d3e881b 100644
--- a/tcp_tests/templates/physical_mcp11_ovs_dpdk/salt.yaml
+++ b/tcp_tests/templates/physical_mcp11_ovs_dpdk/salt.yaml
@@ -69,7 +69,7 @@
 
 - description: Configure GIT settings and certificates
   cmd: touch /root/.git_trusted_certs.pem;
-    for server in github.com; do
+    for server in git.tcpcloud.eu github.com; do
         openssl s_client -showcerts -connect $server:443 </dev/null
         | openssl x509 -outform PEM
         >> /root/.git_trusted_certs.pem;
@@ -101,7 +101,7 @@
     find /srv/salt/reclass/ -type f -exec sed -i 's/apt_mk_version:.*/apt_mk_version: {{ REPOSITORY_SUITE }}/g' {} +
 
     # Disable checkouting the model from remote repository
-    cat << 'EOF' >> /srv/salt/reclass/nodes/control/{{ HOSTNAME_CFG01 }}.yml
+    cat << 'EOF' >> /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml
     # local storage
       reclass:
         storage:
@@ -263,6 +263,13 @@
   retry: {count: 1, delay: 5}
   skip_fail: false
 
+- description: '*Workaround* enable hugepages on cmp* nodes for OVS setup in linux formula'
+  cmd: salt --hard-crash --state-output=mixed --state-verbose=False 'cmp*' cmd.run
+      'sudo apt-get install -y hugepages; sudo echo 2048 > /proc/sys/vm/nr_hugepages'
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
 - description: Sync all salt resources for present baremetal nodes
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False '*' saltutil.sync_all
   node_name: {{ HOSTNAME_CFG01 }}
diff --git a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data-hugepages.yaml b/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data-hugepages.yaml
deleted file mode 100644
index cdc0e8f..0000000
--- a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data-hugepages.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
-| # All the data below will be stored as a string object
-  #cloud-config, see http://cloudinit.readthedocs.io/en/latest/topics/examples.html
-
-  ssh_pwauth: True
-  users:
-   - name: root
-     sudo: ALL=(ALL) NOPASSWD:ALL
-     shell: /bin/bash
-     ssh_authorized_keys:
-      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGwjUlYn9UsmWmAGSuEA2sICad7WqxgsJR0HKcMbbxi0tn96h4Cq2iGYmzlJ48egLm5R5pxyWnFvL4b/2zb+kKTPCMwRc9nv7xEGosEFNQEoSDd+gYu2CO0dgS2bX/7m2DXmzvhqPjxWQUXXsb0OYAS1r9Es65FE8y4rLaegz8V35xfH45bTCA0W8VSKh264XtGz12hacqsttE/UvyjJTZe+/XV+xJy3WAWxe8J/MuW1VqbqNewTmpTE/LJU8i6pG4msU6+wH99UvsGAOKQOduynUHKWG3VZg5YCjpbbV/t/pfW/vHB3b3jiifQmNhulyiG/CNnSQ5BahtV/7qPsYt vagrant@cfg01
-
-  disable_root: false
-  chpasswd:
-   list: |
-    root:r00tme
-   expire: False
-
-  bootcmd:
-   # Block access to SSH while node is preparing
-   - cloud-init-per once sudo iptables -A INPUT -p tcp --dport 22 -j DROP
-   # Enable root access
-   - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
-   - service sshd restart
-  output:
-    all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
-
-  runcmd:
-   - export TERM=linux
-   - export LANG=C
-   # Configure dhclient
-   - sudo echo "nameserver {gateway}" >> /etc/resolvconf/resolv.conf.d/base
-   - sudo resolvconf -u
-
-   # Prepare network connection
-   #- sudo ifup eth0
-
-   # Create swap
-   - fallocate -l 4G /swapfile
-   - chmod 600 /swapfile
-   - mkswap /swapfile
-   - swapon /swapfile
-   - echo "/swapfile   none    swap    defaults   0   0" >> /etc/fstab
-
-
-   ############## TCP Cloud cfg01 node ##################
-   #- sleep 120
-   - echo "Preparing base OS"
-   - which wget >/dev/null || (apt-get update; apt-get install -y wget)
- 
-   - echo "deb [arch=amd64] http://apt-mk.mirantis.com/xenial {{ REPOSITORY_SUITE }} salt extra" > /etc/apt/sources.list.d/mcp_salt.list;
-   - wget -O - http://apt-mk.mirantis.com/public.gpg | apt-key add -;
-   - echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main" > /etc/apt/sources.list.d/saltstack.list
-   - wget -O - https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub | apt-key add -
-
-   - apt-get clean
-   - eatmydata apt-get update && apt-get -y upgrade
-
-   # Install common packages
-   - eatmydata apt-get install -y python-pip git curl tmux byobu iputils-ping traceroute htop tree mc hugepages
-
-   # Enable hugepages to enable OVS setup for dpdk
-   - echo 2048 > /proc/sys/vm/nr_hugepages
-
-   ########################################################
-   # Node is ready, allow SSH access
-   - echo "Allow SSH access ..."
-   - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
-   ########################################################
diff --git a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data.yaml b/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data.yaml
index 06d2638..70fc76d 100644
--- a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data.yaml
+++ b/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay--user-data.yaml
@@ -60,6 +60,41 @@
 
    ########################################################
    # Node is ready, allow SSH access
-   - echo "Allow SSH access ..."
-   - sudo iptables -D INPUT -p tcp --dport 22 -j DROP
+   #- echo "Allow SSH access ..."
+   #- sudo iptables -D INPUT -p tcp --dport 22 -j DROP
+   - update-initramfs -u
+   - reboot
    ########################################################
+
+  write_files:
+   - path: /etc/udev/rules.d/70-persistent-net.rules
+     owner: root:root
+     permissions: '0644'
+     content: |
+       # kvm01
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_KVM01') }}", NAME="enp3s0f0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_KVM01') }}", NAME="enp3s0f1"
+       # kvm02
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_KVM02') }}", NAME="eno1"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_KVM02') }}", NAME="eno2"
+       # kvm03
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_KVM03') }}", NAME="eno1"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_KVM03') }}", NAME="eno2"
+       # cmp001
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_CMP001') }}", NAME="enp3s0f0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_CMP001') }}", NAME="enp3s0f1"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH2_MAC_ADDRESS_CMP001') }}", NAME="enp5s0f0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH3_MAC_ADDRESS_CMP001') }}", NAME="enp5s0f1"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH4_MAC_ADDRESS_CMP001') }}", NAME="enp5s0f2"
+       # cmp002
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_CMP002') }}", NAME="eno1"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_CMP002') }}", NAME="eth0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH2_MAC_ADDRESS_CMP002') }}", NAME="eth3"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH3_MAC_ADDRESS_CMP002') }}", NAME="eth2"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH4_MAC_ADDRESS_CMP002') }}", NAME="eth4"
+       # gtw01
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_GTW01') }}", NAME="enp2s0f0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_GTW01') }}", NAME="enp2s0f1"
+       # gtw02
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH0_MAC_ADDRESS_GTW02') }}", NAME="enp2s0f0"
+       SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{{ '{{address}}' }}=="{{ os_env('ETH1_MAC_ADDRESS_GTW02') }}", NAME="enp2s0f1"
diff --git a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay.yaml b/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay.yaml
index 18da06d..0ad2184 100644
--- a/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay.yaml
+++ b/tcp_tests/templates/physical_mcp11_ovs_dpdk/underlay.yaml
@@ -24,7 +24,6 @@
 {% import 'physical_mcp11_ovs_dpdk/underlay--meta-data.yaml' as CLOUDINIT_META_DATA with context %}
 {% import 'physical_mcp11_ovs_dpdk/underlay--user-data-cfg01.yaml' as CLOUDINIT_USER_DATA_CFG01 with context %}
 {% import 'physical_mcp11_ovs_dpdk/underlay--user-data.yaml' as CLOUDINIT_USER_DATA with context %}
-{% import 'physical_mcp11_ovs_dpdk/underlay--user-data-hugepages.yaml' as CLOUDINIT_USER_DATA_HUGEPAGES with context %}
 
 ---
 aliases:
@@ -32,7 +31,6 @@
  - &cloudinit_meta_data {{ CLOUDINIT_META_DATA }}
  - &cloudinit_user_data_cfg01 {{ CLOUDINIT_USER_DATA_CFG01 }}
  - &cloudinit_user_data {{ CLOUDINIT_USER_DATA }}
- - &cloudinit_user_data_hugepages {{ CLOUDINIT_USER_DATA_HUGEPAGES }}
 
 
 template:
@@ -366,7 +364,7 @@
                              # for store image with cloud-init metadata.
 
                   cloudinit_meta_data: *cloudinit_meta_data
-                  cloudinit_user_data: *cloudinit_user_data_hugepages
+                  cloudinit_user_data: *cloudinit_user_data
 
               interfaces:
                 - label: enp3s0f0
@@ -424,7 +422,7 @@
                              # for store image with cloud-init metadata.
 
                   cloudinit_meta_data: *cloudinit_meta_data
-                  cloudinit_user_data: *cloudinit_user_data_hugepages
+                  cloudinit_user_data: *cloudinit_user_data
 
               interfaces:
                 - label: eno1