Merge pull request #172 from mattkirby/pooler_44

(POOLER-44) Fix vmpooler.migrate reference
This commit is contained in:
wayne 2016-11-23 13:34:10 -08:00 committed by GitHub
commit ac55bbbc4e
2 changed files with 14 additions and 12 deletions

View file

@ -413,7 +413,7 @@ module Vmpooler
def check_disk_queue
$logger.log('d', "[*] [disk_manager] starting worker thread")
$vsphere['disk_manager'] ||= Vmpooler::VsphereHelper.new $config[:vsphere]
$vsphere['disk_manager'] ||= Vmpooler::VsphereHelper.new $config[:vsphere], $metrics
$threads['disk_manager'] = Thread.new do
loop do
@ -439,7 +439,7 @@ module Vmpooler
def check_snapshot_queue
$logger.log('d', "[*] [snapshot_manager] starting worker thread")
$vsphere['snapshot_manager'] ||= Vmpooler::VsphereHelper.new $config[:vsphere]
$vsphere['snapshot_manager'] ||= Vmpooler::VsphereHelper.new $config[:vsphere], $metrics
$threads['snapshot_manager'] = Thread.new do
loop do
@ -506,7 +506,7 @@ module Vmpooler
if host == parent_host
$logger.log('s', "[ ] [#{pool}] No migration required for '#{vm}' running on #{parent_host_name}")
else
finish = migrate_vm_and_record_timing(vm_object, vm, host, vsphere)
finish = migrate_vm_and_record_timing(vm_object, vm, pool, host, parent_host_name, host_name, vsphere)
$logger.log('s', "[>] [#{pool}] '#{vm}' migrated from #{parent_host_name} to #{host_name} in #{finish} seconds")
end
remove_vmpooler_migration_vm(pool, vm)
@ -531,11 +531,13 @@ module Vmpooler
end
end
def migrate_vm_and_record_timing(vm_object, vm_name, host, vsphere)
def migrate_vm_and_record_timing(vm_object, vm_name, pool, host, source_host_name, dest_host_name, vsphere)
start = Time.now
vsphere.migrate_vm_host(vm_object, host)
finish = '%.2f' % (Time.now - start)
$metrics.timing("migrate.#{vm_name}", finish)
$metrics.timing("migrate.#{pool}", finish)
$metrics.increment("migrate_from.#{source_host_name}")
$metrics.increment("migrate_to.#{dest_host_name}")
checkout_to_migration = '%.2f' % (Time.now - Time.parse($redis.hget("vmpooler__vm__#{vm_name}", 'checkout')))
$redis.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish)
$redis.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration)
@ -545,7 +547,7 @@ module Vmpooler
def check_pool(pool)
$logger.log('d', "[*] [#{pool['name']}] starting worker thread")
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config[:vsphere]
$vsphere[pool['name']] ||= Vmpooler::VsphereHelper.new $config[:vsphere], $metrics
$threads[pool['name']] = Thread.new do
loop do

View file

@ -6,16 +6,16 @@ module Vmpooler
DISK_TYPE = 'thin'
DISK_MODE = 'persistent'
def initialize(credentials)
def initialize(credentials, metrics)
$credentials = credentials
$metrics = metrics
end
def ensure_connected(connection, credentials)
begin
connection.serviceInstance.CurrentTime
rescue
connect_to_vsphere $credentials
end
connection.serviceInstance.CurrentTime
rescue
$metrics.increment("connect.open")
connect_to_vsphere $credentials
end
def connect_to_vsphere(credentials)