ia64/xen-unstable

changeset 14656:2317e0cdd07d

Merge
author Tim Deegan <Tim.Deegan@xensource.com>
date Thu Mar 29 15:33:32 2007 +0000 (2007-03-29)
parents 86a798a62cc5 2ac29d446366
children b7ae31726aa6 e3dc8cea5bc0
files
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Thu Mar 29 15:32:08 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Thu Mar 29 15:33:32 2007 +0000
     1.3 @@ -1823,9 +1823,6 @@ class XendAPI(object):
     1.4      VM_metrics_attr_rw = []
     1.5      VM_metrics_methods = []
     1.6  
     1.7 -    def VIF_metrics_get_all(self, session):
     1.8 -        return self.VIF_get_all(session)
     1.9 -
    1.10      def _VM_metrics_get(self, _, ref):
    1.11          return XendVMMetrics.get_by_uuid(ref)
    1.12  
    1.13 @@ -2135,6 +2132,9 @@ class XendAPI(object):
    1.14      VIF_metrics_attr_rw = []
    1.15      VIF_metrics_methods = []
    1.16  
    1.17 +    def VIF_metrics_get_all(self, session):
    1.18 +        return self.VIF_get_all(session)
    1.19 +
    1.20      def VIF_metrics_get_record(self, _, ref):
    1.21          vm = XendDomain.instance().get_vm_with_dev_uuid('vif', ref)
    1.22          if not vm:
     2.1 --- a/tools/python/xen/xend/XendNode.py	Thu Mar 29 15:32:08 2007 +0000
     2.2 +++ b/tools/python/xen/xend/XendNode.py	Thu Mar 29 15:33:32 2007 +0000
     2.3 @@ -143,8 +143,14 @@ class XendNode:
     2.4              for net_uuid, network in saved_networks.items():
     2.5                  self.network_create(network, False, net_uuid)
     2.6          else:
     2.7 -            self.network_create({'name_label' : 'net0' }, False)
     2.8 +            bridges = Brctl.get_state().keys()
     2.9 +            for bridge in bridges:
    2.10 +                self.network_create({'name_label' : bridge }, False)
    2.11 +                
    2.12 +        # Get a mapping from interface to bridge
    2.13  
    2.14 +        if_to_br = dict(reduce(lambda ls,(b,ifs):[(i,b) for i in ifs] + ls,
    2.15 +                               Brctl.get_state().items(), []))
    2.16          # initialise PIFs
    2.17          saved_pifs = self.state_store.load_state('pif')
    2.18          if saved_pifs:
    2.19 @@ -174,8 +180,14 @@ class XendNode:
    2.20                                    pif_uuid, pif['network'], exn.pif_uuid)
    2.21          else:
    2.22              for name, mtu, mac in linux_get_phy_ifaces():
    2.23 -                network = self.networks.values()[0]
    2.24 -                self._PIF_create(name, mtu, -1, mac, network, False)
    2.25 +                bridge_name = if_to_br.get(name, None)
    2.26 +                if bridge_name is not None:
    2.27 +                    networks = [network for
    2.28 +                                network in self.networks.values()
    2.29 +                                if network.get_name_label() == bridge_name]
    2.30 +                    if len(networks) > 0:
    2.31 +                        network = networks[0]
    2.32 +                        self._PIF_create(name, mtu, -1, mac, network, False)
    2.33  
    2.34          # initialise storage
    2.35          saved_srs = self.state_store.load_state('sr')
     3.1 --- a/tools/python/xen/xm/create.dtd	Thu Mar 29 15:32:08 2007 +0000
     3.2 +++ b/tools/python/xen/xm/create.dtd	Thu Mar 29 15:33:32 2007 +0000
     3.3 @@ -74,7 +74,6 @@
     3.4                   mtu             CDATA       #REQUIRED
     3.5                   device          CDATA       #REQUIRED
     3.6                   qos_algorithm_type CDATA    #REQUIRED
     3.7 -                 bridge          CDATA       #IMPLIED
     3.8                   network         CDATA       #IMPLIED> 
     3.9  
    3.10  <!ELEMENT pv     EMPTY>
     4.1 --- a/tools/python/xen/xm/xenapi_create.py	Thu Mar 29 15:32:08 2007 +0000
     4.2 +++ b/tools/python/xen/xm/xenapi_create.py	Thu Mar 29 15:33:32 2007 +0000
     4.3 @@ -25,7 +25,7 @@ from xml.parsers.xmlproc import xmlproc,
     4.4  from xen.xend import sxp
     4.5  from xen.xend.XendAPIConstants import XEN_API_ON_NORMAL_EXIT, \
     4.6       XEN_API_ON_CRASH_BEHAVIOUR
     4.7 -
     4.8 +from xen.xm.opts import OptionError
     4.9  
    4.10  import sys
    4.11  import os
    4.12 @@ -184,15 +184,7 @@ class xenapi_create:
    4.13          map(self.check_vif, vifs)
    4.14  
    4.15      def check_vif(self, vif):
    4.16 -        """
    4.17 -        Check that the vif has
    4.18 -        either a bridge or network
    4.19 -        name but not both
    4.20 -        """
    4.21 -        if "bridge" in vif.attributes.keys() \
    4.22 -               and "network" in vif.attributes.keys():
    4.23 -            raise "You cannot specify both a bridge and\
    4.24 -                   a network name."
    4.25 +        pass
    4.26  
    4.27      # Cleanup methods here
    4.28      def cleanup_vdis(self, vdi_refs_dict):
    4.29 @@ -313,19 +305,23 @@ class xenapi_create:
    4.30              traceback.print_exc()
    4.31              sys.exit(-1)
    4.32  
    4.33 -        # Now create vbds
    4.34 +        try:
    4.35 +            # Now create vbds
    4.36  
    4.37 -        vbds = vm.getElementsByTagName("vbd")
    4.38 +            vbds = vm.getElementsByTagName("vbd")
    4.39  
    4.40 -        self.create_vbds(vm_ref, vbds, vdis)
    4.41 +            self.create_vbds(vm_ref, vbds, vdis)
    4.42 +
    4.43 +            # Now create vifs
    4.44  
    4.45 -        # Now create vifs
    4.46 +            vifs = vm.getElementsByTagName("vif")
    4.47  
    4.48 -        vifs = vm.getElementsByTagName("vif")
    4.49 +            self.create_vifs(vm_ref, vifs)
    4.50  
    4.51 -        self.create_vifs(vm_ref, vifs)
    4.52 -
    4.53 -        return vm_ref
    4.54 +            return vm_ref
    4.55 +        except:
    4.56 +            server.xenapi.VM.destroy(vm_ref)
    4.57 +            raise
    4.58          
    4.59      def create_vbds(self, vm_ref, vbds, vdis):
    4.60          log(DEBUG, "create_vbds")
    4.61 @@ -363,13 +359,16 @@ class xenapi_create:
    4.62      def create_vif(self, vm_ref, vif):
    4.63          log(DEBUG, "create_vif")
    4.64  
    4.65 -        if "bridge" in vif.attributes.keys():
    4.66 -            raise "Not allowed to add by bridge just yet"
    4.67 -        elif "network" in vif.attributes.keys():
    4.68 -            network = [network_ref
    4.69 +        if "network" in vif.attributes.keys():
    4.70 +            networks = [network_ref
    4.71                  for network_ref in server.xenapi.network.get_all()
    4.72                  if server.xenapi.network.get_name_label(network_ref)
    4.73 -                       == vif.attributes["network"].value][0]
    4.74 +                       == vif.attributes["network"].value]
    4.75 +            if len(networks) > 0:
    4.76 +                network = networks[0]
    4.77 +            else:
    4.78 +                raise OptionError("Network %s doesn't exist"
    4.79 +                                  % vif.attributes["network"].value)
    4.80          else:
    4.81              network = self._get_network_ref()
    4.82  
    4.83 @@ -631,7 +630,7 @@ class sxp2xml:
    4.84          vif.attributes["qos_algorithm_type"] = ""
    4.85  
    4.86          if get_child_by_name(vif_sxp, "bridge") is not None:
    4.87 -            vif.attributes["bridge"] \
    4.88 +            vif.attributes["network"] \
    4.89                  = get_child_by_name(vif_sxp, "bridge")
    4.90          
    4.91          return vif