diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 1bb86441..d27b5c77 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -143,6 +143,10 @@ noderesources = { 'pluginattrs': ['hardwaremanagement.method'], 'default': 'ipmi', }), + 'domain_name': PluginRoute({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }), } }, '_console': { diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 0c66956b..d84775fd 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[: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' diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index cd739759..b6c148a6 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -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