def disconnect(self): """ Stops event dispatch and destroys the CIOMSClient instance. """ self._stop_event_dispatch() CIOMSClientFactory.destroy_instance(self._rsn_oms) self._rsn_oms = None log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.RR = ResourceRegistryServiceClient(node=self.container.node) self.IMS = InstrumentManagementServiceClient(node=self.container.node) self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node) self.DP = DataProductManagementServiceClient(node=self.container.node) self.PSC = PubsubManagementServiceClient(node=self.container.node) self.PDC = ProcessDispatcherServiceClient(node=self.container.node) self.DSC = DatasetManagementServiceClient() self.IDS = IdentityManagementServiceClient(node=self.container.node) self.RR2 = EnhancedResourceRegistryClient(self.RR) self.org_id = self.RR2.create(any_old(RT.Org)) log.debug("Org created: %s", self.org_id) # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) CIOMSClientFactory.destroy_instance(rsn_oms) # get serialized version for the configuration: self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition) log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser) # set attributes for the platforms: self._platform_attributes = {} for platform_id in self._network_definition.pnodes: pnode = self._network_definition.pnodes[platform_id] dic = dict((attr.attr_id, attr.defn) for attr in pnode.attrs.itervalues()) self._platform_attributes[platform_id] = dic log.trace("_platform_attributes: %s", self._platform_attributes) # set ports for the platforms: self._platform_ports = {} for platform_id in self._network_definition.pnodes: pnode = self._network_definition.pnodes[platform_id] dic = {} for port_id, port in pnode.ports.iteritems(): dic[port_id] = dict(port_id=port_id, network=port.network) self._platform_ports[platform_id] = dic log.trace("_platform_ports: %s", self._platform_attributes) self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber()
def setUp(self): # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG["oms_uri"]) network_definition = RsnOmsUtil.build_network_definition(rsn_oms) CIOMSClientFactory.destroy_instance(rsn_oms) if log.isEnabledFor(logging.DEBUG): network_definition_ser = NetworkUtil.serialize_network_definition(network_definition) log.debug("NetworkDefinition serialization:\n%s", network_definition_ser) platform_id = self.PLATFORM_ID pnode = network_definition.pnodes[platform_id] self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.RR = ResourceRegistryServiceClient(node=self.container.node) self.IMS = InstrumentManagementServiceClient(node=self.container.node) self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node) self.DP = DataProductManagementServiceClient(node=self.container.node) self.PSC = PubsubManagementServiceClient(node=self.container.node) self.PDC = ProcessDispatcherServiceClient(node=self.container.node) self.DSC = DatasetManagementServiceClient() self.IDS = IdentityManagementServiceClient(node=self.container.node) self.RR2 = EnhancedResourceRegistryClient(self.RR) # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) # get serialized version for the configuration: self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition) if log.isEnabledFor(logging.TRACE): log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser) self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber()
def connect(self, recursion=None): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ # create CIOMSClient: oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self.ping() # start event dispatch: self._start_event_dispatch() # TODO(OOIION-1495) review the following. Commented out for the moment. # 2014-06-05: The pending review in terms of ports is still relevant in # what follows from the original comment here, but note that the # connect_instrument and disconnect_instrument operations have been # removed from the CI-OMS interface. # Note, per the CI-OMS spec ports need to be turned OFF to then proceed # with connecting instruments. So we need to determine whether we # want to turn all ports ON in this "connect driver" operation, # and then add the logic to turn a port OFF before connecting # instruments, and then ON again; or, just do the OFF/ON logic in the # connect_instrument and disconnect_instrument operations, # but not here. """
def disconnect(self, recursion=None): """ Stops event dispatch and destroys the CIOMSClient instance. """ self._stop_event_dispatch() # power off all ports with connected devices if recursion: for port in self._active_ports: log.debug('disconnect power port: %s', port) self.turn_off_port(port) CIOMSClientFactory.destroy_instance(self._rsn_oms) self._rsn_oms = None log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
def _register_oms_listener(self): #load the paramaters and the param dicts necesssary for the VEL3D log.debug( "---------- connect_to_oms ---------- ") log.debug("oms_uri = %s", OMS_URI) self.oms = CIOMSClientFactory.create_instance(OMS_URI) #buddha url url = "http://10.22.88.168:5000/ion-service/oms_event" log.info("test_oms_events_receive:setup http url %s", url) result = self.oms.event.register_event_listener(url) log.debug("_register_oms_listener register_event_listener result %s", result) #------------------------------------------------------------------------------------- # Set up the subscriber to catch the alert event #------------------------------------------------------------------------------------- def callback_for_alert(event, *args, **kwargs): log.debug("caught an OMSDeviceStatusEvent: %s", event) self.catch_alert.put(event) self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent', callback=callback_for_alert) self.event_subscriber.start() self.addCleanup(self.event_subscriber.stop) result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'}) log.debug("_register_oms_listener generate_test_event result %s", result)
def _launch_simulator(self): if self._oms_uri == "launchsimulator": self.addCleanup(CIOMSClientFactory.stop_launched_simulator) log.debug("launch_simulator inactivity: %s", self._inactivity_period) return CIOMSClientFactory.launch_simulator(self._inactivity_period) else: return self._oms_uri
def launch(self): """ Launches the simulator process as indicated by _COMMAND. @return (rsn_oms, uri) A pair with the CIOMSSimulator instance and the associated URI to establish connection with it. """ log.debug("[OMSim] Launching: %s", _COMMAND) self._process = self._spawn(_COMMAND) if not self._process or not self.poll(): msg = "[OMSim] Failed to launch simulator: %s" % _COMMAND log.error(msg) raise Exception(msg) log.debug("[OMSim] process started, pid: %s", self.getpid()) # give it some time to start up sleep(5) # get URI: uri = None with open("logs/rsn_oms_simulator.yml", buffering=1) as f: # we expect one of the first few lines to be of the form: # rsn_oms_simulator_uri=xxxx # where xxxx is the uri -- see oms_simulator_server. while uri is None: line = f.readline() if line.index("rsn_oms_simulator_uri=") == 0: uri = line[len("rsn_oms_simulator_uri="):].strip() self._rsn_oms = CIOMSClientFactory.create_instance(uri) return self._rsn_oms, uri
def connect(self, recursion=None): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ # create CIOMSClient: oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self.ping() # start event dispatch: self._start_event_dispatch() # TODO(OOIION-1495) review the following. Commented out for the moment. # Note, per the CI-OMS spec ports need to be turned OFF to then proceed # with connecting instruments. So we need to determine whether we # want to turn all ports ON in this "connect driver" operation, # and then add the logic to turn a port OFF before connecting # instruments, and then ON again; or, just do the OFF/ON logic in the # connect_instrument and disconnect_instrument operations, # but not here. """
def test_oms_events_receive(self): log.debug("oms_uri = %s", OMS_URI) self.oms = CIOMSClientFactory.create_instance(OMS_URI) #CI url #url = "http://128.54.26.120:5000/ion-service/oms_event" #buddha url url = "http://128.54.29.48:5000/ion-service/oms_event" log.info("test_oms_events_receive:setup http url %s", url) result = self.oms.event.register_event_listener(url) log.info("test_oms_events_receive:setup register_event_listener result %s", result) #------------------------------------------------------------------------------------- # Set up the subscriber to catch the alert event #------------------------------------------------------------------------------------- def callback_for_alert(event, *args, **kwargs): log.debug("caught an OMSDeviceStatusEvent: %s", event) self.catch_alert.put(event) self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent', callback=callback_for_alert) self.event_subscriber.start() self.addCleanup(self.event_subscriber.stop) #test the listener result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id1', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'}) log.info("test_oms_events_receive:setup generate_test_event result %s", result) result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id2', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'}) log.info("test_oms_events_receive:setup generate_test_event result %s", result) result = self.oms.event.generate_test_event({'platform_id': 'fake_platform_id3', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power'}) log.info("test_oms_events_receive:setup generate_test_event result %s", result) oms_event_counter = 0 runtime = 0 starttime = time.time() caught_events = [] #catch several events to get some samples from OMS while oms_event_counter < 10 and runtime < 60 : a = self.catch_alert.get(timeout=60) caught_events.append(a) oms_event_counter += 1 runtime = time.time() - starttime result = self.oms.event.unregister_event_listener(url) log.debug("unregister_event_listener result: %s", result) self.assertTrue(oms_event_counter > 0)
def setUp(self): self._start_container() self._pp = pprint.PrettyPrinter() log.debug("oms_uri = %s", OMS_URI) self.oms = CIOMSClientFactory.create_instance(OMS_URI) self._get_platform_attributes() url = OmsTestMixin.start_http_server() log.info("TestPlatformInstrument:setup http url %s", url) result = self.oms.event.register_event_listener(url) log.info( "TestPlatformInstrument:setup register_event_listener result %s", result) # response = self.oms.port.get_platform_ports('LPJBox_CI_Ben_Hall') # log.info("TestPlatformInstrument:setup get_platform_ports %s", response) self.container.start_rel_from_url('res/deploy/r2deploy.yml') # Now create client to DataProductManagementService self.rrclient = ResourceRegistryServiceClient(node=self.container.node) self.pubsubclient = PubsubManagementServiceClient( node=self.container.node) self.imsclient = InstrumentManagementServiceClient( node=self.container.node) self.datasetclient = DatasetManagementServiceClient( node=self.container.node) self.processdispatchclient = ProcessDispatcherServiceClient( node=self.container.node) self.dpclient = DataProductManagementServiceClient( node=self.container.node) self.damsclient = DataAcquisitionManagementServiceClient( node=self.container.node) self.dataset_management = DatasetManagementServiceClient() self.RR2 = EnhancedResourceRegistryClient(self.rrclient) self.org_id = self.RR2.create(any_old(RT.Org)) log.debug("Org created: %s", self.org_id) # see _set_receive_timeout self._receive_timeout = 177 self.instrument_device = '' self.platform_device = '' self.platform_agent_instance_id = '' self._pa_client = '' def done(): CIOMSClientFactory.destroy_instance(self.oms) event_notifications = OmsTestMixin.stop_http_server() log.info("event_notifications = %s" % str(event_notifications)) self.addCleanup(done)
def setUp(self): DVR_CONFIG['oms_uri'] = self._dispatch_simulator(oms_uri) log.debug("DVR_CONFIG['oms_uri'] = %s", DVR_CONFIG['oms_uri']) # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) network_definition = RsnOmsUtil.build_network_definition(rsn_oms) CIOMSClientFactory.destroy_instance(rsn_oms) if log.isEnabledFor(logging.DEBUG): network_definition_ser = NetworkUtil.serialize_network_definition( network_definition) log.debug("NetworkDefinition serialization:\n%s", network_definition_ser) platform_id = self.PLATFORM_ID pnode = network_definition.pnodes[platform_id] self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
def setUp(self): oms_uri = os.getenv('OMS', "launchsimulator") oms_uri = self._dispatch_simulator(oms_uri) log.debug("oms_uri = %s", oms_uri) self.oms = CIOMSClientFactory.create_instance(oms_uri) def done(): CIOMSClientFactory.destroy_instance(self.oms) self.addCleanup(done)
def disconnect(self, recursion=None): """ Stops event dispatch and destroys the CIOMSClient instance. """ self._stop_event_dispatch() # TODO(OOIION-1495) review the following. Only change is the use # of self._pnode.ports instead of self._active_ports, # while we address the "active ports" concept mentioned above. # BTW, is it OK to turn off ports in this "disconnect driver" operation? # power off all ports with connected devices if recursion: for port in self._pnode.ports: log.debug('disconnect power port: %s', port) self.turn_off_port(port) CIOMSClientFactory.destroy_instance(self._rsn_oms) self._rsn_oms = None log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
def setUp(self): oms_uri = os.getenv('OMS', "launchsimulator") oms_uri = self._dispatch_simulator(oms_uri) log.debug("oms_uri = %s", oms_uri) self.oms = CIOMSClientFactory.create_instance(oms_uri) OmsTestMixin.start_http_server() def done(): CIOMSClientFactory.destroy_instance(self.oms) event_notifications = OmsTestMixin.stop_http_server() log.info("event_notifications = %s" % str(event_notifications)) self.addCleanup(done)
def connect(self): """ Creates an CIOMSClient instance and does a ping. """ oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) self.ping()
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.rrclient = ResourceRegistryServiceClient(node=self.container.node) self.omsclient = ObservatoryManagementServiceClient( node=self.container.node) self.imsclient = InstrumentManagementServiceClient( node=self.container.node) self.damsclient = DataAcquisitionManagementServiceClient( node=self.container.node) self.dpclient = DataProductManagementServiceClient( node=self.container.node) self.pubsubcli = PubsubManagementServiceClient( node=self.container.node) self.processdispatchclient = ProcessDispatcherServiceClient( node=self.container.node) self.dataprocessclient = DataProcessManagementServiceClient( node=self.container.node) self.dataset_management = DatasetManagementServiceClient() # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) # get serialized version for the configuration: self._network_definition_ser = NetworkUtil.serialize_network_definition( self._network_definition) if log.isEnabledFor(logging.DEBUG): log.debug("NetworkDefinition serialization:\n%s", self._network_definition_ser) self.platformModel_id = None self.all_platforms = {} self.agent_streamconfig_map = {} self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber() self._set_up_DataProduct_obj() self._set_up_PlatformModel_obj()
def _simulator_disable(self): """ Disables the simulator to cause the effect of having lost the connection. """ if self._oms_uri == "launchsimulator": rsn_oms = CIOMSClientFactory.get_rsn_oms_for_launched_simulator() self.assertIsNotNone(rsn_oms, "the simulator must have been " "launched and be running") rsn_oms.x_disable() elif self._oms_uri == "embsimulator": CIOMSSimulator.x_disable() else: self.fail("_simulator_disable does not work for: %s" % self._oms_uri)
def _simulator_enable(self): """ Reenables the simulator. """ if self._oms_uri == "launchsimulator": rsn_oms = CIOMSClientFactory.get_rsn_oms_for_launched_simulator() self.assertIsNotNone(rsn_oms, "the simulator must have been " "launched and be running") rsn_oms.x_enable() elif self._oms_uri == "embsimulator": CIOMSSimulator.x_enable() else: self.fail("_simulator_enable does not work for: %s" % self._oms_uri)
def setUp(self): self._start_container() self._pp = pprint.PrettyPrinter() log.debug("oms_uri = %s", OMS_URI) self.oms = CIOMSClientFactory.create_instance(OMS_URI) self._get_platform_attributes() url = OmsTestMixin.start_http_server() log.info("TestPlatformInstrument:setup http url %s", url) result = self.oms.event.register_event_listener(url) log.info("TestPlatformInstrument:setup register_event_listener result %s", result) # response = self.oms.port.get_platform_ports('LPJBox_CI_Ben_Hall') # log.info("TestPlatformInstrument:setup get_platform_ports %s", response) self.container.start_rel_from_url('res/deploy/r2deploy.yml') # Now create client to DataProductManagementService self.rrclient = ResourceRegistryServiceClient(node=self.container.node) self.pubsubclient = PubsubManagementServiceClient(node=self.container.node) self.imsclient = InstrumentManagementServiceClient(node=self.container.node) self.datasetclient = DatasetManagementServiceClient(node=self.container.node) self.processdispatchclient = ProcessDispatcherServiceClient(node=self.container.node) self.dpclient = DataProductManagementServiceClient(node=self.container.node) self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node) self.dataset_management = DatasetManagementServiceClient() self.RR2 = EnhancedResourceRegistryClient(self.rrclient) self.org_id = self.RR2.create(any_old(RT.Org)) log.debug("Org created: %s", self.org_id) # see _set_receive_timeout self._receive_timeout = 177 self.instrument_device = '' self.platform_device = '' self.platform_agent_instance_id = '' self._pa_client = '' def done(): CIOMSClientFactory.destroy_instance(self.oms) event_notifications = OmsTestMixin.stop_http_server() log.info("event_notifications = %s" % str(event_notifications)) self.addCleanup(done)
def connect(self): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ # create CIOMSClient: oms_uri = self._driver_config["oms_uri"] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self.ping() # start event dispatch: self._start_event_dispatch()
def setUpClass(cls): HelperTestMixin.setUpClass() # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG["oms_uri"]) network_definition = RsnOmsUtil.build_network_definition(rsn_oms) network_definition_ser = NetworkUtil.serialize_network_definition(network_definition) if log.isEnabledFor(logging.DEBUG): log.debug("NetworkDefinition serialization:\n%s", network_definition_ser) cls.PLATFORM_CONFIG = { "platform_id": cls.PLATFORM_ID, "driver_config": DVR_CONFIG, "network_definition": network_definition_ser, } NetworkUtil._gen_open_diagram(network_definition.pnodes[cls.PLATFORM_ID])
def _simulator_disable(self): """ Disables the simulator to cause the effect of having lost the connection. """ if self._oms_uri == "launchsimulator": rsn_oms = CIOMSClientFactory.get_rsn_oms_for_launched_simulator() self.assertIsNotNone( rsn_oms, "the simulator must have been " "launched and be running") rsn_oms.x_disable() elif self._oms_uri == "embsimulator": CIOMSSimulator.x_disable() else: self.fail("_simulator_disable does not work for: %s" % self._oms_uri)
def _simulator_enable(self): """ Reenables the simulator. """ if self._oms_uri == "launchsimulator": rsn_oms = CIOMSClientFactory.get_rsn_oms_for_launched_simulator() self.assertIsNotNone( rsn_oms, "the simulator must have been " "launched and be running") rsn_oms.x_enable() elif self._oms_uri == "embsimulator": CIOMSSimulator.x_enable() else: self.fail("_simulator_enable does not work for: %s" % self._oms_uri)
def connect(self): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ # create CIOMSClient: oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self.ping() # start event dispatch: self._start_event_dispatch()
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.rrclient = ResourceRegistryServiceClient(node=self.container.node) self.omsclient = ObservatoryManagementServiceClient(node=self.container.node) self.imsclient = InstrumentManagementServiceClient(node=self.container.node) self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node) self.dpclient = DataProductManagementServiceClient(node=self.container.node) self.pubsubcli = PubsubManagementServiceClient(node=self.container.node) self.processdispatchclient = ProcessDispatcherServiceClient(node=self.container.node) self.dataprocessclient = DataProcessManagementServiceClient(node=self.container.node) self.dataset_management = DatasetManagementServiceClient() # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) # get serialized version for the configuration: self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition) if log.isEnabledFor(logging.DEBUG): log.debug("NetworkDefinition serialization:\n%s", self._network_definition_ser) self.platformModel_id = None self.all_platforms = {} self.agent_streamconfig_map = {} self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber() self._set_up_DataProduct_obj() self._set_up_PlatformModel_obj()
def setUpClass(cls): HelperTestMixin.setUpClass() # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) network_definition = RsnOmsUtil.build_network_definition(rsn_oms) network_definition_ser = NetworkUtil.serialize_network_definition( network_definition) if log.isEnabledFor(logging.DEBUG): log.debug("NetworkDefinition serialization:\n%s", network_definition_ser) cls.PLATFORM_CONFIG = { 'platform_id': cls.PLATFORM_ID, 'driver_config': DVR_CONFIG, 'network_definition': network_definition_ser } NetworkUtil._gen_open_diagram( network_definition.pnodes[cls.PLATFORM_ID])
def _register_oms_listener(self): #load the paramaters and the param dicts necesssary for the VEL3D log.debug("---------- connect_to_oms ---------- ") log.debug("oms_uri = %s", OMS_URI) self.oms = CIOMSClientFactory.create_instance(OMS_URI) #buddha url url = "http://10.22.88.168:5000/ion-service/oms_event" log.info("test_oms_events_receive:setup http url %s", url) result = self.oms.event.register_event_listener(url) log.debug("_register_oms_listener register_event_listener result %s", result) #------------------------------------------------------------------------------------- # Set up the subscriber to catch the alert event #------------------------------------------------------------------------------------- def callback_for_alert(event, *args, **kwargs): log.debug("caught an OMSDeviceStatusEvent: %s", event) self.catch_alert.put(event) self.event_subscriber = EventSubscriber( event_type='OMSDeviceStatusEvent', callback=callback_for_alert) self.event_subscriber.start() self.addCleanup(self.event_subscriber.stop) result = self.oms.event.generate_test_event({ 'platform_id': 'fake_platform_id', 'message': "fake event triggered from CI using OMS' generate_test_event", 'severity': '3', 'group ': 'power' }) log.debug("_register_oms_listener generate_test_event result %s", result)
def connect(self, recursion=None): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ # create CIOMSClient: oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self.ping() # start event dispatch: self._start_event_dispatch() # power all ports with connected devices if recursion: for port in self._active_ports: log.debug('connect power port: %s', port) self.turn_on_port(port)
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.RR = ResourceRegistryServiceClient(node=self.container.node) self.IMS = InstrumentManagementServiceClient(node=self.container.node) self.DAMS = DataAcquisitionManagementServiceClient( node=self.container.node) self.DP = DataProductManagementServiceClient(node=self.container.node) self.PSC = PubsubManagementServiceClient(node=self.container.node) self.PDC = ProcessDispatcherServiceClient(node=self.container.node) self.DSC = DatasetManagementServiceClient() self.IDS = IdentityManagementServiceClient(node=self.container.node) self.RR2 = EnhancedResourceRegistryClient(self.RR) # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) # get serialized version for the configuration: self._network_definition_ser = NetworkUtil.serialize_network_definition( self._network_definition) if log.isEnabledFor(logging.TRACE): log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser) self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber()
def tearDownClass(cls): CIOMSClientFactory.destroy_instance(cls.oms) event_notifications = OmsTestMixin.stop_http_server() log.info("event_notifications = %s" % str(event_notifications))
def setUpClass(cls): OmsTestMixin.setUpClass() cls.oms = CIOMSClientFactory.create_instance() OmsTestMixin.start_http_server()
def tearDownClass(cls): CIOMSClientFactory.destroy_instance(cls.oms)
def done(): CIOMSClientFactory.destroy_instance(self.oms)
def setUp(self): # Note that CIOMSClientFactory will create an "embedded" RSN OMS # simulator object by default. self._rsn_oms = CIOMSClientFactory.create_instance()
def done(): CIOMSClientFactory.destroy_instance(self.oms) event_notifications = OmsTestMixin.stop_http_server() log.info("event_notifications = %s" % str(event_notifications))
def tearDown(self): CIOMSClientFactory.destroy_instance(self._rsn_oms)
try: dot_cmd = 'dot -Tpng %s.dot -o %s.png' % (name,name) open_cmd = 'open %s.png' % name import subprocess subprocess.call(dot_cmd.split()) subprocess.call(open_cmd.split()) except Exception, e: print "error generating diagrams: %s" % str(e) uri = os.getenv('OMS', "http://*****:*****@10.180.80.10:9021/") ##### import re if re.search('simulator', uri): from ion.agents.platform.rsn.oms_client_factory import CIOMSClientFactory oms = CIOMSClientFactory.create_instance(uri) print "ping() = %s" % oms.ping() map = oms.get_platform_map() print "get_platform_map() = %s" % map pnodes = NetworkUtil.create_node_network(map) if not '' in pnodes: print "platform map does not include '' to indicate root platforms." else: dummy_root = pnodes[''] gen_diagrams('sim_topology', dummy_root) sys.exit() ##### proxy = xmlrpclib.ServerProxy(uri)
def setUpClass(cls): OmsTestMixin.setUpClass() cls.oms = CIOMSClientFactory.create_instance()
def setUp(self): self._start_container() self.container.start_rel_from_url('res/deploy/r2deploy.yml') self.RR = ResourceRegistryServiceClient(node=self.container.node) self.IMS = InstrumentManagementServiceClient(node=self.container.node) self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node) self.DP = DataProductManagementServiceClient(node=self.container.node) self.PSC = PubsubManagementServiceClient(node=self.container.node) self.PDC = ProcessDispatcherServiceClient(node=self.container.node) self.DSC = DatasetManagementServiceClient() self.IDS = IdentityManagementServiceClient(node=self.container.node) self.RR2 = EnhancedResourceRegistryClient(self.RR) self.org_id = self.RR2.create(any_old(RT.Org)) log.debug("Org created: %s", self.org_id) # Create InstrumentModel # TODO create multiple models as needed; for the moment assuming all # used instruments are the same model here. instModel_obj = IonObject(RT.InstrumentModel, name='SBE37IMModel', description="SBE37IMModel") self.instModel_id = self.IMS.create_instrument_model(instModel_obj) log.debug('new InstrumentModel id = %s ', self.instModel_id) # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri']) self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms) CIOMSClientFactory.destroy_instance(rsn_oms) if log.isEnabledFor(logging.TRACE): # show serialized version for the network definition: network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition) log.trace("NetworkDefinition serialization:\n%s", network_definition_ser) # set attributes for the platforms: self._platform_attributes = {} for platform_id in self._network_definition.pnodes: pnode = self._network_definition.pnodes[platform_id] dic = dict((attr.attr_id, attr.defn) for attr in pnode.attrs.itervalues()) self._platform_attributes[platform_id] = dic log.trace("_platform_attributes: %s", self._platform_attributes) # set ports for the platforms: self._platform_ports = {} for platform_id in self._network_definition.pnodes: pnode = self._network_definition.pnodes[platform_id] dic = {} for port_id, port in pnode.ports.iteritems(): dic[port_id] = dict(port_id=port_id, network=port.network) self._platform_ports[platform_id] = dic log.trace("_platform_ports: %s", self._platform_attributes) self._async_data_result = AsyncResult() self._data_subscribers = [] self._samples_received = [] self.addCleanup(self._stop_data_subscribers) self._async_event_result = AsyncResult() self._event_subscribers = [] self._events_received = [] self.addCleanup(self._stop_event_subscribers) self._start_event_subscriber(sub_type="platform_event") # instruments that have been set up: instr_key: i_obj self._setup_instruments = {}