2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-12-04 18:44:41 +00:00

Implement update network configuration

This commit is contained in:
Juliana Motira 2015-09-17 08:41:04 -03:00
parent e207940e50
commit 655a0b4d17
2 changed files with 42 additions and 3 deletions

View File

@ -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 inputdata:
raise exc.InvalidArgumentException()
@ -578,6 +581,39 @@ 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 BootDevice(ConfluentChoiceMessage):
valid_values = set([
'network',

View File

@ -437,9 +437,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