def prompt_for_ssh(options): """Prompt the user to ssh to the installation environment on the s390. :param options: Anaconda command line/boot options :return: True if the prompt is printed, otherwise False """ if not blivet.arch.is_s390(): return False if not conf.target.is_hardware: return False if 'TMUX' in os.environ: return False if options.ksfile: return False if options.vnc: return False # Do some work here to get the ip addr / hostname to pass # to the user. import socket ip = network.get_first_ip_address() if not ip: stdout_log.error("No IP addresses found, cannot continue installation.") util.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) ipstr = ip name = None try: hinfo = socket.gethostbyaddr(ipstr) except socket.herror as e: stdout_log.debug("Exception caught trying to get host name of %s: %s", ipstr, e) name = socket.gethostname() else: if len(hinfo) == 3: name = hinfo[0] if ip.find(':') != -1: ipstr = "[%s]" % (ip,) if (name is not None) and (not name.startswith('localhost')) and (ipstr is not None): connxinfo = "%s (%s)" % (socket.getfqdn(name=name), ipstr,) elif ipstr is not None: connxinfo = "%s" % (ipstr,) else: connxinfo = None if connxinfo: stdout_log.info(_("Please ssh install@%s to begin the install."), connxinfo) else: stdout_log.info(_("Please ssh install@HOSTNAME to continue installation.")) return True
def initialize(self): """Here is were all the relative vars get initialized. """ # Network may be slow. Try for 5 seconds tries = 5 while tries: self.ip = network.get_first_ip_address() if self.ip: break time.sleep(1) tries -= 1 if not self.ip: return if self.ip.find(':') != -1: ipstr = "[%s]" % (self.ip,) else: ipstr = self.ip try: hinfo = socket.gethostbyaddr(self.ip) if len(hinfo) == 3: # Consider as coming from a valid DNS record only if single IP is returned if len(hinfo[2]) == 1: self.name = hinfo[0] except socket.herror as e: log.debug("Exception caught trying to get host name of %s: %s", ipstr, e) if self.name is not None and not self.name.startswith('localhost'): self.connxinfo = "%s:%s (%s:%s)" % (socket.getfqdn(name=self.name), constants.X_DISPLAY_NUMBER, ipstr, constants.X_DISPLAY_NUMBER) host = self.name elif ipstr is not None: self.connxinfo = "%s:%s" % (ipstr, constants.X_DISPLAY_NUMBER) host = ipstr else: self.connxinfo = None host = "" # figure out product info if host: self.desktop = _("%(productName)s %(productVersion)s installation " "on host %(name)s") \ % {'productName': product.productName, 'productVersion': product.productVersion, 'name': host}
def initialize(self): """Here is were all the relative vars get initialized. """ # Network may be slow. Try for 5 seconds tries = 5 while tries: self.ip = network.get_first_ip_address() if self.ip: break time.sleep(1) tries -= 1 if not self.ip: return if self.ip.find(':') != -1: ipstr = "[%s]" % (self.ip, ) else: ipstr = self.ip try: hinfo = socket.gethostbyaddr(self.ip) if len(hinfo) == 3: # Consider as coming from a valid DNS record only if single IP is returned if len(hinfo[2]) == 1: self.name = hinfo[0] except socket.herror as e: log.debug("Exception caught trying to get host name of %s: %s", ipstr, e) if self.name is not None and not self.name.startswith('localhost'): self.connxinfo = "%s:%s (%s:%s)" % (socket.getfqdn( name=self.name), constants.X_DISPLAY_NUMBER, ipstr, constants.X_DISPLAY_NUMBER) host = self.name elif ipstr is not None: self.connxinfo = "%s:%s" % (ipstr, constants.X_DISPLAY_NUMBER) host = ipstr else: self.connxinfo = None host = "" # figure out product info if host: self.desktop = _("%(productName)s %(productVersion)s installation " "on host %(name)s") \ % {'productName': product.productName, 'productVersion': product.productVersion, 'name': host}
def prompt_for_ssh(): """Prompt the user to ssh to the installation environment on the s390.""" # Do some work here to get the ip addr / hostname to pass # to the user. import socket ip = network.get_first_ip_address() if not ip: stdout_log.error( "No IP addresses found, cannot continue installation.") util.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) ipstr = ip try: hinfo = socket.gethostbyaddr(ipstr) except socket.herror as e: stdout_log.debug("Exception caught trying to get host name of %s: %s", ipstr, e) name = network.get_hostname() else: if len(hinfo) == 3: name = hinfo[0] if ip.find(':') != -1: ipstr = "[%s]" % (ip, ) if (name is not None) and (not name.startswith('localhost')) and ( ipstr is not None): connxinfo = "%s (%s)" % ( socket.getfqdn(name=name), ipstr, ) elif ipstr is not None: connxinfo = "%s" % (ipstr, ) else: connxinfo = None if connxinfo: stdout_log.info(_("Please ssh install@%s to begin the install."), connxinfo) else: stdout_log.info( _("Please ssh install@HOSTNAME to continue installation."))