From b94053510f9804ac25865f1ac623d5532b9598dd Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Fri, 27 Mar 2015 14:01:11 +0100 Subject: [PATCH] Fix order creation on the command line This patch adds a new --type argument to order creation which allows creating order again. Change-Id: I58429f70753cf87c951756579f8ff2837766720e Closes-Bug: #1434615 --- barbicanclient/barbican_cli/orders.py | 5 ++++- barbicanclient/orders.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/barbicanclient/barbican_cli/orders.py b/barbicanclient/barbican_cli/orders.py index 06a39c4c..f1b4db93 100644 --- a/barbicanclient/barbican_cli/orders.py +++ b/barbicanclient/barbican_cli/orders.py @@ -27,6 +27,8 @@ class CreateOrder(show.ShowOne): parser = super(CreateOrder, self).get_parser(prog_name) parser.add_argument('--name', '-n', help='a human-friendly name.') + parser.add_argument('--type', '-p', + help='the type of the order to create.') parser.add_argument('--algorithm', '-a', default='aes', help='the algorithm to be used with the ' 'requested key (default: ' @@ -49,7 +51,8 @@ class CreateOrder(show.ShowOne): def take_action(self, args): entity = self.app.client.orders.create( - name=args.name, payload_content_type=args.payload_content_type, + name=args.name, type=args.type, + payload_content_type=args.payload_content_type, algorithm=args.algorithm, bit_length=args.bit_length, mode=args.mode, expiration=args.expiration) entity.submit() diff --git a/barbicanclient/orders.py b/barbicanclient/orders.py index 49c6de45..8cfde36c 100644 --- a/barbicanclient/orders.py +++ b/barbicanclient/orders.py @@ -335,6 +335,13 @@ class OrderManager(base.BaseEntityManager): else: raise TypeError('Unknown Order type "{0}"'.format(order_type)) + def create(self, type=None, **kwargs): + order_type = self._order_type_to_class_map.get(type.lower()) + if order_type is not None: + return order_type(self._api, **kwargs) + else: + raise TypeError('Unknown Order type "{0}"'.format(type)) + def create_key(self, name=None, algorithm=None, bit_length=None, mode=None, payload_content_type=None, expiration=None): """