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) )
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
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
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))