diff --git a/confluent_server/confluent/discovery/handlers/tsm.py b/confluent_server/confluent/discovery/handlers/tsm.py index 50747404..82365a7e 100644 --- a/confluent_server/confluent/discovery/handlers/tsm.py +++ b/confluent_server/confluent/discovery/handlers/tsm.py @@ -19,6 +19,7 @@ import confluent.util as util import eventlet.support.greendns import json import urllib +getaddrinfo = eventlet.support.greendns.getaddrinfo webclient = eventlet.import_patched('pyghmi.util.webclient') @@ -137,6 +138,30 @@ class NodeHandler(generic.NodeHandler): 'ipv4_enable': 1, 'ipv6_enable': 1, 'uncheckedipv4lanEnable': 0, 'uncheckedipv6lanEnable': 0, 'checkedipv4lanEnable': 1, 'checkedipv6lanEnable': 1}) + if ('hardwaremanagement.manager' in cd and + cd['hardwaremanagement.manager']['value'] and + not cd['hardwaremanagement.manager']['value'].startswith( + 'fe80::')): + newip = cd['hardwaremanagement.manager']['value'] + newipinfo = getaddrinfo(newip, 0)[0] + newip = newipinfo[-1][0] + if ':' in newip: + raise exc.NotImplementedException('IPv6 remote config TODO') + currnet = wc.grab_json_response('/api/settings/network') + for net in currnet: + if net['channel_number'] == self.channel: + # we have found the interface to potentially manipulate + if net['ipv4_address'] != newip: + netconfig = netutil.get_nic_config(self.configmanager, nodename, ip=newip) + newmask = netutil.cidr_to_mask(netconfig['prefix']) + net['ipv4_address'] = newip + net['ipv4_subnet'] = newmask + if netconfig['ipv4_gateway']: + net['ipv4_gateway'] = netconfig['ipv4_gateway'] + net['ipv4_dhcp_enable'] = 0 + rsp, status = wc.grab_json_response_with_status( + '/api/settings/network/{0}'.format(net['id']), net, method='PUT') + break rsp, status = wc.grab_json_response_with_status('/api/session', method='DELETE')