VMware vSphere: Bug fixes
- Fixed bugs in meter conversions i.e. converting the stat value queried from vSphere to the one used for creating ceilometer samples. - Switched the vSphere networking counters 'bytesTx/bytesRx' to 'transmitted/received'. The counters are synonymous, but the latter ones are available since ESX 3.5 and former are available only in ESX 5.0 onwards. - Added a null check in VsphereOperations._init_vm_moid_lookup_map() Change-Id: I8691ce4ded7bdc824bd56427642f9dd87081727a Implements: blueprint vmware-vcenter-server
This commit is contained in:
parent
87349b2572
commit
8026eccc36
@ -51,8 +51,8 @@ cfg.CONF.register_opts(OPTS, group=opt_group)
|
||||
|
||||
VC_AVERAGE_MEMORY_CONSUMED_CNTR = 'mem:consumed:average'
|
||||
VC_AVERAGE_CPU_CONSUMED_CNTR = 'cpu:usage:average'
|
||||
VC_NETWORK_RX_BYTES_COUNTER = 'net:bytesRx:average'
|
||||
VC_NETWORK_TX_BYTES_COUNTER = 'net:bytesTx:average'
|
||||
VC_NETWORK_RX_COUNTER = 'net:received:average'
|
||||
VC_NETWORK_TX_COUNTER = 'net:transmitted:average'
|
||||
VC_DISK_READ_RATE_CNTR = "disk:read:average"
|
||||
VC_DISK_READ_REQUESTS_RATE_CNTR = "disk:numberReadAveraged:average"
|
||||
VC_DISK_WRITE_RATE_CNTR = "disk:write:average"
|
||||
@ -94,6 +94,12 @@ class VsphereInspector(virt_inspector.Inspector):
|
||||
VC_AVERAGE_CPU_CONSUMED_CNTR)
|
||||
cpu_util = self._ops.query_vm_aggregate_stats(vm_moid,
|
||||
cpu_util_counter_id)
|
||||
|
||||
# For this counter vSphere returns values scaled-up by 100, since the
|
||||
# corresponding API can't return decimals, but only longs.
|
||||
# For e.g. if the utilization is 12.34%, the value returned is 1234.
|
||||
# Hence, dividing by 100.
|
||||
cpu_util = cpu_util / 100
|
||||
return virt_inspector.CPUUtilStats(util=cpu_util)
|
||||
|
||||
def inspect_vnics(self, instance_name):
|
||||
@ -108,19 +114,19 @@ class VsphereInspector(virt_inspector.Inspector):
|
||||
vnic_stats = {}
|
||||
vnic_ids = set()
|
||||
|
||||
for net_counter in (VC_NETWORK_RX_BYTES_COUNTER,
|
||||
VC_NETWORK_TX_BYTES_COUNTER):
|
||||
for net_counter in (VC_NETWORK_RX_COUNTER, VC_NETWORK_TX_COUNTER):
|
||||
net_counter_id = self._ops.get_perf_counter_id(net_counter)
|
||||
vnic_id_to_stats_map = \
|
||||
self._ops.query_vm_device_stats(vm_moid, net_counter_id)
|
||||
vnic_stats[net_counter] = vnic_id_to_stats_map
|
||||
vnic_ids.update(vnic_id_to_stats_map.iterkeys())
|
||||
|
||||
# Stats provided from vSphere are in KB/s, converting it to B/s.
|
||||
for vnic_id in vnic_ids:
|
||||
rx_bytes_rate = (vnic_stats[VC_NETWORK_RX_BYTES_COUNTER]
|
||||
.get(vnic_id, 0) / units.k)
|
||||
tx_bytes_rate = (vnic_stats[VC_NETWORK_TX_BYTES_COUNTER]
|
||||
.get(vnic_id, 0) / units.k)
|
||||
rx_bytes_rate = (vnic_stats[VC_NETWORK_RX_COUNTER]
|
||||
.get(vnic_id, 0) * units.Ki)
|
||||
tx_bytes_rate = (vnic_stats[VC_NETWORK_TX_COUNTER]
|
||||
.get(vnic_id, 0) * units.Ki)
|
||||
|
||||
stats = virt_inspector.InterfaceRateStats(rx_bytes_rate,
|
||||
tx_bytes_rate)
|
||||
@ -142,8 +148,8 @@ class VsphereInspector(virt_inspector.Inspector):
|
||||
mem_counter_id = self._ops.get_perf_counter_id(
|
||||
VC_AVERAGE_MEMORY_CONSUMED_CNTR)
|
||||
memory = self._ops.query_vm_aggregate_stats(vm_moid, mem_counter_id)
|
||||
# Stat provided from VMware Vsphere is in Bytes, converting it to MB.
|
||||
memory = memory / (units.Mi)
|
||||
# Stat provided from vSphere is in KB, converting it to MB.
|
||||
memory = memory / units.Ki
|
||||
return virt_inspector.MemoryUsageStats(usage=memory)
|
||||
|
||||
def inspect_disk_rates(self, instance):
|
||||
@ -174,6 +180,7 @@ class VsphereInspector(virt_inspector.Inspector):
|
||||
return disk_stats[counter_name].get(disk_id, 0)
|
||||
|
||||
disk = virt_inspector.Disk(device=disk_id)
|
||||
# Stats provided from vSphere are in KB/s, converting it to B/s.
|
||||
disk_rate_info = virt_inspector.DiskRateStats(
|
||||
read_bytes_rate=stat_val(VC_DISK_READ_RATE_CNTR) * units.Ki,
|
||||
read_requests_rate=stat_val(VC_DISK_READ_REQUESTS_RATE_CNTR),
|
||||
|
@ -55,9 +55,11 @@ class VsphereOperations(object):
|
||||
while result:
|
||||
for vm_object in result.objects:
|
||||
vm_moid = vm_object.obj.value
|
||||
vm_instance_id = vm_object.propSet[0].val
|
||||
if vm_instance_id:
|
||||
self._vm_moid_lookup_map[vm_instance_id] = vm_moid
|
||||
# propSet will be set only if the server provides value
|
||||
if hasattr(vm_object, 'propSet') and vm_object.propSet:
|
||||
vm_instance_id = vm_object.propSet[0].val
|
||||
if vm_instance_id:
|
||||
self._vm_moid_lookup_map[vm_instance_id] = vm_moid
|
||||
|
||||
result = session.invoke_api(vim_util, "continue_retrieval",
|
||||
session.vim, result)
|
||||
@ -210,7 +212,7 @@ class VsphereOperations(object):
|
||||
|
||||
if samples_count > 0:
|
||||
for metric_series in entity_metric.value:
|
||||
stat_value = metric_series.value[samples_count - 1]
|
||||
stat_value = float(metric_series.value[samples_count - 1])
|
||||
device_id = metric_series.id.instance
|
||||
stat_values[device_id] = stat_value
|
||||
|
||||
|
@ -43,7 +43,7 @@ class TestVsphereInspection(test.BaseTestCase):
|
||||
fake_instance_moid = 'fake_instance_moid'
|
||||
fake_instance_id = 'fake_instance_id'
|
||||
fake_perf_counter_id = 'fake_perf_counter_id'
|
||||
fake_memory_value = 1048576.0
|
||||
fake_memory_value = 1024.0
|
||||
fake_stat = virt_inspector.MemoryUsageStats(usage=1.0)
|
||||
|
||||
def construct_mock_instance_object(fake_instance_id):
|
||||
@ -77,7 +77,7 @@ class TestVsphereInspection(test.BaseTestCase):
|
||||
self._inspector._ops.get_perf_counter_id.return_value = \
|
||||
fake_perf_counter_id
|
||||
self._inspector._ops.query_vm_aggregate_stats.return_value = \
|
||||
fake_cpu_util_value
|
||||
fake_cpu_util_value * 100
|
||||
cpu_util_stat = self._inspector.inspect_cpu_util(fake_instance)
|
||||
self.assertEqual(fake_stat, cpu_util_stat)
|
||||
|
||||
@ -88,12 +88,12 @@ class TestVsphereInspection(test.BaseTestCase):
|
||||
vnic1 = "vnic-1"
|
||||
vnic2 = "vnic-2"
|
||||
counter_name_to_id_map = {
|
||||
vsphere_inspector.VC_NETWORK_RX_BYTES_COUNTER: 1,
|
||||
vsphere_inspector.VC_NETWORK_TX_BYTES_COUNTER: 2
|
||||
vsphere_inspector.VC_NETWORK_RX_COUNTER: 1,
|
||||
vsphere_inspector.VC_NETWORK_TX_COUNTER: 2
|
||||
}
|
||||
counter_id_to_stats_map = {
|
||||
1: {vnic1: 1000.0, vnic2: 3000.0},
|
||||
2: {vnic1: 2000.0, vnic2: 4000.0},
|
||||
1: {vnic1: 1, vnic2: 3},
|
||||
2: {vnic1: 2, vnic2: 4},
|
||||
}
|
||||
|
||||
def get_counter_id_side_effect(counter_full_name):
|
||||
@ -115,8 +115,8 @@ class TestVsphereInspection(test.BaseTestCase):
|
||||
|
||||
# validate result
|
||||
expected_stats = {
|
||||
vnic1: virt_inspector.InterfaceRateStats(1.0, 2.0),
|
||||
vnic2: virt_inspector.InterfaceRateStats(3.0, 4.0)
|
||||
vnic1: virt_inspector.InterfaceRateStats(1024, 2048),
|
||||
vnic2: virt_inspector.InterfaceRateStats(3072, 4096)
|
||||
}
|
||||
|
||||
for vnic, rates_info in result:
|
||||
|
Loading…
x
Reference in New Issue
Block a user