Demo entry 6639933



Submitted by anonymous on Sep 11, 2017 at 06:54
Language: Python. Code size: 1.7 kB.

class InterfaceController(ServerControllerBase):
    def __init__(self, *args, **kwargs):
        super(InterfaceController, self).__init__(*args, **kwargs)

    @policy.authorize_wsgi("mogan:server", "attach_interface")
    @expose.expose(None, types.uuid, body=types.jsontype,
    def post(self, server_uuid, interface):
        """Attach Interface.
        :param server_uuid: UUID of a server.
        :param interface: The Baremetal Network ID within the request body.
        validation.check_schema(interface, interface_schemas.attach_interface)

        port_id = interface.get('port_id', None)
        net_id = interface.get('net_id', None)

        server = self._resource or self._get_resource(server_uuid)
                                                  server, net_id, port_id)

    @policy.authorize_wsgi("mogan:server", "detach_interface")
    @expose.expose(None, types.uuid, types.uuid,
    def delete(self, server_uuid, port_id):
        """Detach Interface
        :param server_uuid: UUID of a server.
        :param port_id: The Port ID within the request body.
        server = self._resource or self._get_resource(server_uuid)
        server_nics = server.nics
        if port_id not in [nic.port_id for nic in server_nics]:
            raise exception.InterfaceNotFoundForServer(server=server_uuid)

                                                  server, port_id)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).