Beispiel #1
0
    def __init__(self, cached=False):
        # get the global config, if cached = False a new config instance will
        # be returned with the up-to-date configuration.
        global_config = glbl_cfg(cached=cached)

        # list the condemned hosts, hosts may be suffixed with `!`
        condemned_hosts = [
            get_fqdn_by_host(host.split('!')[0])
            for host in global_config.get(['suite servers', 'condemned hosts'])
        ]

        # list configured run hosts eliminating any which cannot be contacted
        # or which are condemned
        self.hosts = []
        for host in (global_config.get(['suite servers', 'run hosts'])
                     or ['localhost']):
            try:
                if get_fqdn_by_host(host) not in condemned_hosts:
                    self.hosts.append(host)
            except socket.gaierror:
                pass

        # determine the server ranking and acceptance thresholds if configured
        self.rank_method = global_config.get(
            ['suite servers', 'run host select', 'rank'])
        self.parsed_thresholds = self.parse_thresholds(
            global_config.get(
                ['suite servers', 'run host select', 'thresholds']))
Beispiel #2
0
 def test_get_fqdn_by_host_on_bad_host(self):
     """get_fqdn_by_host bad host."""
     bad_host = 'nosuchhost.nosuchdomain.org'
     try:  # Future: Replace with assertRaises context manager syntax
         get_fqdn_by_host(bad_host)
     except IOError as exc:
         self.assertEqual(exc.filename, bad_host)
         self.assertEqual(
             "[Errno -2] Name or service not known: '%s'" % bad_host,
             str(exc))
Beispiel #3
0
 def test_get_fqdn_by_host_on_bad_host(self):
     """get_fqdn_by_host bad host."""
     bad_host = 'nosuchhost.nosuchdomain.org'
     try:  # Future: Replace with assertRaises context manager syntax
         get_fqdn_by_host(bad_host)
     except IOError as exc:
         self.assertEqual(exc.filename, bad_host)
         self.assertEqual(
             "[Errno -2] Name or service not known: '%s'" % bad_host,
             str(exc))
Beispiel #4
0
    def __init__(
            self, suite, owner=None, host=None, port=None, timeout=None,
            my_uuid=None, print_uuid=False, auth=None):
        self.suite = suite
        if not owner:
            owner = get_user()
        self.owner = owner
        self.host = host
        if self.host and self.host.split('.')[0] == 'localhost':
            self.host = get_host()
        elif self.host and '.' not in self.host:  # Not IP and no domain
            self.host = get_fqdn_by_host(self.host)
        self.port = port
        self.srv_files_mgr = SuiteSrvFilesManager()
        if timeout is not None:
            timeout = float(timeout)
        self.timeout = timeout
        self.my_uuid = my_uuid or uuid4()
        if print_uuid:
            sys.stderr.write('%s\n' % self.my_uuid)

        self.prog_name = os.path.basename(sys.argv[0])
        self.auth = auth
        self.session = None
        self.comms1 = {}  # content in primary contact file
        self.comms2 = {}  # content in extra contact file, e.g. contact via ssh
Beispiel #5
0
    def __init__(self,
                 suite,
                 owner=None,
                 host=None,
                 port=None,
                 timeout=None,
                 my_uuid=None,
                 print_uuid=False,
                 comms_protocol=None,
                 auth=None):
        self.suite = suite
        if not owner:
            owner = get_user()
        self.owner = owner
        self.host = host
        if self.host and self.host.split('.')[0] == 'localhost':
            self.host = get_host()
        elif self.host and '.' not in self.host:  # Not IP and no domain
            self.host = get_fqdn_by_host(self.host)
        self.port = port
        self.srv_files_mgr = SuiteSrvFilesManager()
        self.comms_protocol = comms_protocol
        if timeout is not None:
            timeout = float(timeout)
        self.timeout = timeout
        self.my_uuid = my_uuid or uuid4()
        if print_uuid:
            print >> sys.stderr, '%s' % self.my_uuid

        self.prog_name = os.path.basename(sys.argv[0])
        self.auth = auth
Beispiel #6
0
    def __init__(
            self, suite, owner=None, host=None, port=None, timeout=None,
            my_uuid=None, print_uuid=False, auth=None):
        self.suite = suite
        if not owner:
            owner = get_user()
        self.owner = owner
        self.host = host
        if self.host and self.host.split('.')[0] == 'localhost':
            self.host = get_host()
        elif self.host and '.' not in self.host:  # Not IP and no domain
            self.host = get_fqdn_by_host(self.host)
        self.port = port
        self.srv_files_mgr = SuiteSrvFilesManager()
        if timeout is not None:
            timeout = float(timeout)
        self.timeout = timeout
        self.my_uuid = my_uuid or uuid4()
        if print_uuid:
            sys.stderr.write('%s\n' % self.my_uuid)

        self.prog_name = os.path.basename(sys.argv[0])
        self.auth = auth
        self.session = None
        self.comms1 = {}  # content in primary contact file
        self.comms2 = {}  # content in extra contact file, e.g. contact via ssh
Beispiel #7
0
    def get_location(cls, suite, owner, host):
        """Extract host and port from a suite's contact file."""
        try:
            contact = SuiteSrvFilesManager().load_contact_file(
                suite, owner, host)
        except SuiteServiceFileError:
            sys.exit(cls.NOT_RUNNING % suite)
            # monkey-patch the error message to make it more informative.
            # exc.args = (cls.NOT_RUNNING % suite,)
            # raise

        if not host:
            host = contact[SuiteSrvFilesManager.KEY_HOST]
        host = get_fqdn_by_host(host)

        port = int(contact[SuiteSrvFilesManager.KEY_PORT])
        return host, port
Beispiel #8
0
    def get_location(cls, suite, owner, host):
        """Extract host and port from a suite's contact file."""
        try:
            contact = SuiteSrvFilesManager().load_contact_file(
                suite, owner, host)
        except SuiteServiceFileError:
            sys.exit(cls.NOT_RUNNING % suite)
            # monkey-patch the error message to make it more informative.
            # exc.args = (cls.NOT_RUNNING % suite,)
            # raise

        if not host:
            host = contact[SuiteSrvFilesManager.KEY_HOST]
        host = get_fqdn_by_host(host)

        port = int(contact[SuiteSrvFilesManager.KEY_PORT])
        return host, port