From cbd3c7aeb4b44d2fe15bc1ed376243cf0a3752b7 Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Tue, 5 Mar 2013 16:53:10 +0800 Subject: Read instance resource quota info from "quota" namespace. Scope all instance resource quota params such as CPU(cpu_shares,cpu_quota, cpu_period), disk IO(disk_read_bytes_sec,disk_write_bytes_sec etc.), network bandwidth(vif_inbound_average, vif_outbouand_average) to "quota" scope in extra_specs, so that it doesn't conflict with compute_capabilities_filter. after this patch, user should use: nova flavor-key m1.tiny set quota:cpu_shares=1000 to set parameters. Fix bug #1146322 DocImpact Change-Id: I30e550d21f00eb949ee2f3f8fb4d952c10bf8000 --- nova/virt/libvirt/designer.py | 11 ++++++++--- nova/virt/libvirt/driver.py | 6 ++++-- nova/virt/libvirt/imagebackend.py | 6 ++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/nova/virt/libvirt/designer.py b/nova/virt/libvirt/designer.py index 0625d407b..8dc579300 100644 --- a/nova/virt/libvirt/designer.py +++ b/nova/virt/libvirt/designer.py @@ -101,11 +101,16 @@ def set_vif_host_backend_802qbh_config(conf, devname, profileid, def set_vif_bandwidth_config(conf, extra_specs): - """Config vif inbound/outbound bandwidth limit.""" + """Config vif inbound/outbound bandwidth limit. parameters are + set in instance_type_extra_specs table, key is in the format + quota:vif_inbound_average. + """ bandwidth_items = ['vif_inbound_average', 'vif_inbound_peak', 'vif_inbound_burst', 'vif_outbound_average', 'vif_outbound_peak', 'vif_outbound_burst'] for key, value in extra_specs.iteritems(): - if key in bandwidth_items: - setattr(conf, key, value) + scope = key.split(':') + if len(scope) > 1 and scope[0] == 'quota': + if scope[1] in bandwidth_items: + setattr(conf, scope[1], value) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 4a9d2f3f5..1cf5f399f 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2136,8 +2136,10 @@ class LibvirtDriver(driver.ComputeDriver): quota_items = ['cpu_shares', 'cpu_period', 'cpu_quota'] for key, value in inst_type['extra_specs'].iteritems(): - if key in quota_items: - setattr(guest, key, value) + scope = key.split(':') + if len(scope) > 1 and scope[0] == 'quota': + if scope[1] in quota_items: + setattr(guest, scope[1], value) guest.cpu = self.get_guest_cpu_config() diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py index 25c6be1f3..c15896986 100755 --- a/nova/virt/libvirt/imagebackend.py +++ b/nova/virt/libvirt/imagebackend.py @@ -120,8 +120,10 @@ class Image(object): # throttling for qemu. if self.source_type in ['file', 'block']: for key, value in extra_specs.iteritems(): - if key in tune_items: - setattr(info, key, value) + scope = key.split(':') + if len(scope) > 1 and scope[0] == 'quota': + if scope[1] in tune_items: + setattr(info, scope[1], value) return info def cache(self, fetch_func, filename, size=None, *args, **kwargs): -- cgit