private static void DistributeValues(Dictionary <string, double> value, HostMetric host) { foreach (KeyValuePair <string, double> kvp in value) { string[] bits = kvp.Key.Split(':'); if (bits.Length < 4) { continue; } double currentValue = kvp.Value; string key = GetSetName(kvp.Key); if (bits[1].ToLowerInvariant() == "host") { host.Values[key] = currentValue; } else { VmMetric vm = host.GetVmByUuid(bits[2]); if (vm == null) { continue; } vm.Values[key] = currentValue; } } }
public double GetValue(IXenObject obj, string property) { Host host = GetHost(obj); if (host == null) { return(0d); } HostMetric host_resident; if (!_hosts.TryGetValue(host, out host_resident)) { return(0d); } if (obj is Host) { double result; if (host_resident.Values.TryGetValue(property, out result)) { return(result); } return(0d); } string uuid = Helpers.GetUuid(obj); VmMetric vm = host_resident.GetVmByUuid(uuid); if (vm != null) { double result; if (vm.Values.TryGetValue(property, out result)) { return(result); } } return(0d); }
public double GetValue(IXenObject obj, string property) { lock (_hostsLock) { Host host = GetHost(obj); if (host == null) { return(0d); } HostMetric host_resident; if (!_hosts.TryGetValue(host, out host_resident)) { return(0d); } if (obj is Host) { if (host_resident.Values.ContainsKey(property)) { return(host_resident.Values[property]); } return(0d); } string uuid = Helpers.GetUuid(obj); VmMetric vm = host_resident.GetVmByUuid(uuid); if (vm == null || !vm.Values.ContainsKey(property)) { return(0d); } return(vm.Values[property]); } }