def global_init(self, channel): # Create the gRPC stub. stub = sl_global_pb2.beta_create_SLGlobal_stub(channel) # Create a thread sync event. This will be used to order thread execution event = threading.Event() # The main reason we spawn a thread here, is that we dedicate a GRPC # channel to listen on Global asynchronous events/notifications. # This thread will be handling these event notifications. t = threading.Thread(target=self.global_thread, args=(stub, event)) self.threadList.append(t) t.start() # Wait for the spawned thread before proceeding event.wait() # Get the globals. Create a SLGlobalsGetMsg global_get = sl_global_pb2.SLGlobalsGetMsg() # # Make an RPC call to get global attributes # Timeout = 10 # Seconds response = stub.SLGlobalsGet(global_get, Timeout) # Check the received result from the Server if (response.ErrStatus.Status == sl_common_types_pb2.SLErrorStatus.SL_SUCCESS): logger.debug("Max VRF Name Len : %d" % (response.MaxVrfNameLength)) logger.debug("Max Iface Name Len : %d" % (response.MaxInterfaceNameLength)) logger.debug("Max Paths per Entry : %d" % (response.MaxPathsPerEntry)) logger.debug("Max Prim per Entry : %d" % (response.MaxPrimaryPathPerEntry)) logger.debug("Max Bckup per Entry : %d" % (response.MaxBackupPathPerEntry)) logger.debug("Max Labels per Entry : %d" % (response.MaxMplsLabelsPerPath)) logger.debug("Min Prim Path-id : %d" % (response.MinPrimaryPathIdNum)) logger.debug("Max Prim Path-id : %d" % (response.MaxPrimaryPathIdNum)) logger.debug("Min Bckup Path-id : %d" % (response.MinBackupPathIdNum)) logger.debug("Max Bckup Path-id : %d" % (response.MaxBackupPathIdNum)) logger.debug("Max Remote Bckup Addr: %d" % (response.MaxRemoteAddressNum)) else: logger.debug("Globals response Error 0x%x" % (response.ErrStatus.Status))
def global_get_serializer(): """Global Get Message serializer.""" serializer = sl_global_pb2.SLGlobalsGetMsg() return serializer