Merge "xenapi: fix structure of data reported for cpu_info"

This commit is contained in:
Jenkins 2015-01-24 20:33:50 +00:00 committed by Gerrit Code Review
commit 159e68eb1a
5 changed files with 139 additions and 13 deletions

View File

@ -44,6 +44,26 @@ class XenAPIDriverTestCase(stubs.XenAPITestBaseNoDB):
'host_hostname': 'somename',
'supported_instances': arch.X86_64,
'host_cpu_info': {'cpu_count': 50},
'cpu_model': {
'vendor': 'GenuineIntel',
'model': 'Intel(R) Xeon(R) CPU X3430 @ 2.40GHz',
'topology': {
'sockets': 1,
'cores': 4,
'threads': 1,
},
'features': [
'fpu', 'de', 'tsc', 'msr', 'pae', 'mce',
'cx8', 'apic', 'sep', 'mtrr', 'mca',
'cmov', 'pat', 'clflush', 'acpi', 'mmx',
'fxsr', 'sse', 'sse2', 'ss', 'ht',
'nx', 'constant_tsc', 'nonstop_tsc',
'aperfmperf', 'pni', 'vmx', 'est', 'ssse3',
'sse4_1', 'sse4_2', 'popcnt', 'hypervisor',
'ida', 'tpr_shadow', 'vnmi', 'flexpriority',
'ept', 'vpid',
],
},
'vcpus_used': 10,
'pci_passthrough_devices': '',
'host_other-config': {'iscsi_iqn': 'someiqn'}}

View File

@ -2067,8 +2067,27 @@ class XenAPIHostTestCase(stubs.XenAPITestBase):
self.assertEqual(stats['host_memory_free'], 30)
self.assertEqual(stats['host_memory_free_computed'], 40)
self.assertEqual(stats['hypervisor_hostname'], 'fake-xenhost')
self.assertThat({'cpu_count': 50},
matchers.DictMatches(stats['host_cpu_info']))
self.assertEqual(stats['host_cpu_info']['cpu_count'], 4)
self.assertThat({
'vendor': 'GenuineIntel',
'model': 'Intel(R) Xeon(R) CPU X3430 @ 2.40GHz',
'topology': {
'sockets': 1,
'cores': 4,
'threads': 1,
},
'features': [
'fpu', 'de', 'tsc', 'msr', 'pae', 'mce',
'cx8', 'apic', 'sep', 'mtrr', 'mca',
'cmov', 'pat', 'clflush', 'acpi', 'mmx',
'fxsr', 'sse', 'sse2', 'ss', 'ht',
'nx', 'constant_tsc', 'nonstop_tsc',
'aperfmperf', 'pni', 'vmx', 'est', 'ssse3',
'sse4_1', 'sse4_2', 'popcnt', 'hypervisor',
'ida', 'tpr_shadow', 'vnmi', 'flexpriority',
'ept', 'vpid',
]},
matchers.DictMatches(stats['cpu_model']))
# No VMs running
self.assertEqual(stats['vcpus_used'], 0)
@ -2154,7 +2173,6 @@ class XenAPIHostTestCase(stubs.XenAPITestBase):
def test_supported_instances_is_calculated_by_to_supported_instances(self):
def to_supported_instances(somedata):
self.assertIsNone(somedata)
return "SOMERETURNVALUE"
self.stubs.Set(host, 'to_supported_instances', to_supported_instances)

View File

@ -453,9 +453,7 @@ class XenAPIDriver(driver.ComputeDriver):
'hypervisor_type': 'xen',
'hypervisor_version': hyper_ver,
'hypervisor_hostname': host_stats['host_hostname'],
# Todo(bobba) cpu_info may be in a format not supported by
# arch_filter.py - see libvirt/driver.py get_cpu_info
'cpu_info': jsonutils.dumps(host_stats['host_cpu_info']),
'cpu_info': jsonutils.dumps(host_stats['cpu_model']),
'disk_available_least': total_disk_gb - allocated_disk_gb,
'supported_instances': jsonutils.dumps(
host_stats['supported_instances']),

View File

