Nova-handle v2.1 resources in client state
The patch allows to handle v2.1 nova resources
hence allowing to pass extra specs while creating flavors
Pillar example:
nova:
client:
enabled: True
resources:
v21:
admin_identity:
flavor:
m1.tiny_test:
ram: 512
disk: 5
vcpus: 1
extra_specs:
hw:mem_page_size: small
Change-Id: Iaeb812d28729a86eb8096b026c085bca0b7ff963
Related-PROD: PROD-23478
diff --git a/nova/client/init.sls b/nova/client/init.sls
new file mode 100644
index 0000000..e058d2d
--- /dev/null
+++ b/nova/client/init.sls
@@ -0,0 +1,2 @@
+include:
+- nova.client.resources
diff --git a/nova/client.sls b/nova/client/resources/init.sls
similarity index 93%
rename from nova/client.sls
rename to nova/client/resources/init.sls
index 87ae2cb..6dae528 100644
--- a/nova/client.sls
+++ b/nova/client/resources/init.sls
@@ -1,11 +1,14 @@
{%- from "nova/map.jinja" import client with context %}
{%- if client.enabled %}
+include:
+- nova.client.resources.v21
+
nova_client_packages:
pkg.installed:
- names: {{ client.pkgs }}
-{%- for identity_name, identity in client.server.iteritems() %}
+{%- for identity_name, identity in client.get('server', {}).iteritems() %}
{%- if identity.flavor is defined %}
@@ -75,3 +78,4 @@
{%- endfor %}
{%- endif %}
+
diff --git a/nova/client/resources/v21.sls b/nova/client/resources/v21.sls
new file mode 100644
index 0000000..448a94c
--- /dev/null
+++ b/nova/client/resources/v21.sls
@@ -0,0 +1,33 @@
+{%- from "nova/map.jinja" import client with context %}
+{%- if client.enabled %}
+
+{%- for identity_name, identity in client.get('resources', {}).get('v21', {}).iteritems() %}
+
+ {%- if identity.flavor is defined %}
+ {%- for flavor_name, flavor in identity.flavor.iteritems() %}
+
+novav21_openstack_flavor_{{ flavor_name }}:
+ novav21.flavor_present:
+ - name: {{ flavor_name }}
+ - cloud_name: {{ identity_name }}
+ {%- if flavor.flavor_id is defined %}
+ - flavor_id: {{ flavor.flavor_id }}
+ {%- endif %}
+ {%- if flavor.ram is defined %}
+ - ram: {{ flavor.ram }}
+ {%- endif %}
+ {%- if flavor.disk is defined %}
+ - disk: {{ flavor.disk }}
+ {%- endif %}
+ {%- if flavor.vcpus is defined %}
+ - vcpus: {{ flavor.vcpus }}
+ {%- endif %}
+ {%- if flavor.extra_specs is defined %}
+ - extra_specs: {{ flavor.extra_specs }}
+ {%- endif %}
+
+ {%- endfor %}
+ {%- endif %}
+
+{%- endfor %}
+{%- endif %}