CORD-1483 add dpdk and perf related keys to nova flavors

Change-Id: I314e449199706be18846eb6e37f189209147c959
diff --git a/deploy-openstack-playbook.yml b/deploy-openstack-playbook.yml
index 68d28cb..5cf3b8a 100644
--- a/deploy-openstack-playbook.yml
+++ b/deploy-openstack-playbook.yml
@@ -28,3 +28,7 @@
     - juju-setup
     - juju-finish
 
+- name: Configure Nova with DPDK-enabled flavors
+  hosts: head
+  roles:
+    - { role: setup-nova-dpdk, when: enable_dpdk | default(False) }
diff --git a/roles/setup-nova-dpdk/defaults/main.yml b/roles/setup-nova-dpdk/defaults/main.yml
new file mode 100644
index 0000000..cd0c033
--- /dev/null
+++ b/roles/setup-nova-dpdk/defaults/main.yml
@@ -0,0 +1,8 @@
+---
+# setup-nova-dpdk/defaults/main.yml
+
+site_name: placeholder-sitename
+site_suffix: "{{ site_name }}.test"
+
+requests_ca_bundle: "/etc/ssl/certs/ca-certificates.crt"
+keystone_admin_password: "{{ lookup('password', credentials_dir ~ '/cord_keystone_admin chars=ascii_letters,digits') }}"
diff --git a/roles/setup-nova-dpdk/tasks/main.yml b/roles/setup-nova-dpdk/tasks/main.yml
new file mode 100644
index 0000000..427c412
--- /dev/null
+++ b/roles/setup-nova-dpdk/tasks/main.yml
@@ -0,0 +1,51 @@
+---
+# Setup nova flavors with perf attributes
+
+- name: Upgrade pbr
+  pip:
+    name: pbr
+    extra_args: --upgrade
+  become: True
+
+- name: Install shade
+  pip:
+    name: shade
+  become: True
+
+- name: Delete existing flavors except m1.tiny
+  os_nova_flavor:
+    state: absent
+    cacert: "{{ requests_ca_bundle }}"
+    auth:
+      auth_url: "https://keystone.{{ site_suffix }}:5000/v2.0"
+      username: admin
+      password: "{{ keystone_admin_password }}"
+      project_name: admin
+    name: "{{ item }}"
+  with_items:
+    - m1.small
+    - m1.medium
+    - m1.large
+    - m1.xlarge
+
+- name: Re-create flavors with perf attributes
+  os_nova_flavor:
+    state: present
+    cacert: "{{ requests_ca_bundle }}"
+    auth:
+      auth_url: "https://keystone.{{ site_suffix }}:5000/v2.0"
+      username: admin
+      password: "{{ keystone_admin_password }}"
+      project_name: admin
+    name: "{{ item.name }}"
+    ram: "{{ item.ram }}"
+    vcpus: "{{ item.vcpus }}"
+    disk: "{{ item.disk }}"
+    extra_specs:
+      "hw:mem_page_size": 2048
+      "hw:cpu_policy": dedicated
+  with_items:
+    - { name: 'm1.small',   ram: 2048,  vcpus: 1, disk: 20  }
+    - { name: 'm1.medium',  ram: 4096,  vcpus: 2, disk: 40  }
+    - { name: 'm1.large',   ram: 8192,  vcpus: 4, disk: 80  }
+    - { name: 'm1.xlarge',  ram: 16384, vcpus: 8, disk: 160 }