class Show(ListCommand):
    """Show quotas for project"""

    columns = ['resource', 'region', 'zone', 'value', 'used']
    _formatters = {
        "region": join_by_key("region"),
        "zone": join_by_key("zone"),
        "value": join_by_key("value"),
        "used": join_by_key("used")
    }
    sorting_support = True

    def get_parser(self, prog_name):
        parser = super(ListCommand, self).get_parser(prog_name)
        parser.add_argument(
            'project_id',
            metavar="<project_id>"
        )
        return parser

    @handle_http_error
    def take_action(self, parsed_args):
        result = self.app.context["client"].quotas.get_project_quotas(
            parsed_args.project_id
        )

        val = {parsed_args.project_id: result._info}
        return self.setup_columns(
            reformat_quotas_with_usages(val), parsed_args
        )
Пример #2
0
class Update(ListCommand):
    """Set quotas for project"""

    columns = ['resource', 'region', 'zone', 'value', 'used']
    _formatters = {
        "region": join_by_key("region"),
        "zone": join_by_key("zone"),
        "value": join_by_key("value"),
        "used": join_by_key("used")
    }
    sorting_support = True

    def get_parser(self, prog_name):
        parser = super(ListCommand, self).get_parser(prog_name)
        required = parser.add_argument_group('Required arguments')
        required.add_argument('project_id',
                              metavar='<project_id>',
                              )
        required.add_argument('-r',
                              '--region',
                              required=True,
                              )
        required.add_argument('-R',
                              '--resource',
                              required=True,
                              )
        required.add_argument('--value',
                              required=True,
                              type=int,
                              )

        optional = parser.add_argument_group('Optional arguments')
        optional.add_argument('-z',
                              '--zone',
                              required=False,
                              default=None,
                              )
        return parser

    @handle_http_error
    def take_action(self, parsed_args):
        quotas = {
            'quotas': {
                parsed_args.resource: [{
                    "region": parsed_args.region,
                    "zone": parsed_args.zone,
                    "value": parsed_args.value
                }]
            }
        }
        result = self.app.context["client"].quotas.update(
            parsed_args.project_id, quotas
        )
        if isinstance(result, PartialResponse):
            result._info = result._info["quotas"]
        val = {parsed_args.project_id: result._info}
        return self.setup_columns(
            reformat_quotas_with_usages(val), parsed_args
        )
Пример #3
0
class List(ListCommand):
    """Show domain quotas"""

    columns = ["resource", "region", "zone", "value"]
    _formatters = {
        "region": join_by_key("region"),
        "zone": join_by_key("zone"),
        "value": join_by_key("value")
    }
    sorting_support = True

    @handle_http_error
    def take_action(self, parsed_args):
        result = self.app.context["client"].quotas.get_domain_quotas()
        return self.setup_columns(reformat_quotas(result._info), parsed_args)
Пример #4
0
class List(ListCommand):
    """Show quotas for all projects"""

    columns = ['project_id', 'resource', 'region', 'zone', 'value', 'used']
    _formatters = {
        "region": join_by_key("region"),
        "zone": join_by_key("zone"),
        "value": join_by_key("value"),
        "used": join_by_key("used")
    }
    sorting_support = True

    @handle_http_error
    def take_action(self, parsed_args):
        result = self.app.context["client"].quotas.get_projects_quotas()
        return self.setup_columns(reformat_quotas_with_usages(result._info),
                                  parsed_args)
class Licenses(ListCommand):
    """Show available license values"""

    columns = ['type', 'availability']
    _formatters = {"availability": join_by_key("availability")}
    sorting_support = True

    @handle_http_error
    def take_action(self, parsed_args):
        result = self.app.context["client"].capabilities.get()
        return self.setup_columns(result.licenses, parsed_args)