Added a configuration option to specify whether to use block migration
This commit is contained in:
parent
cb60d4b797
commit
f4cd41fd81
@ -92,6 +92,9 @@ compute_user = neat
|
|||||||
# hosts to switch them into the sleep mode
|
# hosts to switch them into the sleep mode
|
||||||
compute_password = neatpassword
|
compute_password = neatpassword
|
||||||
|
|
||||||
|
# Whether to use block migration (includes disk migration)
|
||||||
|
block_migration = False
|
||||||
|
|
||||||
# The network bandwidth in MB/s available for VM migration
|
# The network bandwidth in MB/s available for VM migration
|
||||||
network_migration_bandwidth = 10
|
network_migration_bandwidth = 10
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ REQUIRED_FIELDS = [
|
|||||||
'compute_password',
|
'compute_password',
|
||||||
'sleep_command',
|
'sleep_command',
|
||||||
'ether_wake_interface',
|
'ether_wake_interface',
|
||||||
|
'block_migration',
|
||||||
'network_migration_bandwidth',
|
'network_migration_bandwidth',
|
||||||
'algorithm_underload_detection_factory',
|
'algorithm_underload_detection_factory',
|
||||||
'algorithm_underload_detection_parameters',
|
'algorithm_underload_detection_parameters',
|
||||||
|
@ -435,7 +435,8 @@ def execute_underload(config, state, host):
|
|||||||
migrate_vms(state['db'],
|
migrate_vms(state['db'],
|
||||||
state['nova'],
|
state['nova'],
|
||||||
config['vm_instance_directory'],
|
config['vm_instance_directory'],
|
||||||
placement)
|
placement,
|
||||||
|
bool(config['block_migration']))
|
||||||
log.info('Completed underload VM migrations')
|
log.info('Completed underload VM migrations')
|
||||||
|
|
||||||
if hosts_to_deactivate:
|
if hosts_to_deactivate:
|
||||||
@ -595,7 +596,8 @@ def execute_overload(config, state, host, vm_uuids):
|
|||||||
migrate_vms(state['db'],
|
migrate_vms(state['db'],
|
||||||
state['nova'],
|
state['nova'],
|
||||||
config['vm_instance_directory'],
|
config['vm_instance_directory'],
|
||||||
placement)
|
placement,
|
||||||
|
bool(config['block_migration']))
|
||||||
log.info('Completed overload VM migrations')
|
log.info('Completed overload VM migrations')
|
||||||
log.info('Completed processing an overload request')
|
log.info('Completed processing an overload request')
|
||||||
return state
|
return state
|
||||||
@ -729,7 +731,7 @@ def vm_hostname(vm):
|
|||||||
|
|
||||||
|
|
||||||
@contract
|
@contract
|
||||||
def migrate_vms(db, nova, vm_instance_directory, placement):
|
def migrate_vms(db, nova, vm_instance_directory, placement, block_migration):
|
||||||
""" Synchronously live migrate a set of VMs.
|
""" Synchronously live migrate a set of VMs.
|
||||||
|
|
||||||
:param db: The database object.
|
:param db: The database object.
|
||||||
@ -743,6 +745,9 @@ def migrate_vms(db, nova, vm_instance_directory, placement):
|
|||||||
|
|
||||||
:param placement: A dict of VM UUIDs to host names.
|
:param placement: A dict of VM UUIDs to host names.
|
||||||
:type placement: dict(str: str)
|
:type placement: dict(str: str)
|
||||||
|
|
||||||
|
:param block_migration: Whether to use block migration.
|
||||||
|
:type block_migration: bool
|
||||||
"""
|
"""
|
||||||
retry_placement = {}
|
retry_placement = {}
|
||||||
vms = placement.keys()
|
vms = placement.keys()
|
||||||
@ -753,7 +758,8 @@ def migrate_vms(db, nova, vm_instance_directory, placement):
|
|||||||
for vm_pair in vm_pairs:
|
for vm_pair in vm_pairs:
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
for vm_uuid in vm_pair:
|
for vm_uuid in vm_pair:
|
||||||
migrate_vm(nova, vm_instance_directory, vm_uuid, placement[vm_uuid])
|
migrate_vm(nova, vm_instance_directory, vm_uuid,
|
||||||
|
placement[vm_uuid], block_migration)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
@ -790,11 +796,12 @@ def migrate_vms(db, nova, vm_instance_directory, placement):
|
|||||||
if log.isEnabledFor(logging.INFO):
|
if log.isEnabledFor(logging.INFO):
|
||||||
log.info('Retrying the following migrations: %s',
|
log.info('Retrying the following migrations: %s',
|
||||||
str(retry_placement))
|
str(retry_placement))
|
||||||
migrate_vms(db, nova, vm_instance_directory, retry_placement)
|
migrate_vms(db, nova, vm_instance_directory,
|
||||||
|
retry_placement, block_migration)
|
||||||
|
|
||||||
|
|
||||||
@contract
|
@contract
|
||||||
def migrate_vm(nova, vm_instance_directory, vm, host):
|
def migrate_vm(nova, vm_instance_directory, vm, host, block_migration):
|
||||||
""" Live migrate a VM.
|
""" Live migrate a VM.
|
||||||
|
|
||||||
:param nova: A Nova client.
|
:param nova: A Nova client.
|
||||||
@ -808,11 +815,14 @@ def migrate_vm(nova, vm_instance_directory, vm, host):
|
|||||||
|
|
||||||
:param host: The name of the destination host.
|
:param host: The name of the destination host.
|
||||||
:type host: str
|
:type host: str
|
||||||
|
|
||||||
|
:param block_migration: Whether to use block migration.
|
||||||
|
:type block_migration: bool
|
||||||
"""
|
"""
|
||||||
# To avoid problems with migration, need the following:
|
# To avoid problems with migration, need the following:
|
||||||
subprocess.call('chown -R nova:nova ' + vm_instance_directory,
|
subprocess.call('chown -R nova:nova ' + vm_instance_directory,
|
||||||
shell=True)
|
shell=True)
|
||||||
nova.servers.live_migrate(vm, host, False, False)
|
nova.servers.live_migrate(vm, host, block_migration, False)
|
||||||
if log.isEnabledFor(logging.INFO):
|
if log.isEnabledFor(logging.INFO):
|
||||||
log.info('Started migration of VM %s to %s', vm, host)
|
log.info('Started migration of VM %s to %s', vm, host)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user