Updated the collector to store the adjusted CPU capacity of the host

This commit is contained in:
Anton Beloglazov 2012-10-19 17:19:56 +11:00
parent ab23b5bcec
commit 720f5b885c
2 changed files with 10 additions and 3 deletions

View File

@ -158,9 +158,13 @@ def init_state(config):
hostname = vir_connection.getHostname()
host_cpu_mhz, host_ram = get_host_characteristics(vir_connection)
physical_cpus = common.physical_cpu_count(vir_connection)
host_cpu_usable_by_vms = float(config['host_cpu_usable_by_vms'])
db = init_db(config['sql_connection'])
db.update_host(hostname, host_cpu_mhz, physical_cpus, host_ram)
db.update_host(hostname,
int(host_cpu_mhz * host_cpu_usable_by_vms),
physical_cpus,
host_ram)
return {'previous_time': 0.,
'previous_cpu_time': dict(),
@ -169,7 +173,7 @@ def init_state(config):
'hostname': hostname,
'host_cpu_overload_threshold':
float(config['host_cpu_overload_threshold']) * \
float(config['host_cpu_usable_by_vms']),
host_cpu_usable_by_vms,
'physical_cpus': physical_cpus,
'physical_cpu_mhz': host_cpu_mhz,
'physical_core_mhz': host_cpu_mhz / physical_cpus,

View File

@ -73,7 +73,10 @@ class Collector(TestCase):
db = mock('db')
expect(collector).init_db('db').and_return(db).once()
expect(db).update_host(hostname, mhz, physical_cpus, ram).once()
expect(db).update_host(hostname,
int(mhz * 0.75),
physical_cpus,
ram).once()
state = collector.init_state(config)
assert state['previous_time'] == 0