From b7107c848fea59e4eae8456e87e1e1a2340ad051 Mon Sep 17 00:00:00 2001 From: Jose Castro Leon Date: Wed, 31 Oct 2018 13:41:51 +0100 Subject: [PATCH] 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 --- mistral/actions/openstack/actions.py | 20 +++++++++++++++++--- mistral/actions/openstack/mapping.json | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mistral/actions/openstack/actions.py b/mistral/actions/openstack/actions.py index e8eb71b75..a061b0513 100644 --- a/mistral/actions/openstack/actions.py +++ b/mistral/actions/openstack/actions.py @@ -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' diff --git a/mistral/actions/openstack/mapping.json b/mistral/actions/openstack/mapping.json index 5cbe7129a..710442b9d 100644 --- a/mistral/actions/openstack/mapping.json +++ b/mistral/actions/openstack/mapping.json @@ -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.",