1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
import argparse
from barbicanclient import client
IDENTITY = 'https://identity.api.rackspacecloud.com/v2.0'
ENDPOINT = 'https://barbican.api.rackspacecloud.com/v1/'
def connect(username, password, tenant, endpoint):
connection = client.Connection(IDENTITY,
username,
password,
tenant,
endpoint=endpoint)
return connection
def parse_args():
parser = argparse.ArgumentParser(
description='Testing code for creating barbican order.'
)
parser.add_argument(
'--username',
help='The keystone username used for authentication'
)
parser.add_argument(
'--password',
help='The keystone password used for authentication'
)
parser.add_argument(
'--tenant',
help='The keystone tenant used for authentication'
)
parser.add_argument(
'--keystone',
default=IDENTITY,
help='The keystone endpoint used for authentication'
)
parser.add_argument(
'--endpoint',
default=ENDPOINT,
help='The barbican endpoint to test against'
)
parser.add_argument(
'--name',
help='Name of secret'
)
parser.add_argument(
'--mime-type',
help='MIME type of secret to create'
)
parser.add_argument(
'--algorithm',
help='Algorithm of secret to create'
)
parser.add_argument(
'--bit-length',
help='Bit length of secret to create'
)
parser.add_argument(
'--cypher-type',
help='Cypher type of secret to create'
)
args = parser.parse_args()
return args
if __name__ == '__main__':
args = parse_args()
conn = connect(args.username, args.password, args.tenant, args.endpoint)
order = conn.create_order(args.name,
args.mime_type,
args.algorithm,
args.bit_length,
args.cypher_type)
print order
|