Exemple #1
0
    def __init__(self, oss):
        """
        @param oss   CIOMSSimulatorServer
        """
        CIOMSSimulator.__init__(self)
        self._oss = oss

        # for inactivity checking
        self._last_activity = time.time()
        self._inactivity_period = None
Exemple #2
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)
Exemple #3
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)
Exemple #4
0
    def create_instance(cls, uri=None):
        """
        Creates an CIOMSClient instance.
        Do not forget to call destroy_instance with the returned object when
        you are done with the instance.

        @param uri URI to connect to the RSN OMS server or simulator.
        If None (the default) the value of the OMS environment variable is used
        as argument. If not defined or if the resulting argument is "embsimulator"
        then an CIOMSSimulator instance is directly created and returned.
        Otherwise, the given argument (or value of the OMS environment variable)
        is used as given to try the connection with the corresponding XML/RPC
        server resolvable by that URI.
        """

        if uri is None:
            uri = os.getenv('OMS', 'embsimulator')

        if "embsimulator" == uri:
            # "embedded" simulator, so instantiate CIOMSSimulator here:
            log.debug("Using embedded CIOMSSimulator instance")
            instance = CIOMSSimulator()
        else:
            log.debug("Creating xmlrpclib.ServerProxy: uri=%s", uri)
            instance = xmlrpclib.ServerProxy(uri, allow_none=True)
            log.debug("Created xmlrpclib.ServerProxy: uri=%s", uri)

        cls._inst_count += 1
        log.debug("create_instance: _inst_count = %d", cls._inst_count)
        return instance
Exemple #5
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)
Exemple #6
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)