Ejemplo n.º 1
0
 def test_args_array_to_patch(self):
     my_args = {
         'attributes': [
             'str=foo', 'int=1', 'bool=true', 'list=[1, 2, 3]',
             'dict={"foo": "bar"}'
         ],
         'op':
         'add',
     }
     patch = utils.args_array_to_patch(my_args['op'], my_args['attributes'])
     self.assertEqual([{
         'op': 'add',
         'value': 'foo',
         'path': '/str'
     }, {
         'op': 'add',
         'value': 1,
         'path': '/int'
     }, {
         'op': 'add',
         'value': True,
         'path': '/bool'
     }, {
         'op': 'add',
         'value': [1, 2, 3],
         'path': '/list'
     }, {
         'op': 'add',
         'value': {
             "foo": "bar"
         },
         'path': '/dict'
     }], patch)
Ejemplo n.º 2
0
 def test_args_array_to_patch_remove(self):
     my_args = {
         'attributes': ['/foo', 'extra/bar'],
         'op': 'remove',
     }
     patch = utils.args_array_to_patch(my_args['op'],
                                       my_args['attributes'])
     self.assertEqual([{'op': 'remove', 'path': '/foo'},
                       {'op': 'remove', 'path': '/extra/bar'}], patch)
Ejemplo n.º 3
0
 def test_args_array_to_patch(self):
     my_args = {
         'attributes': ['str=foo', 'int=1', 'bool=true',
                        'list=[1, 2, 3]', 'dict={"foo": "bar"}'],
         'op': 'add',
     }
     patch = utils.args_array_to_patch(my_args['op'],
                                       my_args['attributes'])
     self.assertEqual([{'op': 'add', 'value': 'foo', 'path': '/str'},
                       {'op': 'add', 'value': 1, 'path': '/int'},
                       {'op': 'add', 'value': True, 'path': '/bool'},
                       {'op': 'add', 'value': [1, 2, 3], 'path': '/list'},
                       {'op': 'add', 'value': {"foo": "bar"},
                        'path': '/dict'}], patch)
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        patch = common_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0])

        audit_template = client.audit_template.update(
            parsed_args.audit_template, patch)

        columns = res_fields.AUDIT_TEMPLATE_FIELDS
        column_headers = res_fields.AUDIT_TEMPLATE_FIELD_LABELS

        return column_headers, utils.get_item_properties(
            audit_template, columns)
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        patch = common_utils.args_array_to_patch(
            parsed_args.op, parsed_args.attributes[0])

        audit_template = client.audit_template.update(
            parsed_args.audit_template, patch)

        columns = res_fields.AUDIT_TEMPLATE_FIELDS
        column_headers = res_fields.AUDIT_TEMPLATE_FIELD_LABELS

        return column_headers, utils.get_item_properties(
            audit_template, columns)
Ejemplo n.º 6
0
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        if not uuidutils.is_uuid_like(parsed_args.action_plan):
            raise exceptions.ValidationError()

        patch = common_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0])

        action_plan = client.action_plan.update(parsed_args.action_plan, patch)

        columns = res_fields.ACTION_PLAN_FIELDS
        column_headers = res_fields.ACTION_PLAN_FIELD_LABELS

        return column_headers, utils.get_item_properties(action_plan, columns)
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        if not uuidutils.is_uuid_like(parsed_args.action_plan):
            raise exceptions.ValidationError()

        patch = common_utils.args_array_to_patch(
            parsed_args.op, parsed_args.attributes[0])

        action_plan = client.action_plan.update(parsed_args.action_plan, patch)

        columns = res_fields.ACTION_PLAN_FIELDS
        column_headers = res_fields.ACTION_PLAN_FIELD_LABELS

        return column_headers, utils.get_item_properties(action_plan, columns)
Ejemplo n.º 8
0
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        patch = common_utils.args_array_to_patch(parsed_args.op,
                                                 parsed_args.attributes[0],
                                                 exclude_fields=['/interval'])

        audit = client.audit.update(parsed_args.audit, patch)

        columns = res_fields.AUDIT_FIELDS
        column_headers = res_fields.AUDIT_FIELD_LABELS

        columns, column_headers = drop_unsupported_field(
            self.app_args, columns, column_headers)

        return column_headers, utils.get_item_properties(audit, columns)
Ejemplo n.º 9
0
    def take_action(self, parsed_args):
        client = getattr(self.app.client_manager, "infra-optim")

        patch = common_utils.args_array_to_patch(
            parsed_args.op, parsed_args.attributes[0],
            exclude_fields=['/interval'])

        audit = client.audit.update(parsed_args.audit, patch)

        columns = res_fields.AUDIT_FIELDS
        column_headers = res_fields.AUDIT_FIELD_LABELS

        columns, column_headers = drop_start_end_field(self.app_args, columns,
                                                       column_headers)

        return column_headers, utils.get_item_properties(audit, columns)