Adds secrets_retrieve to the list of available actions in barbican

This method allows to retrieve the payloads of secrets in the
workflows.

Change-Id: I7d391a6b46ddd4b388c11a69b75f2a2cd7e40384
Closes-Bug: #1800821
This commit is contained in:
Jose Castro Leon 2018-10-31 13:41:51 +01:00 committed by Renat Akhmerov
parent 13d8f532b9
commit b7107c848f
2 changed files with 19 additions and 4 deletions

View File

@ -609,7 +609,8 @@ class BarbicanAction(base.OpenStackAction):
@classmethod
def _get_client_method(cls, client):
if cls.client_method_name != "secrets_store":
if cls.client_method_name not in ["secrets_store",
"secrets_retrieve"]:
return super(BarbicanAction, cls)._get_client_method(client)
method = getattr(cls, cls.client_method_name)
@ -635,8 +636,8 @@ class BarbicanAction(base.OpenStackAction):
mode=None, expiration=None):
"""Create and Store a secret in Barbican.
:param client: the Zaqar client
:type client: zaqarclient.queues.client
:param client: the Barbican client
:type client: barbicanclient.client
:param name: A friendly name for the Secret
:type name: string
@ -677,6 +678,19 @@ class BarbicanAction(base.OpenStackAction):
return entity._get_formatted_entity()
@staticmethod
def secrets_retrieve(client, secret_ref):
"""Retrieve the payload from a secret in Barbican.
:param client: the Barbican client
:type client: barbicanclient.client
:param secret_ref: Full HATEOAS reference to a Secret
:type name: string
"""
return client.secrets.get(secret_ref).payload
class DesignateAction(base.OpenStackAction):
_service_type = 'dns'

View File

@ -1000,7 +1000,8 @@
"secrets_delete": "secrets.delete",
"secrets_get": "secrets.get",
"secrets_list": "secrets.list",
"secrets_total": "secrets.total"
"secrets_total": "secrets.total",
"secrets_retrieve": "secrets_retrieve"
},
"mistral": {
"_comment": "It uses mistralclient.v2.",