Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from keystoneclient.v3 import client
- from oslo_config import cfg
- from oslo_context import context
- from castellan import key_manager
- from castellan import options
- def main():
- """Main module that establishes a connection to barbican my using the
- values parsed from a command file"""
- username = 'xxxx'
- password = 'xxxx'
- project_name = 'xxxx'
- auth_url = 'http://localhost:5000/v3'
- keystone_client = client.Client(username=username,
- password=password,
- project_name=project_name,
- auth_url=auth_url,
- project_domain_id='default')
- ctxt = context.RequestContext(auth_token=keystone_client.auth_token,
- tenant='xxxx')
- conf = cfg.ConfigOpts()
- conf(default_config_files=['/etc/castellan/castellan.conf'])
- # Create a key_manager that use the values in the configuration file
- manager = key_manager.API(configuration=conf)
- #The remaining code is sample castellan code that will try and store a key
- #using the values setup in the castellan file
- import pdb; pdb.set_trace()
- key_id = manager.create_key(context=ctxt, algorithm="AES", length=256)
- print "retrieving key"
- get_key = manager.get(ctxt, key_id)
- print "key retrieves is: {}".format(get_key.get_encoded())
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement