It also prevents a crash when no IP address is found.
--- pyanaconda/vnc.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index a7ccc76..000c9fc 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -84,8 +84,8 @@ class VncServer: active_devs = network.getActiveNetDevs()
self.ip = None - if active_devs != []: - devname = devices[active_devs[0]].iface + for dev in active_devs: + devname = devices[dev].iface try: ips = (isys.getIPAddresses(devname, version=4) + isys.getIPAddresses(devname, version=6)) @@ -97,6 +97,10 @@ class VncServer: log.info("IPs (using first) of device %s: %s" % (devname, ips)) self.ip = ips[0] + break + + if not self.ip: + self.log.warning("No IP address found. You may not be able to connect to VNC server.")
ipstr = self.ip
@@ -110,7 +114,7 @@ class VncServer: if len(hinfo) == 3: self.name = hinfo[0]
- if self.ip.find(':') != -1: + if self.ip and 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):
On 06/08/2012 11:20 AM, Gustavo Luiz Duarte wrote:
It also prevents a crash when no IP address is found.
pyanaconda/vnc.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index a7ccc76..000c9fc 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -84,8 +84,8 @@ class VncServer: active_devs = network.getActiveNetDevs()
self.ip = None
if active_devs != []:
devname = devices[active_devs[0]].iface
for dev in active_devs:
devname = devices[dev].iface try: ips = (isys.getIPAddresses(devname, version=4) + isys.getIPAddresses(devname, version=6))
@@ -97,6 +97,10 @@ class VncServer: log.info("IPs (using first) of device %s: %s" % (devname, ips)) self.ip = ips[0]
break
if not self.ip:
self.log.warning("No IP address found. You may not be able to connect to VNC server.")
Is a warning here appropriate? If we can't find an IP address, how is vnc ever going to work?
ipstr = self.ip
@@ -110,7 +114,7 @@ class VncServer: if len(hinfo) == 3: self.name = hinfo[0]
if self.ip.find(':') != -1:
if self.ip and 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):
All the rest look fine, although since we've got some code duplication I'm going to look at moving the common code into a library to make use of it from multiple places.
On 06/14/2012 03:36 PM, Jesse Keating wrote:
On 06/08/2012 11:20 AM, Gustavo Luiz Duarte wrote:
It also prevents a crash when no IP address is found.
pyanaconda/vnc.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py index a7ccc76..000c9fc 100644 --- a/pyanaconda/vnc.py +++ b/pyanaconda/vnc.py @@ -84,8 +84,8 @@ class VncServer: active_devs = network.getActiveNetDevs()
self.ip = None
if active_devs != []:
devname = devices[active_devs[0]].iface
for dev in active_devs:
devname = devices[dev].iface try: ips = (isys.getIPAddresses(devname, version=4) + isys.getIPAddresses(devname, version=6))
@@ -97,6 +97,10 @@ class VncServer: log.info("IPs (using first) of device %s: %s" % (devname,
ips)) self.ip = ips[0]
break
if not self.ip:
self.log.warning("No IP address found. You may not be
able to connect to VNC server.")
Is a warning here appropriate? If we can't find an IP address, how is vnc ever going to work?
We should warn the user or abort. I kept the warning because, based on the following code excerpt, there seems to be a use for the no IP address case (maybe local access for testing purposes?).
if self.connxinfo != None: self.log.info(_("Please manually connect your vnc client to %s to begin the install.") % (self.connxinfo,)) else: self.log.info(_("Please manually connect your vnc client to begin the install."))
ipstr = self.ip
@@ -110,7 +114,7 @@ class VncServer: if len(hinfo) == 3: self.name = hinfo[0]
if self.ip.find(':') != -1:
if self.ip and 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):
All the rest look fine, although since we've got some code duplication I'm going to look at moving the common code into a library to make use of it from multiple places.
Even better. Thanks Jesse.
[]'s Gustavo
On 06/08/2012 11:20 AM, Gustavo Luiz Duarte wrote:
It also prevents a crash when no IP address is found.
My recent patch to put the IP fetching code in a shared library incorporates some of your patch. Although if we don't find an IP, while we don't crash, we do exit the installer. If there is no found IP there is no way for the user to connect or for us to connect to the user. It's not appropriate to continue from that point.
anaconda-devel@lists.stg.fedoraproject.org