Пример #1
0
    def edit_link(
        self,
        session_id,
        node_one_id,
        node_two_id,
        options,
        interface_one_id=None,
        interface_two_id=None,
    ):
        """
        Edit a link between nodes.

        :param int session_id: session id
        :param int node_one_id: node one id
        :param int node_two_id: node two id
        :param core_pb2.LinkOptions options: options for link (jitter, bandwidth, etc)
        :param int interface_one_id: node one interface id
        :param int interface_two_id: node two interface id
        :return: response with result of success or failure
        :rtype: core_pb2.EditLinkResponse
        :raises grpc.RpcError: when session or one of the nodes don't exist
        """
        request = core_pb2.EditLinkRequest(
            session_id=session_id,
            node_one_id=node_one_id,
            node_two_id=node_two_id,
            options=options,
            interface_one_id=interface_one_id,
            interface_two_id=interface_two_id,
        )
        return self.stub.EditLink(request)
Пример #2
0
    def edit_link(self,
                  session_id: int,
                  link: wrappers.Link,
                  source: str = None) -> bool:
        """
        Edit a link between nodes.

        :param session_id: session id
        :param link: link to edit
        :param source: application source
        :return: response with result of success or failure
        :raises grpc.RpcError: when session or one of the nodes don't exist
        """
        iface1_id = link.iface1.id if link.iface1 else None
        iface2_id = link.iface2.id if link.iface2 else None
        request = core_pb2.EditLinkRequest(
            session_id=session_id,
            node1_id=link.node1_id,
            node2_id=link.node2_id,
            options=link.options.to_proto(),
            iface1_id=iface1_id,
            iface2_id=iface2_id,
            source=source,
        )
        response = self.stub.EditLink(request)
        return response.result