@ -672,13 +672,47 @@ class SessionBase(object):
_plugin_migration_move_vhds_into_sr = _plugin_noop
def _plugin_xenhost_host_data(self, method, args):
return jsonutils.dumps({'host_memory': {'total': 10,
'overhead': 20,
'free': 30,
'free-computed': 40},
'host_hostname': 'fake-xenhost',
'host_cpu_info': {'cpu_count': 50},
})
return jsonutils.dumps({
'host_memory': {'total': 10,
'overhead': 20,
'free': 30,
'free-computed': 40},
'host_uuid': 'fb97583b-baa1-452d-850e-819d95285def',
'host_name-label': 'fake-xenhost',
'host_name-description': 'Default install of XenServer',
'host_hostname': 'fake-xenhost',
'host_ip_address': '10.219.10.24',
'enabled': 'true',
'host_capabilities': ['xen-3.0-x86_64',
'xen-3.0-x86_32p',
'hvm-3.0-x86_32',
'hvm-3.0-x86_32p',
'hvm-3.0-x86_64'],
'host_other-config': {
'agent_start_time': '1412774967.',
'iscsi_iqn': 'iqn.2014-10.org.example:39fa9ee3',
'boot_time': '1412774885.',
},
'host_cpu_info': {
'physical_features': '0098e3fd-bfebfbff-00000001-28100800',
'modelname': 'Intel(R) Xeon(R) CPU X3430 @ 2.40GHz',
'vendor': 'GenuineIntel',
'features': '0098e3fd-bfebfbff-00000001-28100800',
'family': 6,
'maskable': 'full',
'cpu_count': 4,
'socket_count': '1',
'flags': 'fpu de tsc msr pae mce cx8 apic sep mtrr mca '
'cmov pat clflush acpi mmx fxsr sse sse2 ss ht '
'nx constant_tsc nonstop_tsc aperfmperf pni vmx '
'est ssse3 sse4_1 sse4_2 popcnt hypervisor ida '
'tpr_shadow vnmi flexpriority ept vpid',
'stepping': 5,
'model': 30,
'features_after_reboot': '0098e3fd-bfebfbff-00000001-28100800',
'speed': '2394.086'
},
})
def _plugin_poweraction(self, method, args):
return jsonutils.dumps({"power_action": method[5:]})

View File

@ -244,6 +244,9 @@ class HostState(object):
data["supported_instances"] = to_supported_instances(
data.get("host_capabilities")
)
data["cpu_model"] = to_cpu_model(
data.get("host_cpu_info")
)
host_memory = data.get('host_memory', None)
if host_memory:
data["host_memory_total"] = host_memory.get('total', 0)
@ -292,6 +295,59 @@ def to_supported_instances(host_capabilities):
return result
def to_cpu_model(host_cpu_info):
# The XenAPI driver returns data in the format
#
# {"physical_features": "0098e3fd-bfebfbff-00000001-28100800",
# "modelname": "Intel(R) Xeon(R) CPU X3430 @ 2.40GHz",
# "vendor": "GenuineIntel",
# "features": "0098e3fd-bfebfbff-00000001-28100800",
# "family": 6,
# "maskable": "full",
# "cpu_count": 4,
# "socket_count": "1",
# "flags": "fpu de tsc msr pae mce cx8 apic sep mtrr mca cmov
# pat clflush acpi mmx fxsr sse sse2 ss ht nx
# constant_tsc nonstop_tsc aperfmperf pni vmx est
# ssse3 sse4_1 sse4_2 popcnt hypervisor ida
# tpr_shadow vnmi flexpriority ept vpid",
# "stepping": 5,
# "model": 30,
# "features_after_reboot": "0098e3fd-bfebfbff-00000001-28100800",
# "speed": "2394.086"}
if host_cpu_info is None:
return None
cpu_info = dict()
# TODO(berrange) the data we're putting in model is not
# exactly comparable to what libvirt puts in model. The
# libvirt model names are a well defined short string
# which is really an aliass for a particular set of
# feature flags. The Xen model names are raw printable
# strings from the kernel with no specific semantics
cpu_info["model"] = host_cpu_info["modelname"]
cpu_info["vendor"] = host_cpu_info["vendor"]
# TODO(berrange) perhaps we could fill in 'arch' field too
# by looking at 'host_capabilities' for the Xen host ?
topology = dict()
topology["sockets"] = int(host_cpu_info["socket_count"])
topology["cores"] = (int(host_cpu_info["cpu_count"]) /
int(host_cpu_info["socket_count"]))
# TODO(berrange): if 'ht' is present in the 'flags' list
# is it possible to infer that the 'cpu_count' is in fact
# sockets * cores * threads ? Unclear if 'ht' would remain
# visible when threads are disabled in BIOS ?
topology["threads"] = 1
cpu_info["topology"] = topology
cpu_info["features"] = host_cpu_info["flags"].split(" ")
return cpu_info
def call_xenhost(session, method, arg_dict):
"""There will be several methods that will need this general
handling for interacting with the xenhost plugin, so this abstracts