Exemplo n.º 1
0
    def take_action(self, parsed_args):
        LOG.debug('take_action({0})'.format(parsed_args))

        prop = {}
        for datum in parsed_args.property:
            key, value = datum.split('=', 1)
            prop[key] = value

        for datum in parsed_args.list:
            key, value = datum.split('=', 1)
            value = strutils.split_by_commas(value)
            prop[key] = value

        for datum in parsed_args.dict:
            key, value = datum.split('=', 1)
            value = strutils.split_by_commas(value)
            prop[key] = {}
            for elem in value:
                k, v = elem.split(':', 1)
                prop[key][k] = v

        client = self.app.client_manager.artifact
        af_id = glare_utils.get_artifact_id(client, parsed_args)
        data = client.artifacts.update(
            af_id, type_name=parsed_args.type_name,
            remove_props=parsed_args.remove_property, **prop)

        return print_artifact(client, data, parsed_args.type_name)
Exemplo n.º 2
0
    def take_action(self, parsed_args):
        LOG.debug('take_action({0})'.format(parsed_args))

        prop = {}
        for datum in parsed_args.property:
            key, value = datum.split('=', 1)
            prop[key] = value

        for datum in parsed_args.list:
            key, value = datum.split('=', 1)
            value = strutils.split_by_commas(value)
            prop[key] = value

        for datum in parsed_args.dict:
            key, value = datum.split('=', 1)
            value = strutils.split_by_commas(value)
            prop[key] = {}
            for elem in value:
                k, v = elem.split(':', 1)
                prop[key][k] = v

        client = self.app.client_manager.artifact
        data = client.artifacts.create(parsed_args.name,
                                       type_name=parsed_args.type_name,
                                       version=parsed_args.artifact_version,
                                       **prop)
        return print_artifact(client, data, parsed_args.type_name)
Exemplo n.º 3
0
 def set_labels(cls, config):
     labels = {}
     ls = strutils.split_by_commas(CONF.magnum.get('labels', None))
     for l in ls:
         try:
             (k, v) = l.split(('='), 1)
         except ValueError:
             raise Exception('labels must be in format key1=val1,key2-val2')
         if k not in labels:
             labels[k] = v
         else:
             raise Exception('key %s in labels defined multiple times')
     cls.labels = labels
Exemplo n.º 4
0
 def check(self, expect, input):
     self.assertEqual(expect, strutils.split_by_commas(input))
Exemplo n.º 5
0
 def check(self, expect, input):
     self.assertEqual(expect, strutils.split_by_commas(input))