Added platform-dependent selection of the etherwake program name: ether-wake for RedHat and CentOS, etherwake for others
This commit is contained in:
parent
86d5ffb59e
commit
620425f10d
@ -84,6 +84,13 @@ from neat.db_utils import *
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
import platform
|
||||
dist = platform.linux_distribution(full_distribution_name=0)[0]
|
||||
if dist in ['redhat', 'centos']:
|
||||
etherwake = 'ether-wake'
|
||||
else:
|
||||
etherwake = 'etherwake'
|
||||
|
||||
|
||||
ERRORS = {
|
||||
400: 'Bad input parameter: incorrect or missing parameters',
|
||||
@ -857,7 +864,8 @@ def switch_hosts_on(db, ether_wake_interface, host_macs, hosts):
|
||||
for host in hosts:
|
||||
if host not in host_macs:
|
||||
host_macs[host] = host_mac(host)
|
||||
command = 'ether-wake -i {0} {1}'.format(
|
||||
command = '{0} -i {1} {2}'.format(
|
||||
etherwake,
|
||||
ether_wake_interface,
|
||||
host_macs[host])
|
||||
if log.isEnabledFor(logging.DEBUG):
|
||||
|
@ -381,8 +381,12 @@ class GlobalManager(TestCase):
|
||||
db = db_utils.init_db('sqlite:///:memory:')
|
||||
|
||||
with MockTransaction:
|
||||
expect(subprocess).call('ether-wake -i eth0 mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac2', shell=True).once()
|
||||
expect(subprocess).call(any_of(['ether-wake -i eth0 mac1',
|
||||
'etherwake -i eth0 mac1']),
|
||||
shell=True).once()
|
||||
expect(subprocess).call(any_of(['ether-wake -i eth0 mac2',
|
||||
'etherwake -i eth0 mac2']),
|
||||
shell=True).once()
|
||||
expect(manager).host_mac('h1').and_return('mac1').once()
|
||||
expect(db).insert_host_states({
|
||||
'h1': 1,
|
||||
@ -390,8 +394,12 @@ class GlobalManager(TestCase):
|
||||
manager.switch_hosts_on(db, 'eth0', {'h2': 'mac2'}, ['h1', 'h2'])
|
||||
|
||||
with MockTransaction:
|
||||
expect(subprocess).call('ether-wake -i eth0 mac1', shell=True).once()
|
||||
expect(subprocess).call('ether-wake -i eth0 mac2', shell=True).once()
|
||||
expect(subprocess).call(any_of(['ether-wake -i eth0 mac1',
|
||||
'etherwake -i eth0 mac1']),
|
||||
shell=True).once()
|
||||
expect(subprocess).call(any_of(['ether-wake -i eth0 mac2',
|
||||
'etherwake -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user