diff options
| author | Yaguang Tang <yaguang.tang@canonical.com> | 2013-03-05 16:53:10 +0800 |
|---|---|---|
| committer | Yaguang Tang <yaguang.tang@canonical.com> | 2013-03-13 19:41:54 +0800 |
| commit | cbd3c7aeb4b44d2fe15bc1ed376243cf0a3752b7 (patch) | |
| tree | 6091643bdaf4accba17ddd0384b2cc2a4f7dc5a1 | |
| parent | 99155de44615dbb5718bf7d20bf749ef49a4b507 (diff) | |
| download | nova-cbd3c7aeb4b44d2fe15bc1ed376243cf0a3752b7.tar.gz nova-cbd3c7aeb4b44d2fe15bc1ed376243cf0a3752b7.tar.xz nova-cbd3c7aeb4b44d2fe15bc1ed376243cf0a3752b7.zip | |
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
| -rw-r--r-- | nova/virt/libvirt/designer.py | 11 | ||||
| -rwxr-xr-x | nova/virt/libvirt/driver.py | 6 | ||||
| -rwxr-xr-x | 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): |
