示例#1
0
    def post(self, port):

        """Create a new port.

        :param port: a port within the request body.
        """
        if self.from_nodes:
            raise exception.OperationNotPermitted

        if not (api_utils.allow_node_name()):
            if port.node_uuid == wtypes.Unset:
                e = exception.BadRequest()
                e.code = 400
                raise e

        new_port = objects.Port(pecan.request.context, **port.as_dict())
        new_port.create()
        # Set the HTTP Location Header
        pecan.response.location = link.build_url("ports", new_port.uuid)
        return Port.convert_with_links(new_port)
示例#2
0
 def mandatory_attrs():
     if api_utils.allow_node_name():
         return ["address", "/node"]
     return ["/address", "/node_uuid"]