예제 #1
0
 def __init__(self, cls, server_cls):
     """
     Args:
         cls (class): The class whose methods we are trying to automate.
         server_cls (class): The class of the server whose methods we are testing.
     """
     self.cls = cls
     self.server_cls = server_cls
     self.logger = logging_config(module_logger.name + ".AutomaticTest",
                                  loglevel=logging.DEBUG)
예제 #2
0
    def __init__(self, tunnel, proxy_name, use_autoconnect=False, **kwargs):
        """
        Intialize a connection the Pyro server.
        Args:

        """
        self.logger = logging_config(**kwargs)
        self.proxy_name = proxy_name
        self.tunnel = tunnel
        self.server = self.tunnel.get_pyro_object(
            self.proxy_name, use_autoconnect=use_autoconnect)
        self.connected = True
예제 #3
0
    def __init__(self, ns_host='localhost',ns_port=9090,
    				msg_bus_host='localhost', msg_bus_port=0):
        """
        kwargs:
            - ns_host (str): Nameserver host (localhost)
            - ns_port (int): Nameserver port (9090)
            - msg_bus_host (str): Pyro4 host to bind messagebus to (localhost)
            - msg_bus_port (int): Pyro4 port to bind messagebus to (0, or random)

        """
        threading.Thread.__init__(self)
        self.ns_host = ns_host
        self.ns_port = ns_port
        self.msg_bus_host = msg_bus_host
        self.msg_bus_port = msg_bus_port


        self.logger = logging_config(name=__name__+".MessageBusThread")
예제 #4
0
    def __init__(self, name, obj=None, simulated=False, local=False, **kwargs):
        """
        Setup logging for the server, in addition to creating a
        lock. Subclasses of this class can interact directly with the lock,
        or through the blocking and non-blocking decorators.
        Args:
            name (str): The name of the Pyro server.
            simulated (bool): Simulation mode bool
            local (bool): Local run bool
            **kwargs: TAMS_BackEnd.util.logging_config kwargs
        """
        self._logfile = kwargs.get("logfile", "")
        self.serverlog = logging_config(**kwargs)
        self.lock = threading.Lock()
        self._simulated = simulated
        if self._simulated:
            self.serverlog.name = self.serverlog.name + ".simulator"
            self.serverlog.info("Running in simulation mode")

        self._local = local
        self._name = name
        self._running = False
        self._tunnel = None
        self._remote_ip = None
        self._remote_port = None
        self._proc = []

        self._exposed_obj = None
        if obj:
            self._exposed_obj = obj
        else:
            pass

        self.server_uri = None
        self.daemon_thread = None
        self.daemon = None
예제 #5
0
    def __init__(self,
                 remote_server_name='localhost',
                 remote_port=None,
                 remote_ns_port=50000,
                 remote_ns_host='localhost',
                 local_forwarding_port=None,
                 tunnel_username=None,
                 remote_username=None,
                 loglevel=logging.INFO,
                 **kwargs):
        """
        Create a Pyro4ObjectDiscoverer object.
        Args:
            remote_server_name (str): Name or ip of remote server.
        Keyword Args:
            remote_port (int): The remote listening port.
            remote_ns_port (int): The remote nameserver port
            remote_ns_host (str): The remote nameserver host name
            local_forwarding_port (int): The local port on which to listen;
                the local port we used for port forwarding
            tunnel_username (str): The username for the creation of a support.tunneling.Tunnel.
                This could be, for example, a login to the JPL ops gateway.
            username (str): The username to use for port forwarding. On crux, this would be 'ops'
            **kwargs: For logging_util.logging_config
        """
        self.remote_server_name = remote_server_name
        self.remote_ns_host = remote_ns_host
        self.remote_ns_port = remote_ns_port
        if not local_forwarding_port: local_forwarding_port = remote_ns_port
        self.local_forwarding_port = local_forwarding_port
        self.tunnel_username = tunnel_username
        self.remote_username = remote_username
        logger = logging.getLogger(module_logger.name + ".Pyro4Tunnel")
        self.logger = logging_config(logger=logger,
                                     loglevel=loglevel,
                                     **kwargs)
        self.processes = []

        if remote_server_name in full_name.keys():
            self.local = False
            self.logger.debug("Checking for existing Tunnel.")
            self.tunnel = Tunnel(remote_server_name, username=tunnel_username)
            self.remote_port = self.tunnel.port
            self.remote_server_ip = 'localhost'
        elif remote_server_name == 'localhost':
            self.remote_server_ip = 'localhost'
            if remote_port:
                self.local = False
                self.remote_port = remote_port
            else:
                self.local = True
        else:
            self.local = False
            self.logger.debug("Provided server name not on JPL network.")
            self.tunnel = None
            self.remote_server_ip = remote_server_name
            self.remote_port = remote_port

        if self.local:
            self.logger.debug("Local nameserver host:port: {}:{}".format(
                self.remote_ns_host, self.remote_ns_port))
            self.ns = Pyro4.locateNS(host=self.remote_ns_host,
                                     port=self.remote_ns_port)
        else:
            self.ns = self.find_nameserver(self.remote_server_ip,
                                           self.remote_ns_host,
                                           self.remote_ns_port,
                                           self.local_forwarding_port,
                                           self.remote_port,
                                           self.remote_username)

        self.uris = {}
        self.requested_objects = []
예제 #6
0
import re

import Pyro4

from support.tunneling import Tunnel
from support.process import invoke, search_response, BasicProcess
from support.logs import logging_config
from pyro3_util import full_name
from pyro4_client import AutoReconnectingProxy
full_name = full_name.copy()
try:
    full_name.pop('localhost')
except KeyError:
    pass
module_logger = logging.getLogger(__name__)
logging_config(logger=module_logger, loglevel=logging.DEBUG)


class Pyro4ObjectDiscoverer(object):
    """
    An class used to represent a set of ssh tunnels to a Pyro4 object located remotely.
    This is meant to be a replacement for Tom's support.pyro.get_device_server function.
    This does not just work for JPL tunnels, however. We can tunnel to arbitrary IP addresses
    and gain access to Pyro objects as well.

    Example Usage:
    If we want to get the URI of the APC Pyro object on crux, we would do the following:

    ```
    crux_tunnel = Pyro4ObjectDiscoverer("crux", remote_ns_host='localhost', remote_ns_port=50000,
                                        tunnel_username='******', username='******')