def produce_ABClusterHost(hostname='localhost', key_based=None, user=None, pwd=None, key_file=None): """Factory method which returns RemoteClusterHost or LocalClusterHost depending on the value of hostname..""" _logger.debug('CHS--> Produce ABC, hostname passed %s', hostname) shn = socket.gethostbyname_ex(socket.gethostname()) #Say ('host.dom.comp.com', [], ['10.17.16.24']) _logger.debug('CHS--> Produce ABC socket host name is %s.', shn) if hostname == 'localhost' or hostname == '127.0.0.1' or hostname == shn[0]: _logger.debug('CHS--> Host is local.') return LocalClusterHost(hostname) for x in range(len(shn[2])): if hostname == shn[2][x]: return LocalClusterHost(hostname) # Sanitize input: if not (user and user.strip()): user = None if not (pwd and pwd.strip()): pwd = None else: if pwd.startswith('**'): pwd = None if not (key_file and key_file.strip()): key_file = None import remote_clusterhost _logger.debug('CHS--> Producing remote ABC.') return remote_clusterhost.RemoteClusterHost(hostname, key_based, user, pwd, key_file)
def produce_ABClusterHost(hostname='localhost', key_based=None, user=None, pwd=None, key_file=None): """Factory method which returns RemoteClusterHost or LocalClusterHost depending on the value of hostname..""" if hostname == 'localhost' or hostname == '127.0.0.1' or hostname == socket.gethostname( ): return LocalClusterHost(hostname) hostname_fqdn = socket.getfqdn(hostname) if hostname_fqdn == socket.getfqdn( 'localhost') or hostname_fqdn == socket.getfqdn( socket.gethostname()): return LocalClusterHost(hostname) # Sanitize input: if not (user and user.strip()): user = None if not (pwd and pwd.strip()): pwd = None else: if pwd.startswith('**'): pwd = None if not (key_file and key_file.strip()): key_file = None import remote_clusterhost return remote_clusterhost.RemoteClusterHost(hostname, key_based, user, pwd, key_file)
def produce_ABClusterHost(hostname='localhost', user=None, pwd=None): """Factory method which returns RemoteClusterHost or LocalClusterHost depending on the value of hostname..""" if hostname == 'localhost' or hostname == '127.0.0.1' or hostname == socket.gethostname(): return LocalClusterHost(hostname) hostname_fqdn = socket.getfqdn(hostname) if hostname_fqdn == socket.getfqdn('localhost') or hostname_fqdn == socket.getfqdn(socket.gethostname()): return LocalClusterHost(hostname) import remote_clusterhost return remote_clusterhost.RemoteClusterHost(hostname, user, pwd)
def produce_ABClusterHost(hostname='localhost', key_based=None, user=None, pwd=None, key_file=None): """Factory method which returns RemoteClusterHost or LocalClusterHost depending on the value of hostname..""" if hostname == 'localhost' or hostname == '127.0.0.1' or hostname == socket.gethostname( ): _logger.warning('Host is local (1).') return LocalClusterHost(hostname) hostname_fqdn = socket.getfqdn(hostname) if hostname_fqdn == socket.getfqdn( 'localhost') or hostname_fqdn == socket.getfqdn( socket.gethostname()): _logger.warning('Host is local (2).') return LocalClusterHost(hostname) # Check if proper IP address is provided for localhost: ips = socket.gethostbyname_ex(socket.gethostname())[2] for ipadr in ips: if ipadr == hostname: _logger.warning('Host is local (3).') return LocalClusterHost(hostname) # Sanitize input: if not (user and user.strip()): user = None if not (pwd and pwd.strip()): pwd = None else: if pwd.startswith('**'): pwd = None if not (key_file and key_file.strip()): key_file = None import remote_clusterhost return remote_clusterhost.RemoteClusterHost(hostname, key_based, user, pwd, key_file)