mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-17 21:23:18 +00:00
Implement domain name command
This commit is contained in:
parent
e207940e50
commit
b1b4ee4634
@ -143,6 +143,10 @@ noderesources = {
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
'domain_name': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
}
|
||||
},
|
||||
'_console': {
|
||||
|
@ -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[:3] == ['configuration', 'management_controller', 'domain_name']
|
||||
and operation != 'retrieve'):
|
||||
return InputDomainName(path, nodes, inputdata)
|
||||
elif inputdata:
|
||||
raise exc.InvalidArgumentException()
|
||||
|
||||
@ -578,6 +581,25 @@ class InputMCI(ConfluentInputMessage):
|
||||
return self.inputbynode[node]['identifier']
|
||||
|
||||
|
||||
class InputDomainName(ConfluentInputMessage):
|
||||
def __init__(self, path, nodes, inputdata):
|
||||
self.inputbynode = {}
|
||||
self.stripped = False
|
||||
if not inputdata or 'domain_name' not in inputdata:
|
||||
raise exc.InvalidArgumentException('missing input data')
|
||||
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')
|
||||
for node in nodes:
|
||||
self.inputbynode[node] = inputdata['domain_name']
|
||||
|
||||
def domain_name(self, node):
|
||||
return self.inputbynode[node]
|
||||
|
||||
class BootDevice(ConfluentChoiceMessage):
|
||||
valid_values = set([
|
||||
'network',
|
||||
@ -954,6 +976,18 @@ class MCI(ConfluentMessage):
|
||||
self.kvpairs = {name: kv}
|
||||
|
||||
|
||||
class DomainName(ConfluentMessage):
|
||||
def __init__(self, name=None, dn=None):
|
||||
self.notnode = name is None
|
||||
self.desc = 'BMC domain name'
|
||||
|
||||
kv = {'domain_name': {'value': dn}}
|
||||
if self.notnode:
|
||||
self.kvpairs = kv
|
||||
else:
|
||||
self.kvpairs = {name: kv}
|
||||
|
||||
|
||||
class CryptedAttributes(Attributes):
|
||||
defaulttype = 'password'
|
||||
|
||||
|
@ -371,6 +371,8 @@ class IpmiHandler(object):
|
||||
return self.handle_reset()
|
||||
elif self.element[1:3] == ['management_controller', 'identifier']:
|
||||
return self.handle_identifier()
|
||||
elif self.element[1:3] == ['management_controller', 'domain_name']:
|
||||
return self.handle_domain_name()
|
||||
raise Exception('Not implemented')
|
||||
|
||||
def decode_alert(self):
|
||||
@ -762,6 +764,16 @@ class IpmiHandler(object):
|
||||
self.ipmicmd.set_mci(mci)
|
||||
return
|
||||
|
||||
def handle_domain_name(self):
|
||||
if 'read' == self.op:
|
||||
dn = self.ipmicmd.get_domain_name()
|
||||
self.output.put(msg.DomainName(self.node, dn))
|
||||
return
|
||||
elif 'update' == self.op:
|
||||
dn = self.inputdata.domain_name(self.node)
|
||||
self.ipmicmd.set_domain_name(dn)
|
||||
return
|
||||
|
||||
def _str_health(health):
|
||||
if health == 'unknown':
|
||||
return health
|
||||
|
Loading…
x
Reference in New Issue
Block a user