Handle network interfaces without IPs
authorAndrea Spadaccini <spadaccio@google.com>
Mon, 15 Aug 2011 13:20:27 +0000 (14:20 +0100)
committerGuido Trotter <ultrotter@google.com>
Mon, 15 Aug 2011 15:46:22 +0000 (16:46 +0100)
If the user specified a network interface with no IPs, he would receive
an unhelpful "list index out of range" error. Fixed that.

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/hypervisor/hv_kvm.py

index 10718a5..04d2327 100644 (file)
@@ -747,8 +747,11 @@ class KVMHypervisor(hv_base.BaseHypervisor):
               cluster_family)
         elif addresses[constants.IP4_VERSION]:
           spice_ip_version = constants.IP4_VERSION
-        else:
+        elif addresses[constants.IP6_VERSION]:
           spice_ip_version = constants.IP6_VERSION
+        else:
+          raise errors.HypervisorError("spice: unable to get an IP address"
+                                       " for %s" % (spice_bind))
 
         spice_address = addresses[spice_ip_version][0]