Exemple #1
0
 def get_parser(self, prog_name):
     parser = super(SetFlavor, self).get_parser(prog_name)
     parser.add_argument(
         'flavor',
         metavar='<flavor>',
         help=_("Flavor to modify (name or UUID)")
     )
     parser.add_argument(
         '--project',
         metavar='<project>',
         help=_('Set flavor access to project (name or ID) '
                '(admin only)'),
     )
     parser.add_argument(
         '--name',
         metavar='<name>',
         help=_('Set a new name to a flavor (admin only)')
     )
     parser.add_argument(
         '--is-public',
         metavar='<is-public>',
         type=strutils.bool_from_string,
         help=_('Set a flavor to be public or private '
                '(admin only)'),
     )
     parser.add_argument(
         '--disabled',
         metavar='<disabled>',
         type=strutils.bool_from_string,
         help=_('Set a flavor to be disabled or enabled '
                '(admin only)'),
     )
     return parser
 def get_parser(self, prog_name):
     parser = super(AggregateAddNode, self).get_parser(prog_name)
     parser.add_argument("aggregate",
                         metavar="<aggregate>",
                         help=_("Aggregate to add nodes (name or UUID)"))
     parser.add_argument("node",
                         metavar="<node>",
                         help=_("Name of baremetal node"))
     return parser
 def get_parser(self, prog_name):
     parser = super(ShowKeyPair, self).get_parser(prog_name)
     parser.add_argument('keypair',
                         metavar='<keypair>',
                         help=_("Keypair to display (name only)"))
     parser.add_argument(
         "--user",
         metavar="<user-id>",
         help=_("ID of user to whom to add key-pair (Admin only)"))
     return parser
 def get_parser(self, prog_name):
     parser = super(DeleteKeyPair, self).get_parser(prog_name)
     parser.add_argument('key',
                         metavar='<key>',
                         nargs='+',
                         help=_("Name of key(s) to delete (name only)"))
     parser.add_argument(
         "--user",
         metavar="<user-id>",
         help=_("ID of user to whom to add key-pair (Admin only)"))
     return parser
 def get_parser(self, prog_name):
     parser = super(CreateAggregate, self).get_parser(prog_name)
     parser.add_argument("name",
                         metavar="<name>",
                         help=_("Name of baremetal node aggregate"))
     parser.add_argument("--property",
                         metavar="<key=value>",
                         action=parseractions.KeyValueAction,
                         help=_(
                             "Property to add to this node aggregate "
                             "(repeat option to set multiple properties)"))
     return parser
 def get_parser(self, prog_name):
     parser = super(UnsetAggregate, self).get_parser(prog_name)
     parser.add_argument('aggregate',
                         metavar='<aggregate>',
                         help=_("Aggregate(s) to delete (name or UUID)"))
     parser.add_argument(
         "--property",
         metavar="<key>",
         action='append',
         help=_("Property to remove from this node aggregate "
                "(repeat option to remove multiple properties)"))
     return parser
 def get_parser(self, prog_name):
     parser = super(UnsetServer, self).get_parser(prog_name)
     parser.add_argument(
         'server',
         metavar='<server>',
         help=_("Baremetal server to unset its properties (name or UUID)"))
     parser.add_argument(
         "--property",
         metavar="<key>",
         action='append',
         help=_("Property to remove from this server "
                "(repeat option to remove multiple properties)"))
     return parser
 def get_parser(self, prog_name):
     parser = super(RemoveInterface, self).get_parser(prog_name)
     parser.add_argument(
         "port_id",
         metavar="<port-id>",
         help=_("Interface to remove from server"),
     )
     parser.add_argument(
         "server",
         metavar="<server>",
         help=_("Server to remove the interface from"),
     )
     return parser
Exemple #9
0
 def get_parser(self, prog_name):
     parser = super(UnsetFlavor, self).get_parser(prog_name)
     parser.add_argument(
         'flavor',
         metavar='<flavor>',
         help=_("Flavor to modify (name or UUID)")
     )
     parser.add_argument(
         '--project',
         metavar='<project>',
         help=_('Remove flavor access from project (name or ID) '
                '(admin only)'),
     )
     return parser
Exemple #10
0
 def get_parser(self, prog_name):
     parser = super(RemoveFloatingIP, self).get_parser(prog_name)
     parser.add_argument(
         "server",
         metavar="<server>",
         help=_(
             "Server to remove the floating IP address from (name or ID)"),
     )
     parser.add_argument(
         "ip_address",
         metavar="<ip-address>",
         help=_("Floating IP address to remove from server (IP only)"),
     )
     return parser
