Determine instance cores from public flavors API

Fixes bug 1078371

Previously the flavor vcpus used in the CPU utilization metering
was available from the nova DB instance representation.

Now that we retrieve the on-host instances from the public nova API
as opposed to the DB, we need to retrieve the flavor vcpus from
the flavors API.

Note that it's a known issue with nova that a flavor associated
with a running instance can be deleted and re-created with the
same ID but a different resource configuration (in this case, a
different number of cores would led to an incorrect CPU util
calculation). This will be addressed in a future nova patch.

Change-Id: I093acb94a4818f671782a3cb4e2c846f29b8cec5
This commit is contained in:
Eoghan Glynn
2012-11-13 20:20:19 +00:00
parent f3641de37f
commit 454c486e01
3 changed files with 6 additions and 3 deletions

View File

@@ -59,7 +59,7 @@ class TestLibvirtBase(test_base.TestCase):
setattr(self.instance, 'OS-EXT-SRV-ATTR:instance_name',
self.instance.name)
self.instance.id = 1
self.instance.flavor = {'name': 'm1.small', 'id': 2}
self.instance.flavor = {'name': 'm1.small', 'id': 2, 'vcpus': 1}
flags.FLAGS.compute_driver = 'libvirt.LibvirtDriver'
flags.FLAGS.connection_type = 'libvirt'