Added an ether_wake_interface config option, added it as an -i parameter to ether-wake
This commit is contained in:
parent
31113db2e6
commit
e7b4a2c499
@ -99,6 +99,9 @@ network_migration_bandwidth = 10
|
||||
# compute_user must have permissions to execute this command
|
||||
sleep_command = pm-suspend
|
||||
|
||||
# The network interface to send a magic packet from using ether-wake
|
||||
ether_wake_interface = eth0
|
||||
|
||||
# The fully qualified name of a Python factory function that returns a
|
||||
# function implementing an underload detection algorithm
|
||||
#algorithm_underload_detection_factory = neat.locals.underload.trivial.threshold_factory
|
||||
|
@ -59,6 +59,7 @@ REQUIRED_FIELDS = [
|
||||
'compute_user',
|
||||
'compute_password',
|
||||
'sleep_command',
|
||||
'ether_wake_interface',
|
||||
'network_migration_bandwidth',
|
||||
'algorithm_underload_detection_factory',
|
||||
'algorithm_underload_detection_parameters',
|
||||
|
@ -164,6 +164,7 @@ def start():
|
||||
|
||||
state = init_state(config)
|
||||
switch_hosts_on(state['db'],
|
||||
config['ether_wake_interface'],
|
||||
state['host_macs'],
|
||||
state['compute_hosts'])
|
||||
|
||||
@ -571,6 +572,7 @@ def execute_overload(config, state, host, vm_uuids):
|
||||
set(placement.values())))
|
||||
if hosts_to_activate:
|
||||
switch_hosts_on(state['db'],
|
||||
config['ether_wake_interface'],
|
||||
state['host_macs'],
|
||||
hosts_to_activate)
|
||||
log.info('Started overload VM migrations')
|
||||
@ -789,12 +791,15 @@ def switch_hosts_off(db, sleep_command, hosts):
|
||||
|
||||
|
||||
@contract
|
||||
def switch_hosts_on(db, host_macs, hosts):
|
||||
def switch_hosts_on(db, ether_wake_interface, host_macs, hosts):
|
||||
""" Switch hosts to the active mode.
|
||||
|
||||
:param db: The database object.
|
||||
:type db: Database
|
||||
|
||||
:param ether_wake_interface: An interface to send a magic packet.
|
||||
:type ether_wake_interface: str
|
||||
|
||||
:param host_macs: A dict of host names to mac addresses.
|
||||
:type host_macs: dict(str: str)
|
||||
|
||||
@ -804,7 +809,9 @@ def switch_hosts_on(db, host_macs, hosts):
|
||||
for host in hosts:
|
||||
if host not in host_macs:
|
||||
host_macs[host] = host_mac(host)
|
||||
command = 'ether-wake {0}'.format(host_macs[host])
|
||||
command = 'ether-wake -i {0} {1}'.format(
|
||||
ether_wake_interface,
|
||||
host_macs[host])
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
log.debug('Calling: %s', command)
|
||||
subprocess.call(command, shell=True)
|
||||
|
@ -168,7 +168,8 @@ class GlobalManager(TestCase):
|
||||
'log_directory': 'dir',
|
||||
'log_level': 2,
|
||||
'global_manager_host': 'localhost',
|
||||
'global_manager_port': 8080}
|
||||
'global_manager_port': 8080,
|
||||
'ether_wake_interface': 'eth0'}
|
||||
paths = [manager.DEFAILT_CONFIG_PATH, manager.CONFIG_PATH]
|
||||
fields = manager.REQUIRED_FIELDS
|
||||
expect(manager).read_and_validate_config(paths, fields). \
|
||||
@ -176,7 +177,7 @@ class GlobalManager(TestCase):
|
||||
expect(common).init_logging('dir', 'global-manager.log', 2).once()
|
||||
expect(manager).init_state(config). \
|
||||
and_return(state).once()
|
||||
expect(manager).switch_hosts_on(db, {}, hosts).once()
|
||||
expect(manager).switch_hosts_on(db, 'eth0', {}, hosts).once()
|
||||
expect(bottle).app().and_return(app).once()
|
||||
expect(bottle).run(host='localhost', port=8080).once()
|
||||
manager.start()
|
||||
@ -380,20 +381,20 @@ class GlobalManager(TestCase):
|
||||
db = db_utils.init_db('sqlite:///:memory:')
|
||||
|
||||
with MockTransaction:
|
||||
expect(subprocess).call('ether-wake mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake mac2', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac2', shell=True).once()
|
||||
expect(manager).host_mac('h1').and_return('mac1').once()
|
||||
expect(db).insert_host_states({
|
||||
'h1': 1,
|
||||
'h2': 1}).once()
|
||||
manager.switch_hosts_on(db, {'h2': 'mac2'}, ['h1', 'h2'])
|
||||
manager.switch_hosts_on(db, 'eth0', {'h2': 'mac2'}, ['h1', 'h2'])
|
||||
|
||||
with MockTransaction:
|
||||
expect(subprocess).call('ether-wake mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake mac2', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac2', shell=True).once()
|
||||
expect(manager).host_mac('h1').and_return('mac1').once()
|
||||
expect(manager).host_mac('h2').and_return('mac2').once()
|
||||
expect(db).insert_host_states({
|
||||
'h1': 1,
|
||||
'h2': 1}).once()
|
||||
manager.switch_hosts_on(db, {}, ['h1', 'h2'])
|
||||
manager.switch_hosts_on(db, 'eth0', {}, ['h1', 'h2'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user