Exemple #1
0
    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.getFirstRealIP()
            if self.ip:
                break
            time.sleep(1)
            tries -= 1

        if not self.ip:
            return

        ipstr = self.ip
        try:
            hinfo = socket.gethostbyaddr(ipstr)
        except socket.herror as e:
            log.debug("Exception caught trying to get host name of %s: %s",
                      ipstr, e)
            self.name = network.getHostname()
        else:
            if len(hinfo) == 3:
                self.name = hinfo[0]

        if self.ip.find(':') != -1:
            ipstr = "[%s]" % (self.ip, )

        if (self.name is not None) and (
                not self.name.startswith('localhost')) and (ipstr is not None):
            self.connxinfo = "%s:%s (%s:%s)" % (socket.getfqdn(
                name=self.name), self.display, ipstr, self.display)
        elif ipstr is not None:
            self.connxinfo = "%s:%s" % (
                ipstr,
                self.display,
            )
        else:
            self.connxinfo = None

        # figure out product info
        if self.name is not None:
            self.desktop = _("%(productName)s %(productVersion)s installation "
                             "on host %(name)s") \
                           % {'productName': product.productName,
                              'productVersion': product.productVersion,
                              'name': self.name}
Exemple #2
0
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.getFirstRealIP()

    if not ip:
        stdout_log.error(
            "No IP addresses found, cannot continue installation.")
        iutil.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.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."))
Exemple #3
0
    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.getFirstRealIP()
            if self.ip:
                break
            time.sleep(1)
            tries -= 1

        if not self.ip:
            return

        ipstr = self.ip
        try:
            hinfo = socket.gethostbyaddr(ipstr)
        except socket.herror as e:
            log.debug("Exception caught trying to get host name of %s: %s", ipstr, e)
            self.name = network.getHostname()
        else:
            if len(hinfo) == 3:
                self.name = hinfo[0]

        if self.ip.find(':') != -1:
            ipstr = "[%s]" % (self.ip,)

        name_ips = [i[4][0] for i in socket.getaddrinfo(self.name, 0)]
        if self.name is not None and not self.name.startswith('localhost') \
           and ipstr is not None and self.ip in name_ips:
            self.connxinfo = "%s:%s (%s:%s)" % \
                    (socket.getfqdn(name=self.name), constants.X_DISPLAY_NUMBER,
                     ipstr, constants.X_DISPLAY_NUMBER)
        elif ipstr is not None:
            self.connxinfo = "%s:%s" % (ipstr, constants.X_DISPLAY_NUMBER)
        else:
            self.connxinfo = None

        # figure out product info
        if self.name is not None:
            self.desktop = _("%(productName)s %(productVersion)s installation "
                             "on host %(name)s") \
                           % {'productName': product.productName,
                              'productVersion': product.productVersion,
                              'name': self.name}
    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.getFirstRealIP()
            if self.ip:
                break
            time.sleep(1)
            tries -= 1

        if not self.ip:
            return

        ipstr = self.ip
        try:
            hinfo = socket.gethostbyaddr(ipstr)
        except socket.herror as e:
            log.debug("Exception caught trying to get host name of %s: %s", ipstr, e)
            self.name = network.getHostname()
        else:
            if len(hinfo) == 3:
                self.name = hinfo[0]

        if self.ip.find(":") != -1:
            ipstr = "[%s]" % (self.ip,)

        if (self.name is not None) and (not self.name.startswith("localhost")) and (ipstr is not None):
            self.connxinfo = "%s:%s (%s:%s)" % (socket.getfqdn(name=self.name), self.display, ipstr, self.display)
        elif ipstr is not None:
            self.connxinfo = "%s:%s" % (ipstr, self.display)
        else:
            self.connxinfo = None

        # figure out product info
        if self.name is not None:
            self.desktop = _("%(productName)s %(productVersion)s installation " "on host %(name)s") % {
                "productName": product.productName,
                "productVersion": product.productVersion,
                "name": self.name,
            }
Exemple #5
0
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.getFirstRealIP()

    if not ip:
        stdout_log.error("No IP addresses found, cannot continue installation.")
        iutil.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.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."))
Exemple #6
0
    def refresh(self, args=None):
        """ Refresh screen. """
        self._load_new_devices()
        EditTUISpoke.refresh(self, args)

        # on refresh check if we haven't got hostname from NM on activated
        # connection (dhcp or DNS)
        if self.hostname_dialog.value == network.DEFAULT_HOSTNAME:
            hostname = network.getHostname()
            network.update_hostname_data(self.data, hostname)
            self.hostname_dialog.value = self.data.network.hostname

        summary = self._summary_text()
        self._window += [TextWidget(summary), ""]
        hostname = _("Host Name: %s\n") % self.data.network.hostname
        self._window += [TextWidget(hostname), ""]

        # if we have any errors, display them
        while len(self.errors) > 0:
            self._window += [TextWidget(self.errors.pop()), ""]

        def _prep(i, w):
            """ Mangle our text to make it look pretty on screen. """
            number = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [number]), (None, [w])], 1)

        _opts = [_("Set host name")]
        for devname in self.supported_devices:
            _opts.append(_("Configure device %s") % devname)
        text = [TextWidget(o) for o in _opts]

        # make everything presentable on screen
        choices = [_prep(i, w) for i, w in enumerate(text)]
        displayed = ColumnWidget([(78, choices)], 1)
        self._window.append(displayed)

        return True
Exemple #7
0
    def refresh(self, args=None):
        """ Refresh screen. """
        self._load_new_devices()
        EditTUISpoke.refresh(self, args)

        # on refresh check if we haven't got hostname from NM on activated
        # connection (dhcp or DNS)
        if self.hostname_dialog.value == network.DEFAULT_HOSTNAME:
            hostname = network.getHostname()
            network.update_hostname_data(self.data, hostname)
            self.hostname_dialog.value = self.data.network.hostname

        summary = self._summary_text()
        self._window += [TextWidget(summary), ""]
        hostname = _("Host Name: %s\n") % self.data.network.hostname
        self._window += [TextWidget(hostname), ""]

        # if we have any errors, display them
        while len(self.errors) > 0:
            self._window += [TextWidget(self.errors.pop()), ""]

        def _prep(i, w):
            """ Mangle our text to make it look pretty on screen. """
            number = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [number]), (None, [w])], 1)

        _opts = [_("Set host name")]
        for devname in self.supported_devices:
            _opts.append(_("Configure device %s") % devname)
        text = [TextWidget(o) for o in _opts]

        # make everything presentable on screen
        choices = [_prep(i, w) for i, w in enumerate(text)]
        displayed = ColumnWidget([(78, choices)], 1)
        self._window.append(displayed)

        return True