Merge "Fix nova/meta/prometheus.yml for the CI"
diff --git a/.kitchen.yml b/.kitchen.yml
index 418d93e..d0d8c0d 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -34,7 +34,7 @@
           - nova
           - release
   pillars-from-files:
-    linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack_<%= ENV['OS_VERSION'] || 'mitaka' %>.sls
+    linux_repo_openstack.sls: tests/pillar/repo_mcp_openstack_<%= ENV['OS_VERSION'] || 'ocata' %>.sls
 
 verifier:
   name: inspec
@@ -48,7 +48,7 @@
 
 suites:
 
-  - name: compute_cluster
+  - name: compute_cluster_<%= ENV['OS_VERSION'] || 'ocata' %>
     provisioner:
       pillars-from-files:
         nova.sls: tests/pillar/compute_cluster.sls
@@ -56,9 +56,9 @@
         release.sls:
           nova:
             compute:
-              version: <%= ENV['OS_VERSION'] || 'mitaka' %>
+              version: <%= ENV['OS_VERSION'] || 'ocata' %>
 
-  - name: control_cluster
+  - name: control_cluster_<%= ENV['OS_VERSION'] || 'ocata' %>
     provisioner:
       pillars-from-files:
         nova.sls: tests/pillar/control_cluster.sls
@@ -66,6 +66,6 @@
         release.sls:
           nova:
             controller:
-              version: <%= ENV['OS_VERSION'] || 'mitaka' %>
+              version: <%= ENV['OS_VERSION'] || 'ocata' %>
 
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/_states/novang.py b/_states/novang.py
index d5bcb35..00c74d8 100644
--- a/_states/novang.py
+++ b/_states/novang.py
@@ -251,6 +251,23 @@
             'result': True,
             'comment': 'Instance "{0}" was successfuly created'.format(name)}
 
+
+def keypair_present(name, pub_file, profile=None):
+    """
+    Ensures that the Nova key-pair exists
+    """
+
+    existing_keypairs = __salt__['novang.keypair_list'](profile)
+    if name in existing_keypairs:
+        return _already_exists(name, 'Keypair')
+    else:
+        res = __salt__['novang.keypair_add'](name, pubfile=pub_file,
+                                             profile=profile)
+        if res and res['name'] == name:
+            return _created(name, 'Keypair', res)
+        return _create_failed(name, 'Keypair')
+
+
 def _already_exists(name, resource):
     changes_dict = {'name': name,
                     'changes': {},
@@ -293,3 +310,11 @@
             '{0} {1} is in correct state'.format(resource, name)
     return changes_dict
 
+
+def _create_failed(name, resource):
+    changes_dict = {'name': name,
+                    'changes': {},
+                    'comment': '{0} {1} failed to create'.format(resource,
+                                                                 name),
+                    'result': False}
+    return changes_dict
diff --git a/metadata/service/client/init.yml b/metadata/service/client/init.yml
new file mode 100644
index 0000000..46046d6
--- /dev/null
+++ b/metadata/service/client/init.yml
@@ -0,0 +1,6 @@
+applications:
+  - nova
+parameters:
+  nova:
+    client:
+      enabled: true
diff --git a/nova/client.sls b/nova/client.sls
index 57d62e5..ea4aaa0 100644
--- a/nova/client.sls
+++ b/nova/client.sls
@@ -33,6 +33,18 @@
 
 {%- endif %}
 
+{%- if identity.keypair is defined %}
+
+{%- for keypair_name, keypair in identity.keypair.iteritems() %}
+nova_keypair_{{ keypair_name }}:
+  novang.keypair_present:
+    - name: {{ keypair_name }}
+    - pub_file: {{ keypair.pub_file }}
+    - profile: {{ identity_name }}
+{%- endfor %}
+
+{%- endif %}
+
 {%- if identity.availability_zones is defined %}
 
 {%- for availability_zone_name in identity.availability_zones %}
diff --git a/nova/controller.sls b/nova/controller.sls
index 73cc55d..15531f2 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -145,6 +145,9 @@
   novang.online_data_migrations_present:
   - api_db_version: "20"
   - db_version: "334"
+  {%- if grains.get('noservices') %}
+  - onlyif: /bin/false
+  {%- endif %}
   - require:
     - novang: nova_controller_api_db_sync_version_20
     - novang: nova_controller_db_sync_version_334