コード例 #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
コード例 #2
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
コード例 #3
0
    def __init__(self, oss, def_file, events_file):
        """
        @param oss   CIOMSSimulatorServer
        @param def_file      Platform network definition file
        @param events_file   File with events to be published
        """
        CIOMSSimulator.__init__(self, def_file, events_file)
        self._oss = oss

        # for inactivity checking
        self._last_activity = time.time()
        self._inactivity_period = None
コード例 #4
0
    def __init__(self, oss, def_file, events_file):
        """
        @param oss   CIOMSSimulatorServer
        @param def_file      Platform network definition file
        @param events_file   File with events to be published
        """
        CIOMSSimulator.__init__(self, def_file, events_file)
        self._oss = oss

        # for inactivity checking
        self._last_activity = time.time()
        self._inactivity_period = None
コード例 #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)
コード例 #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)
コード例 #7
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
コード例 #8
0
    def create_instance(cls, uri=None):
        """
        Creates an CIOMSClient 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 created and returned. Otherwise, the
        argument is looked up in the OMS URI aliases file and if found the
        corresponding URI is used for the connection. Otherwise, the given
        argument (or value of the OMS environment variable) is used as given
        to try the connection with corresponding XML/RPC server.
        """

        if cls._uri_aliases is None:
            cls._load_uri_aliases()

        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:
            # try alias resolution and then create ServerProxy instance:
            uri = cls._uri_aliases.get(uri, uri)
            if log.isEnabledFor(logging.DEBUG):
                log.debug("Creating xmlrpclib.ServerProxy: uri=%s", uri)
            instance = xmlrpclib.ServerProxy(uri, allow_none=True)
            if log.isEnabledFor(logging.DEBUG):
                log.debug("Created xmlrpclib.ServerProxy: uri=%s", uri)

        return instance
コード例 #9
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)
コード例 #10
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)
コード例 #11
0
 def __init__(self, host, port, thread=False):
     """
     @param host   Hostname for the service
     @param port   Port for the service
     @param thread If True, a thread is launched to call serve_forever on
                   the server. Do not use this within a pyon-dominated
                   environment because of gevent monkey patching
                   behavior that doesn't play well with threading.Thread
                   (you'll likely see the thread blocked). By default False.
     """
     self._sim = CIOMSSimulator()
     self._server = SimpleXMLRPCServer((host, port), allow_none=True)
     self._server.register_introspection_functions()
     self._server.register_instance(self._sim, allow_dotted_names=True)
     log.info("OMS simulator xmlrpc server listening on %s:%s ..." %
              (host, port))
     if thread:
         self._check_pyon()
         runnable = Thread(target=self._server.serve_forever)
         runnable.start()
         log.info("started thread.")
     else:
         self._server.serve_forever()