diff options
| author | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2011-03-18 09:53:28 +0000 |
|---|---|---|
| committer | Salvatore Orlando <salvatore.orlando@eu.citrix.com> | 2011-03-18 09:53:28 +0000 |
| commit | 0fbd0e70b4699bb4a34792e14fd11c5b57636fde (patch) | |
| tree | 98de26eeca73da4a30a140542f53fc1422e78f2c /nova/virt | |
| parent | 0174d584708f2e9b7fa02a27eeb707892eb213ec (diff) | |
| parent | abe147f756f13d4f968aa075d709e5c6643d310a (diff) | |
merge trunk
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt_conn.py | 43 | ||||
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 8 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 9 |
3 files changed, 39 insertions, 21 deletions
diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 0a85da541..e80b9fbdf 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -991,24 +991,35 @@ class LibvirtConnection(object): + xml.serialize()) cpu_info = dict() - cpu_info['arch'] = xml.xpathEval('//host/cpu/arch')[0].getContent() - cpu_info['model'] = xml.xpathEval('//host/cpu/model')[0].getContent() - cpu_info['vendor'] = xml.xpathEval('//host/cpu/vendor')[0].getContent() - topology_node = xml.xpathEval('//host/cpu/topology')[0]\ - .get_properties() + arch_nodes = xml.xpathEval('//host/cpu/arch') + if arch_nodes: + cpu_info['arch'] = arch_nodes[0].getContent() + + model_nodes = xml.xpathEval('//host/cpu/model') + if model_nodes: + cpu_info['model'] = model_nodes[0].getContent() + + vendor_nodes = xml.xpathEval('//host/cpu/vendor') + if vendor_nodes: + cpu_info['vendor'] = vendor_nodes[0].getContent() + + topology_nodes = xml.xpathEval('//host/cpu/topology') topology = dict() - while topology_node: - name = topology_node.get_name() - topology[name] = topology_node.getContent() - topology_node = topology_node.get_next() - - keys = ['cores', 'sockets', 'threads'] - tkeys = topology.keys() - if set(tkeys) != set(keys): - ks = ', '.join(keys) - raise exception.Invalid(_("Invalid xml: topology(%(topology)s) " - "must have %(ks)s") % locals()) + if topology_nodes: + topology_node = topology_nodes[0].get_properties() + while topology_node: + name = topology_node.get_name() + topology[name] = topology_node.getContent() + topology_node = topology_node.get_next() + + keys = ['cores', 'sockets', 'threads'] + tkeys = topology.keys() + if set(tkeys) != set(keys): + ks = ', '.join(keys) + raise exception.Invalid(_("Invalid xml: topology" + "(%(topology)s) must have " + "%(ks)s") % locals()) feature_nodes = xml.xpathEval('//host/cpu/feature') features = list() diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 0610d5c11..f3e1a2ab8 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -244,7 +244,8 @@ class VMHelper(HelperBase): raise StorageError(_('Unable to destroy VDI %s') % vdi_ref) @classmethod - def create_vif(cls, session, vm_ref, network_ref, mac_address, dev="0"): + def create_vif(cls, session, vm_ref, network_ref, mac_address, + dev="0", rxtx_cap=0): """Create a VIF record. Returns a Deferred that gives the new VIF reference.""" vif_rec = {} @@ -254,8 +255,9 @@ class VMHelper(HelperBase): vif_rec['MAC'] = mac_address vif_rec['MTU'] = '1500' vif_rec['other_config'] = {} - vif_rec['qos_algorithm_type'] = '' - vif_rec['qos_algorithm_params'] = {} + vif_rec['qos_algorithm_type'] = "ratelimit" if rxtx_cap else '' + vif_rec['qos_algorithm_params'] = \ + {"kbps": str(rxtx_cap * 1024)} if rxtx_cap else {} LOG.debug(_('Creating VIF for VM %(vm_ref)s,' ' network %(network_ref)s.') % locals()) vif_ref = session.call_xenapi('VIF.create', vif_rec) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index e4701762f..25f8f3642 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -818,8 +818,12 @@ class VMOps(object): Creates vifs for an instance """ - vm_ref = self._get_vm_opaque_ref(instance.id) + vm_ref = self._get_vm_opaque_ref(instance['id']) + admin_context = context.get_admin_context() + flavor = db.instance_type_get_by_name(admin_context, + instance.instance_type) logging.debug(_("creating vif(s) for vm: |%s|"), vm_ref) + rxtx_cap = flavor['rxtx_cap'] if networks is None: networks = db.network_get_all_by_instance(admin_context, instance['id']) @@ -840,7 +844,8 @@ class VMOps(object): device = "0" VMHelper.create_vif(self._session, vm_ref, network_ref, - instance.mac_address, device) + instance.mac_address, device, + rxtx_cap=rxtx_cap) def reset_network(self, instance): """ |
