diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 3b44b43a..e8e9a2e0 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -334,6 +334,9 @@ def get_input_message(path, operation, inputdata, nodes=None, multinode=False): elif (path[:3] == ['configuration', 'management_controller', 'identifier'] and operation != 'retrieve'): return InputMCI(path, nodes, inputdata) + elif (path[:4] == ['configuration', 'management_controller', + 'net_interfaces', 'management'] and operation != 'retrieve'): + return InputNetworkConfiguration(path, nodes, inputdata) elif (path[:3] == ['configuration', 'management_controller', 'domain_name'] and operation != 'retrieve'): return InputDomainName(path, nodes, inputdata) @@ -581,6 +584,38 @@ class InputMCI(ConfluentInputMessage): return self.inputbynode[node]['identifier'] +class InputNetworkConfiguration(ConfluentInputMessage): + def __init__(self, path, nodes, inputdata): + self.inputbynode = {} + self.stripped = False + if not inputdata: + raise exc.InvalidArgumentException('missing input data') + + if 'hw_addr' in inputdata: + raise exc.InvalidArgumentException('hw_addr is a read only field') + + if 'ipv4_address' not in inputdata: + inputdata['ipv4_address'] = None + + if 'ipv4_gateway' not in inputdata: + inputdata['ipv4_gateway'] = None + + if 'ipv4_configuration' in inputdata: + if inputdata['ipv4_configuration'].lower() not in ['dhcp','static']: + raise exc.InvalidArgumentException( + 'Unrecognized ipv4_configuration') + else: + inputdata['ipv4_configuration'] = None + if nodes is None: + raise exc.InvalidArgumentException( + 'This only supports per-node input') + for node in nodes: + self.inputbynode[node] = inputdata + + def netconfig(self, node): + return self.inputbynode[node] + + class InputDomainName(ConfluentInputMessage): def __init__(self, path, nodes, inputdata): self.inputbynode = {} @@ -590,7 +625,6 @@ class InputDomainName(ConfluentInputMessage): if len(inputdata['domain_name']) > 256: raise exc.InvalidArgumentException( 'identifier must be less than or = 256 chars') - if nodes is None: raise exc.InvalidArgumentException( 'This only supports per-node input') diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index b6c148a6..88d2c8d3 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -439,9 +439,12 @@ class IpmiHandler(object): ipv4cfgmethod=lancfg['ipv4_configuration'], hwaddr=lancfg['mac_address'] )) - else: - self.output.put(msg.ConfluentNodeError(self.node, - 'Not yet implemented')) + elif self.op == 'update': + config = self.inputdata.netconfig(self.node) + self.ipmicmd.set_net_configuration( + ipv4_address=config['ipv4_address'], + ipv4_configuration=config['ipv4_configuration'], + ipv4_gateway=config['ipv4_gateway']) def handle_users(self): # Create user