Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. import os
  2. from keystoneclient.v3 import client
  3. from oslo_config import cfg
  4. from oslo_context import context
  5. from castellan import key_manager
  6. from castellan import options
  7.  
  8.  
  9. def main():
  10. """Main module that establishes a connection to barbican my using the
  11. values parsed from a command file"""
  12.  
  13. username = 'xxxx'
  14. password = 'xxxx'
  15. project_name = 'xxxx'
  16. auth_url = 'http://localhost:5000/v3'
  17.  
  18. keystone_client = client.Client(username=username,
  19. password=password,
  20. project_name=project_name,
  21. auth_url=auth_url,
  22. project_domain_id='default')
  23.  
  24. ctxt = context.RequestContext(auth_token=keystone_client.auth_token,
  25. tenant='xxxx')
  26.  
  27. conf = cfg.ConfigOpts()
  28.  
  29.  
  30. conf(default_config_files=['/etc/castellan/castellan.conf'])
  31. # Create a key_manager that use the values in the configuration file
  32. manager = key_manager.API(configuration=conf)
  33. #The remaining code is sample castellan code that will try and store a key
  34. #using the values setup in the castellan file
  35.  
  36. import pdb; pdb.set_trace()
  37. key_id = manager.create_key(context=ctxt, algorithm="AES", length=256)
  38.  
  39. print "retrieving key"
  40.  
  41. get_key = manager.get(ctxt, key_id)
  42. print "key retrieves is: {}".format(get_key.get_encoded())
  43.  
  44.  
  45. if __name__ == "__main__":
  46. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement