mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-22 09:32:21 +00:00
Add hostname to api
The hostname of the BMC is added to the api.
This commit is contained in:
parent
f88e0bca4c
commit
f97c39cea4
@ -154,6 +154,10 @@ def _init_core():
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
'hostname': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
}),
|
||||
'identifier': PluginRoute({
|
||||
'pluginattrs': ['hardwaremanagement.method'],
|
||||
'default': 'ipmi',
|
||||
|
@ -394,9 +394,12 @@ def get_input_message(path, operation, inputdata, nodes=None, multinode=False,
|
||||
elif (path[:3] == ['configuration', 'management_controller', 'reset']
|
||||
and operation != 'retrieve'):
|
||||
return InputBMCReset(path, nodes, inputdata)
|
||||
elif (path[:3] == ['configuration', 'management_controller', 'identifier']
|
||||
elif (path[:2] == ['configuration', 'management_controller', 'identifier']
|
||||
and operation != 'retrieve'):
|
||||
return InputMCI(path, nodes, inputdata)
|
||||
elif (path[:2] == ['configuration', 'management_controller', 'hostname']
|
||||
and operation != 'retrieve'):
|
||||
return InputHostname(path, nodes, inputdata, configmanager)
|
||||
elif (path[:4] == ['configuration', 'management_controller',
|
||||
'net_interfaces', 'management'] and operation != 'retrieve'):
|
||||
return InputNetworkConfiguration(path, nodes, inputdata,
|
||||
@ -719,6 +722,25 @@ class InputBMCReset(ConfluentInputMessage):
|
||||
return self.inputbynode[node]
|
||||
|
||||
|
||||
|
||||
class InputHostname(ConfluentInputMessage):
|
||||
def __init__(self, path, nodes, inputdata, configmanager):
|
||||
self.inputbynode = {}
|
||||
self.stripped = False
|
||||
if not inputdata or 'hostname' not in inputdata:
|
||||
raise exc.InvalidArgumentException('missing hostname attribute')
|
||||
if nodes is None:
|
||||
raise exc.InvalidArgumentException(
|
||||
'This only supports per-node input')
|
||||
for expanded in configmanager.expand_attrib_expression(
|
||||
nodes, inputdata['hostname']):
|
||||
node, value = expanded
|
||||
self.inputbynode[node] = value
|
||||
|
||||
def hostname(self, node):
|
||||
return self.inputbynode[node]
|
||||
|
||||
|
||||
class InputMCI(ConfluentInputMessage):
|
||||
def __init__(self, path, nodes, inputdata):
|
||||
self.inputbynode = {}
|
||||
@ -1298,6 +1320,17 @@ class MCI(ConfluentMessage):
|
||||
self.kvpairs = {name: kv}
|
||||
|
||||
|
||||
class Hostname(ConfluentMessage):
|
||||
def __init__(self, name=None, hostname=None):
|
||||
self.notnode = name is None
|
||||
self.desc = 'BMC hostname'
|
||||
|
||||
kv = {'hostname': {'value': hostname}}
|
||||
if self.notnode:
|
||||
self.kvpairs = kv
|
||||
else:
|
||||
self.kvpairs = {name: kv}
|
||||
|
||||
class DomainName(ConfluentMessage):
|
||||
def __init__(self, name=None, dn=None):
|
||||
self.notnode = name is None
|
||||
|
@ -518,6 +518,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', 'hostname']:
|
||||
return self.handle_hostname()
|
||||
elif self.element[1:3] == ['management_controller', 'domain_name']:
|
||||
return self.handle_domain_name()
|
||||
elif self.element[1:3] == ['management_controller', 'ntp']:
|
||||
@ -986,6 +988,16 @@ class IpmiHandler(object):
|
||||
self.ipmicmd.set_mci(mci)
|
||||
return
|
||||
|
||||
def handle_hostname(self):
|
||||
if 'read' == self.op:
|
||||
hostname = self.ipmicmd.get_hostname()
|
||||
self.output.put(msg.Hostname(self.node, hostname))
|
||||
return
|
||||
elif 'update' == self.op:
|
||||
hostname = self.inputdata.hostname(self.node)
|
||||
self.ipmicmd.set_hostname(hostname)
|
||||
return
|
||||
|
||||
def handle_domain_name(self):
|
||||
if 'read' == self.op:
|
||||
dn = self.ipmicmd.get_domain_name()
|
||||
|
Loading…
Reference in New Issue
Block a user