Merge "Add ability to generate required parameters for manila in tempest conf"
diff --git a/_modules/runtest/tempest_sections/volume.py b/_modules/runtest/tempest_sections/volume.py
index 7deeeb1..8de5e2b 100644
--- a/_modules/runtest/tempest_sections/volume.py
+++ b/_modules/runtest/tempest_sections/volume.py
@@ -73,8 +73,9 @@
     @property
     def storage_protocol(self):
         c = conditions.BaseRule('cinder.volume.enabled', 'eq', True)
-        backends = self.get_item_when_condition_match(
-            'cinder.volume.backend', c)
+        backends = (self.get_item_when_condition_match(
+            'cinder.volume.backend', c) or self.get_item_when_condition_match(
+            'cinder.controller.backend', c))
         if not backends:
             return
 
@@ -83,10 +84,9 @@
 
         # TODO: cinder support multibackends with different storage protocols,
         # pick first we know about for now, but might be refactored in future.
-        for backend_name,backend in backends.iteritems():
+        for backend_name, backend in backends.iteritems():
             res = backend['engine']
-            if res:
-              return res
+            return protocol_map.get(res)
 
     @property
     def vendor_name(self):
diff --git a/metadata/service/tempest/barbican.yml b/metadata/service/tempest/barbican.yml
new file mode 100644
index 0000000..5c9e212
--- /dev/null
+++ b/metadata/service/tempest/barbican.yml
@@ -0,0 +1,30 @@
+classes:
+  - service.runtest.tempest.cert
+  - service.runtest.tempest.test_accounts
+parameters:
+  _param:
+    # barbican tempest tests require admin accounts access
+    runtest_tempest_test_accounts_admin_access_enabled: True
+    runtest_tempest_test_accounts_roles:
+      - creator
+      - key-manager:service-admin
+  barbican:
+    client:
+      enabled: True
+      resources:
+        v1:
+          enabled: true
+          cloud_name: admin_identity
+          secrets:
+            TestSecret:
+              type: certificate
+              algorithm: RSA
+              payload_content_type: application/octet-stream
+              payload_content_encoding: base64
+              payload_path: ${_param:tempest_cert_file}
+              encodeb64_payload: true
+  runtest:
+    tempest:
+      test_cert_key: ${_param:tempest_cert_key}
+      test_cert_crt: ${_param:tempest_cert_file}
+      barbican_secret_name: TestSecret
diff --git a/metadata/service/tempest/cert.yml b/metadata/service/tempest/cert.yml
new file mode 100644
index 0000000..1ef2975
--- /dev/null
+++ b/metadata/service/tempest/cert.yml
@@ -0,0 +1,18 @@
+parameters:
+  _param:
+    tempest_ca_hostname: ${linux:system:name}
+    tempest_ca_host: ${_param:tempest_ca_hostname}.${_param:cluster_domain}
+    tempest_ca_authority: salt_master_ca
+    tempest_cert_key: /tmp/test.key
+    tempest_cert_file: /tmp/test.crt
+  salt:
+    minion:
+      cert:
+        tempest:
+          host: ${_param:tempest_ca_host}
+          authority: ${_param:tempest_ca_authority}
+          common_name: tempest_test
+          signing_policy: cert_server
+          key_usage: "digitalSignature,nonRepudiation,keyEncipherment"
+          key_file:  ${_param:tempest_cert_key}
+          cert_file: ${_param:tempest_cert_file}
diff --git a/runtest/barbican_sign_image.sls b/runtest/barbican_sign_image.sls
new file mode 100644
index 0000000..7e48f8a
--- /dev/null
+++ b/runtest/barbican_sign_image.sls
@@ -0,0 +1,30 @@
+{%- from "runtest/map.jinja" import tempest with context %}
+{%- set prefix = tempest.get('test_accounts', {}).get('prefix', 'Tempest_Test') %}
+{%- set secret_name = tempest.get('barbican_secret_name', 'TestSecret') %}
+
+{%- set images = salt['glancev2.image_list'](cloud_name=tempest.keystone_profile_admin) %}
+{%- for image in images['images'] %}
+barbican_sign_image_{{ image['name'] }}:
+  barbicanv1.glance_image_signed:
+    - cloud_name: {{ tempest.keystone_profile_admin }}
+    - image_name: {{ image['name'] }}
+    - pk_fname: {{ tempest.test_cert_key }}
+    - secret_name: {{ secret_name }}
+    - out_fname: /tmp/signature_{{ image['name'] }}
+{%- endfor %}
+
+{%- set users = salt['keystonev3.user_list'](cloud_name=tempest.keystone_profile_admin) %}
+barbican_secret_acl_add_users:
+  module.run:
+    - name: barbicanv1.secret_acl_put
+    - args:
+      - {{ secret_name }}
+    - kwargs:
+        users:
+{%- for user in users['users'] %}
+{%- if prefix in user['name'] %}
+          - {{ user['id'] }}
+{%- endif %}
+{%- endfor %}
+        project-access: True
+        cloud_name: admin_identity
\ No newline at end of file
diff --git a/runtest/tempest.sls b/runtest/tempest.sls
index ac5fb87..4b6d24a 100644
--- a/runtest/tempest.sls
+++ b/runtest/tempest.sls
@@ -59,4 +59,5 @@
       - tempest_config_file
 
 {%- endif %}
+
 {%- endif -%}