Fix HIMN eth to eth9
This commit is contained in:
parent
7a49c5b546
commit
9e8601d90b
|
@ -92,32 +92,31 @@ def get_endpoints(astute):
|
|||
return endpoints
|
||||
|
||||
|
||||
def init_eth():
|
||||
def init_eth(eth):
|
||||
"""Initialize the net interface connected to HIMN
|
||||
|
||||
Returns:
|
||||
the IP addresses of local host and XenServer.
|
||||
"""
|
||||
for eth in netifaces.interfaces():
|
||||
if not os.path.exists('/var/lib/dhcp/dhclient.%s.leases' % eth):
|
||||
execute('dhclient', eth)
|
||||
fname = '/etc/network/interfaces.d/ifcfg-' + eth
|
||||
s = 'auto {eth}\niface {eth} inet dhcp'.format(eth=eth)
|
||||
with open(fname, 'w') as f:
|
||||
f.write(s)
|
||||
info('%s created' % fname)
|
||||
execute('ifdown', eth)
|
||||
execute('ifup', eth)
|
||||
if not os.path.exists('/var/lib/dhcp/dhclient.%s.leases' % eth):
|
||||
execute('dhclient', eth)
|
||||
fname = '/etc/network/interfaces.d/ifcfg-' + eth
|
||||
s = 'auto {eth}\niface {eth} inet dhcp'.format(eth=eth)
|
||||
with open(fname, 'w') as f:
|
||||
f.write(s)
|
||||
info('%s created' % fname)
|
||||
execute('ifdown', eth)
|
||||
execute('ifup', eth)
|
||||
|
||||
addr = netifaces.ifaddresses(eth).get(2)
|
||||
if addr:
|
||||
addr_local = addr[0]['addr']
|
||||
addr_remote = '.'.join(addr_local.split('.')[:-1] + ['1'])
|
||||
addr = netifaces.ifaddresses(eth).get(2)
|
||||
if addr:
|
||||
addr_local = addr[0]['addr']
|
||||
addr_remote = '.'.join(addr_local.split('.')[:-1] + ['1'])
|
||||
if '169.254.0.1' == addr_remote:
|
||||
info('HIMN on %s : %s' % (eth, addr_remote))
|
||||
if '169.254.0.1' == addr_remote:
|
||||
return eth, addr_local, addr_remote
|
||||
return addr_local, addr_remote
|
||||
warning('HIMN failed to get IP address from XenServer')
|
||||
return None, None, None
|
||||
return None, None
|
||||
|
||||
|
||||
def install_xenapi_sdk():
|
||||
|
@ -215,7 +214,8 @@ if __name__ == '__main__':
|
|||
if astute:
|
||||
username, password = get_access(astute, ACCESS_SECTION)
|
||||
endpoints = get_endpoints(astute)
|
||||
eth, himn_local, himn_xs = init_eth()
|
||||
eth = 'eth9'
|
||||
himn_local, himn_xs = init_eth(eth)
|
||||
if username and password and endpoints and himn_local and himn_xs:
|
||||
route_to_compute(
|
||||
endpoints, himn_xs, himn_local, username, password)
|
||||
|
|
Loading…
Reference in New Issue