class PaymentRequired(HTTPClientError):
    """HTTP 402 - Payment Required.

    Reserved for future use.
    """
    status_code = 402
    message = _("Payment Required")
Exemple #12
0
class RemoveInterface(command.Command):
    _description = _("Remove interface from server")

    def get_parser(self, prog_name):
        parser = super(RemoveInterface, self).get_parser(prog_name)
        parser.add_argument(
            "port_id",
            metavar="<port-id>",
            help=_("Interface to remove from server"),
        )
        parser.add_argument(
            "server",
            metavar="<server>",
            help=_("Server to remove the interface from"),
        )
        return parser

    def take_action(self, parsed_args):
        bc_client = self.app.client_manager.baremetal_compute
        server = utils.find_resource(
            bc_client.server,
            parsed_args.server,
        )

        bc_client.server.remove_interface(server.uuid, parsed_args.port_id)
Exemple #13
0
class AddInterface(command.Command):
    _description = _("Add interface to server")

    def get_parser(self, prog_name):
        parser = super(AddInterface, self).get_parser(prog_name)
        excluded_group = parser.add_mutually_exclusive_group(required=True)
        excluded_group.add_argument(
            "--net-id",
            metavar="<net-id>",
            help=_("Network to link to server"),
        )
        excluded_group.add_argument(
            "--port-id",
            metavar="<port-id>",
            help=_("Port to link to server"),
        )
        parser.add_argument(
            "server",
            metavar="<server>",
            help=_("Server to attach interface for"),
        )
        return parser

    def take_action(self, parsed_args):
        bc_client = self.app.client_manager.baremetal_compute
        server = utils.find_resource(
            bc_client.server,
            parsed_args.server,
        )

        bc_client.server.add_interface(server.uuid, parsed_args.net_id,
                                       parsed_args.port_id)
class ServiceUnavailable(HttpServerError):
    """HTTP 503 - Service Unavailable.

    The server is currently unavailable.
    """
    status_code = 503
    message = _("Service Unavailable")
Exemple #15
0
class RemoveFloatingIP(command.Command):
    _description = _("Remove floating IP address from server")

    def get_parser(self, prog_name):
        parser = super(RemoveFloatingIP, self).get_parser(prog_name)
        parser.add_argument(
            "server",
            metavar="<server>",
            help=_(
                "Server to remove the floating IP address from (name or ID)"),
        )
        parser.add_argument(
            "ip_address",
            metavar="<ip-address>",
            help=_("Floating IP address to remove from server (IP only)"),
        )
        return parser

    def take_action(self, parsed_args):
        bc_client = self.app.client_manager.baremetal_compute
        server = utils.find_resource(
            bc_client.server,
            parsed_args.server,
        )

        bc_client.server.remove_floating_ip(server.uuid,
                                            parsed_args.ip_address)
class ProxyAuthenticationRequired(HTTPClientError):
    """HTTP 407 - Proxy Authentication Required.

    The client must first authenticate itself with the proxy.
    """
    status_code = 407
    message = _("Proxy Authentication Required")
class HttpServerError(HttpError):
    """Server-side HTTP error.

    Exception for cases in which the server is aware that it has
    erred or is incapable of performing the request.
    """
    message = _("HTTP Server Error")
class RequestUriTooLong(HTTPClientError):
    """HTTP 414 - Request-URI Too Long.

    The URI provided was too long for the server to process.
    """
    status_code = 414
    message = _("Request-URI Too Long")
class RequestTimeout(HTTPClientError):
    """HTTP 408 - Request Timeout.

    The server timed out waiting for the request.
    """
    status_code = 408
    message = _("Request Timeout")
Exemple #20
0
    def take_action(self, parsed_args):

        bc_client = self.app.client_manager.baremetal_compute
        data = utils.find_resource(
            bc_client.flavor,
            parsed_args.flavor,
        )
        updates = []
        if parsed_args.name:
            updates.append({"op": "replace",
                            "path": "/name",
                            "value": parsed_args.name})
        if parsed_args.is_public is not None:
            updates.append({"op": "replace",
                            "path": "/is_public",
                            "value": parsed_args.is_public})
        if parsed_args.disabled is not None:
            updates.append({"op": "replace",
                            "path": "/disabled",
                            "value": parsed_args.disabled})
        if updates:
            bc_client.flavor.update(data, updates)
        if parsed_args.project:
            if data.is_public:
                msg = _("Cannot set access for a public flavor")
                raise exceptions.CommandError(msg)
            else:
                bc_client.flavor.add_tenant_access(
                    data, parsed_args.project)
