コード例 #1
0
ファイル: __init__.py プロジェクト: itsuugo/midonet
def handshake(sock, cnxn_id, req_id):
    """Performs the initial handshake operation with the topology server"""
    sock.send(utils.encode_delimited(_handshake_msg(cnxn_id, req_id).SerializeToString()))
    response = topology_api_pb2.Response()
    try:
        response.ParseFromString(utils.get_answer(sock))
    except socket.timeout:
        issue = "Timed out receiving Handshake protobuf response"
        LOG.exception(issue)
        raise TopologyError(issue)
    except PBDecodeError:
        issue = "Failed to parse Handshake protobuf response"
        LOG.exception(issue)
        raise TopologyError(issue)
    if response.type != topology_api_pb2.ResponseType.Value("ACK"):
        raise HandshakeError(
            "Failed to handshake with the topology API. Got response %s" % utils.proto_to_dict(response)
        )
コード例 #2
0
ファイル: __init__.py プロジェクト: itsuugo/midonet
def get(sock, kind, obj_uuid, req_id=None):
    """Returns a Protobuf Response object for a Request.Get command"""
    if req_id is None:
        req_id = uuid.uuid4()
    get = _get_msg(req_id, kind, obj_uuid)
    sock.send(utils.encode_delimited(get.SerializeToString()))
    response = topology_api_pb2.Response()
    try:
        response.ParseFromString(utils.get_answer(sock))
    except socket.timeout:
        issue = "Timed out receiving Get protobuf response"
        LOG.exception(issue)
        raise TopologyError(issue)
    except PBDecodeError:
        issue = "Failed to parse Get protobuf response"
        LOG.exception(issue)
        raise TopologyError(issue)
    return response
コード例 #3
0
ファイル: __init__.py プロジェクト: williamwang0/MusicGen
def get(sock, kind, obj_uuid, req_id=None):
    """Returns a Protobuf Response object for a Request.Get command"""
    if req_id is None:
        req_id = uuid.uuid4()
    get = _get_msg(req_id, kind, obj_uuid)
    sock.send(utils.encode_delimited(get.SerializeToString()))
    response = topology_api_pb2.Response()
    try:
        response.ParseFromString(utils.get_answer(sock))
    except socket.timeout:
        issue = 'Timed out receiving Get protobuf response'
        LOG.exception(issue)
        raise TopologyError(issue)
    except PBDecodeError:
        issue = 'Failed to parse Get protobuf response'
        LOG.exception(issue)
        raise TopologyError(issue)
    return response
コード例 #4
0
ファイル: __init__.py プロジェクト: williamwang0/MusicGen
def handshake(sock, cnxn_id, req_id):
    """Performs the initial handshake operation with the topology server"""
    sock.send(
        utils.encode_delimited(
            _handshake_msg(cnxn_id, req_id).SerializeToString()))
    response = topology_api_pb2.Response()
    try:
        response.ParseFromString(utils.get_answer(sock))
    except socket.timeout:
        issue = 'Timed out receiving Handshake protobuf response'
        LOG.exception(issue)
        raise TopologyError(issue)
    except PBDecodeError:
        issue = 'Failed to parse Handshake protobuf response'
        LOG.exception(issue)
        raise TopologyError(issue)
    if response.type != topology_api_pb2.ResponseType.Value('ACK'):
        raise HandshakeError(
            'Failed to handshake with the topology API. Got response %s' %
            utils.proto_to_dict(response))