def _disconnect(self, recursion=None):
        CIOMSClientFactory.destroy_instance(self._rsn_oms)
        self._rsn_oms = None
        log.debug("%r: CIOMSClient instance destroyed", self._platform_id)

        self._delete_scheduler()
        self._scheduler = None
示例#2
0
    def _disconnect(self, recursion=None):
        CIOMSClientFactory.destroy_instance(self._rsn_oms)
        self._rsn_oms = None
        log.debug("%r: CIOMSClient instance destroyed", self._platform_id)

        self._delete_scheduler()
        self._scheduler = None
示例#3
0
    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'])
        CIOMSClientFactory.destroy_instance(rsn_oms)

        self._plat_driver = RSNPlatformDriver(self.evt_recv)
        self._configure()
        self._connect()
    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'])
        CIOMSClientFactory.destroy_instance(rsn_oms)

        self._plat_driver = RSNPlatformDriver(self.evt_recv)
        self._configure()
        self._connect()
    def _disconnect(self, recursion=None):
        """
        Stops event dispatch and destroys the CIOMSClient instance.
        """
        self._stop_event_dispatch()
 #       self.event_subscriber.stop()
#        self.event_subscriber=None
  

        CIOMSClientFactory.destroy_instance(self._rsn_oms)
        self._rsn_oms = None
        log.debug("%r: CIOMSClient instance destroyed", self._platform_id)
        
        self._delete_scheduler();
        self._scheduler = None
    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 - commented out
        # self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent',
        #     callback=self.callback_for_alert)
        #
        # self.event_subscriber.start()

        # 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 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
示例#8
0
 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
示例#9
0
    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
示例#10
0
    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 - commented out
        # self.event_subscriber = EventSubscriber(event_type='OMSDeviceStatusEvent',
        #     callback=self.callback_for_alert)
        #
        # self.event_subscriber.start()

        # 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 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)
示例#12
0
 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
示例#13
0
    def _disconnect(self, recursion=None):
        """
        Stops event dispatch and destroys the CIOMSClient instance.
        """
        self._stop_event_dispatch()
        self.event_subscriber.stop()
        self.event_subscriber=None
        # 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.
        # Also, it is probably OK to turn off all ports in this "disconnect
        # driver" operation.fe

        # 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)
示例#14
0
    def _disconnect(self, recursion=None):
        """
        Stops event dispatch and destroys the CIOMSClient instance.
        """
        self._stop_event_dispatch()
        self.event_subscriber.stop()
        self.event_subscriber = None
        # 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.
        # Also, it is probably OK to turn off all ports in this "disconnect
        # driver" operation.fe

        # 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 _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()
示例#16
0
    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, 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()
示例#18
0
    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)
示例#19
0
    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)
示例#20
0
    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, recursion=None):
        """
        Creates an CIOMSClient instance, does a ping to verify connection,
        and starts event dispatch.
        """
        log.info("%r: _connect...", self._platform_id)

        # 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()
        self._build_scheduler()  # then start calling it every X seconds
    def _connect(self, recursion=None):
        """
        Creates an CIOMSClient instance, does a ping to verify connection,
        and starts event dispatch.
        """
        log.info("%r: _connect...", self._platform_id)

        # 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()
        self._build_scheduler()  # then start calling it every X seconds