def take_action(self, parsed_args):

        attrs = {
            'operation_definition': {},
            'trigger': {
                'properties': {
                    'pattern': []
                }
            }
        }

        # mandatory
        attrs['name'] = parsed_args.name
        attrs['enabled'] = parsed_args.disable
        attrs['operation_type'] = parsed_args.operation_type
        attrs['trigger']['properties']['pattern'] = parsed_args.patterns

        # optional
        if parsed_args.day_backups:
            attrs['operation_definition'].update(
                day_backups=parsed_args.day_backups)
        if parsed_args.week_backups:
            attrs['operation_definition'].update(
                week_backups=parsed_args.week_backups)
        if parsed_args.month_backups:
            attrs['operation_definition'].update(
                month_backups=parsed_args.month_backups)
        if parsed_args.year_backups:
            attrs['operation_definition'].update(
                year_backups=parsed_args.year_backups)
        if parsed_args.max_backups:
            attrs['operation_definition'].update(
                max_backups=parsed_args.max_backups)
        if parsed_args.retention_duration_days:
            rdd = parsed_args.retention_duration_days
            attrs['operation_definition'].update(retention_duration_days=rdd)

        if (parsed_args.day_backups or parsed_args.week_backups
                or parsed_args.month_backups
                or parsed_args.year_backups) and not parsed_args.timezone:
            msg = ("Parameter timezone must be provided if "
                   "<day|week|month|year>_backups are being used.")
            raise exceptions.BadRequest(msg)

        if parsed_args.timezone:
            attrs['operation_definition'].update(timezone=parsed_args.timezone)

        client = self.app.client_manager.cbr
        obj = client.create_policy(**attrs)

        data = utils.get_dict_properties(_flatten_policy(obj), self.columns)

        if obj.trigger.properties.pattern:
            data, self.columns = _add_scheduling_patterns(
                obj, data, self.columns)

        return (self.columns, data)
    def test_quota_list_compute_no_project_4xx(self):
        # Make one of the projects disappear
        self.compute.quotas.get = mock.Mock(side_effect=[
            self.compute_quotas[0],
            exceptions.BadRequest("Bad request"),
        ], )

        arglist = [
            '--compute',
        ]
        verifylist = [
            ('compute', True),
        ]
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)

        columns, data = self.cmd.take_action(parsed_args)
        ret_quotas = list(data)

        self.assertEqual(self.compute_column_header, columns)
        self.assertEqual(self.compute_reference_data, ret_quotas[0])
        self.assertEqual(1, len(ret_quotas))