def _handshake_msg(cnxn_id=None, req_id=None): """Msg for starting a session with the topology server""" if cnxn_id is None: cnxn_id = uuid.uuid4() # Random uuid if req_id is None: req_id = uuid.uuid4() # Random uuid request = topology_api_pb2.Request() request.handshake.cnxn_id.msb, request.handshake.cnxn_id.lsb = utils.split_uuid(cnxn_id) request.handshake.req_id.msb, request.handshake.req_id.lsb = utils.split_uuid(req_id) return request
def _handshake_msg(cnxn_id=None, req_id=None): """Msg for starting a session with the topology server""" if cnxn_id is None: cnxn_id = uuid.uuid4() # Random uuid if req_id is None: req_id = uuid.uuid4() # Random uuid request = topology_api_pb2.Request() request.handshake.cnxn_id.msb, request.handshake.cnxn_id.lsb = ( utils.split_uuid(cnxn_id)) request.handshake.req_id.msb, request.handshake.req_id.lsb = ( utils.split_uuid(req_id)) return request
def _get_msg(req_id, kind, obj_uuid): """Msg for fetching resources from the topology api with the specified type Returns: - A topology_pb2.update object if obj_uuid is specified, or - a topology_api_pb2.Response.snapshot of all the uuids of the specified kind. """ request = topology_api_pb2.Request() request.get.req_id.msb, request.get.req_id.lsb = utils.split_uuid(req_id) request.get.type = kind if obj_uuid is not None: request.get.id.msb, request.get.id.lsb = utils.split_uuid(obj_uuid) return request
def _get_msg(req_id, kind, obj_uuid): """Msg for fetching resources from the topology api with the specified type Returns: - A topology_pb2.update object if obj_uuid is specified, or - a topology_api_pb2.Response.snapshot of all the uuids of the specified kind. """ request = topology_api_pb2.Request() request.get.req_id.msb, request.get.req_id.lsb = (utils.split_uuid(req_id)) request.get.type = kind if obj_uuid is not None: request.get.id.msb, request.get.id.lsb = utils.split_uuid(obj_uuid) return request
def _bye_msg(req_id): """Msg for notifying the server of the end of session Returns a message that can be sent to server to notify of the end of the current session, whereupon the server is free to close the socket """ request = topology_api_pb2.Request() request.bye.req_id.msb, request.bye.req_id.lsb = utils.split_uuid(req_id) return request
def _bye_msg(req_id): """Msg for notifying the server of the end of session Returns a message that can be sent to server to notify of the end of the current session, whereupon the server is free to close the socket """ request = topology_api_pb2.Request() request.bye.req_id.msb, request.bye.req_id.lsb = (utils.split_uuid(req_id)) return request