secrets.py 563 B

123456789101112131415161718
  1. # Copyright 2016 Cloudbase Solutions Srl
  2. # All Rights Reserved.
  3. import json
  4. from barbicanclient import client as barbican_client
  5. from coriolis import keystone
  6. from coriolis import utils
  7. def get_secret(ctxt, secret_ref):
  8. session = keystone.create_keystone_session(ctxt)
  9. barbican = barbican_client.Client(session=session)
  10. sec = utils.retry_on_error()(barbican.secrets.get)(secret_ref)
  11. # NOTE: accessing `payload` leads to another API call being made:
  12. payload = utils.retry_on_error()(getattr)(sec, "payload")
  13. return json.loads(payload)