[XEND] Unparsable VLAN numbers should default to -1
authorAlastair Tse <atse@xensource.com>
Tue, 30 Jan 2007 11:37:18 +0000 (11:37 +0000)
committerAlastair Tse <atse@xensource.com>
Tue, 30 Jan 2007 11:37:18 +0000 (11:37 +0000)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendNode.py
tools/python/xen/xend/XendPIF.py

index 6a01e958f26ec55deadae2e07529d2f809322bf3..c2e336b345650c128376fb0b950d483f5e21d2a5 100644 (file)
@@ -125,8 +125,13 @@ class XendNode:
                             # Compatibility hack, can go pretty soon.
                             pif['metrics'] = uuid.createString()
 
+                        try:
+                            pif['VLAN'] = int(pif.get('VLAN', -1))
+                        except (ValueError, TypeError):
+                            pif['VLAN'] = -1
+
                         self._PIF_create(pif['device'], pif['MTU'],
-                                         int(pif['VLAN']),
+                                         pif['VLAN'],
                                          pif['MAC'], network, False, pif_uuid,
                                          pif['metrics'])
                     except NetworkAlreadyConnected, exn:
index 6c8fcae6d64aa1760030ed78f44c29d1f9651d3e..b0284278636172f35324aee25605ddd77aa7611f 100644 (file)
@@ -138,8 +138,9 @@ class XendPIF:
             
             rc, _ = _cmd('vconfig add %s %d', self.device, self.vlan)
             if rc != 0:
-                log.error('Could not refresh %s', ifname)
+                log.error('Could not refresh VLAN for interface %s', ifname)
                 return
+            
             log.info('Created network interface %s', ifname)
 
         for brname, nics in bridges.items():