class ExpectationFailed(HTTPClientError):
    """HTTP 417 - Expectation Failed.

    The server cannot meet the requirements of the Expect request-header field.
    """
    status_code = 417
    message = _("Expectation Failed")
class HttpVersionNotSupported(HttpServerError):
    """HTTP 505 - HttpVersion Not Supported.

    The server does not support the HTTP protocol version used in the request.
    """
    status_code = 505
    message = _("HTTP Version Not Supported")
 def get_parser(self, prog_name):
     parser = super(SetAggregate, self).get_parser(prog_name)
     parser.add_argument('aggregate',
                         metavar='<aggregate>',
                         help=_("Aggregate(s) to delete (name or UUID)"))
     parser.add_argument(
         '--name',
         metavar='<name>',
         help=_('Set a new name to a node aggregate (admin only)'))
     parser.add_argument("--property",
                         metavar="<key=value>",
                         action=parseractions.KeyValueAction,
                         help=_(
                             "Property to set on this node aggregate "
                             "(repeat option to set multiple properties)"))
     return parser
Exemple #24
0
    def _action_multiple_items(self, parsed_args, action, method_name,
                               **kwargs):
        bc_client = self.app.client_manager.baremetal_compute
        result = 0
        for one_server in parsed_args.server:
            try:
                data = utils.find_resource(bc_client.server, one_server)
                method = getattr(bc_client.server, method_name)
                method(data.uuid, **kwargs)
            except Exception as e:
                result += 1
                LOG.error(
                    "Failed to %(action)s server with name or UUID "
                    "'%(server)s': %(e)s", {
                        'action': action,
                        'server': one_server,
                        'e': e
                    })

        if result > 0:
            total = len(parsed_args.server)
            msg = (_("%(result)s of %(total)s baremetal servers failed "
                     "to %(action)s.") % {
                         'result': result,
                         'total': total,
                         'action': action
                     })
            raise exceptions.CommandError(msg)
class BadRequest(HTTPClientError):
    """HTTP 400 - Bad Request.

    The request cannot be fulfilled due to bad syntax.
    """
    status_code = 400
    message = _("Bad Request")
Exemple #26
0
class AddFloatingIP(command.Command):
    _description = _("Add floating IP address to server")

    def get_parser(self, prog_name):
        parser = super(AddFloatingIP, self).get_parser(prog_name)
        parser.add_argument(
            "server",
            metavar="<server>",
            help=_("Server to receive the floating IP address (name or ID)"),
        )
        parser.add_argument(
            "ip_address",
            metavar="<ip-address>",
            help=_("Floating IP address to assign to server (IP only)"),
        )
        parser.add_argument(
            "--fixed-ip-address",
            metavar="<ip-address>",
            help=_("Fixed IP address to associate with this floating IP "
                   "address"),
        )
        return parser

    def take_action(self, parsed_args):
        bc_client = self.app.client_manager.baremetal_compute
        server = utils.find_resource(
            bc_client.server,
            parsed_args.server,
        )

        bc_client.server.add_floating_ip(server.uuid, parsed_args.ip_address,
                                         parsed_args.fixed_ip_address)
 def get_parser(self, prog_name):
     parser = super(AggregateListNode, self).get_parser(prog_name)
     parser.add_argument(
         "aggregate",
         metavar="<aggregate>",
         help=_("Aggregate to list its nodes (name or UUID)"))
     return parser
class InternalServerError(HttpServerError):
    """HTTP 500 - Internal Server Error.

    A generic error message, given when no more specific message is suitable.
    """
    status_code = 500
    message = _("Internal Server Error")
 def get_parser(self, prog_name):
     parser = super(DeleteAggregate, self).get_parser(prog_name)
     parser.add_argument('aggregate',
                         metavar='<aggregate>',
                         nargs='+',
                         help=_("Aggregate(s) to delete (name or UUID)"))
     return parser
Exemple #30
0
 def get_parser(self, prog_name):
     parser = super(ShowServer, self).get_parser(prog_name)
     parser.add_argument(
         'server',
         metavar='<server>',
         help=_("Baremetal server to display (name or UUID)"))
     return parser