示例#1
0
    def take_action(self, parsed_args):
        barbican = pdkutil.PDKUtil().create_client(parsed_args)
        my_container = barbican.containers.create(
            name=parsed_args.container_name)
        f = open(parsed_args.filename, 'rb')
        secret_number = 1
        for piece in self.read_in_chunks(f):
            secret_payload = piece
            secret = barbican.secrets.create(
                name=u'Secret ' + str(secret_number), payload=secret_payload)
            secret_reference = secret.store()
            my_container.add(str(secret_number),
                             barbican.secrets.get(secret_reference))
            secret_number += 1
        container_reference = my_container.store()

        columns = ('PDK_file',
                   'Container_name',
                   'Container_reference',
                   )
        data = (parsed_args.filename,
                parsed_args.container_name,
                container_reference,
                )
        return (columns, data)
示例#2
0
 def get_parser(self, prog_name):
     parser = super(Store, self).get_parser(prog_name)
     pdkutil.PDKUtil().build_parser(parser)
     parser.add_argument('filename',
                         metavar='<filename>')
     parser.add_argument('container_name',
                         metavar='<container-name>')
     return parser
示例#3
0
 def take_action(self, parsed_args):
     barbican = pdkutil.PDKUtil().create_client(parsed_args)
     columns = (
         'Reference',
         'Name',
     )
     data = (
         parsed_args.container_reference,
         'This container does not exist.',
     )
     for container in barbican.containers.list():
         if parsed_args.container_reference == container.container_ref:
             columns = ('Reference', 'Name', 'Created', 'Status', 'Secrets')
             items = container.secrets.items()
             data = (container.container_ref, container.name,
                     container.created, container.status,
                     '\n'.join(value.secret_ref for key, value in items))
     return (columns, data)
示例#4
0
 def get_parser(self, prog_name):
     parser = super(Get, self).get_parser(prog_name)
     pdkutil.PDKUtil().build_parser(parser)
     parser.add_argument('container_reference',
                         metavar='<container-reference>')
     return parser