2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Tolerate '/' in hardwaremanagement.manager

This paves the way to allowing CIDR syntax to
indicate prefix length for remote XCCs
This commit is contained in:
Jarrod Johnson 2022-07-21 09:54:00 -04:00
parent 79421a724f
commit 2256b341b9
16 changed files with 23 additions and 2 deletions

View File

@ -79,6 +79,8 @@ def collect_attribute_data(databynode, node):
xcatattrs['groups'] = ','.join(data.get('groups', []))
xcatattrs['bmc'] = data.get('hardwaremanagement.manager', {}).get(
'value', None)
if xcatattrs['bmc']:
xcatattrs['bmc'] = xcatattrs['bmc'].split('/', 1)[0]
xcatattrs['mpa'] = data.get('enclosure.manager', {}).get(
'value', None)
xcatattrs['slotid'] = data.get('enclosure.bay', {}).get(

View File

@ -380,7 +380,9 @@ node = {
# },
'hardwaremanagement.manager': {
'description': 'The management address dedicated to this node. This '
'is the address of, for example, the Lenovo IMM.',
'is the address of, for example, the Lenovo XCC. It may optionally '
'include /<prefixlen> CIDR suffix to indicate subnet length, which is '
'autodetected by default where possible.',
},
'hardwaremanagement.method': {
'description': 'The method used to perform operations such as power '

View File

@ -820,6 +820,7 @@ def get_chained_smm_name(nodename, cfg, handler, nl=None, checkswitch=True):
smmaddr = cd.get(nodename, {}).get('hardwaremanagement.manager', {}).get('value', None)
if not smmaddr:
return None, False
smmaddr = smmaddr.split('/', 1)[0]
if pkey:
cv = util.TLSCertVerifier(
cfg, nodename, 'pubkeys.tls_hardwaremanager').verify_cert

View File

@ -160,6 +160,7 @@ class NodeHandler(generic.NodeHandler):
not cd['hardwaremanagement.manager']['value'].startswith(
'fe80::')):
newip = cd['hardwaremanagement.manager']['value']
newip = newip.split('/', 1)[0]
newipinfo = getaddrinfo(newip, 0)[0]
# This getaddrinfo is repeated in get_nic_config, could be
# optimized, albeit with a more convoluted api..

View File

@ -104,6 +104,8 @@ class NodeHandler(bmchandler.NodeHandler):
cd = cfg.get_node_attributes(
nodename, ['hardwaremanagement.manager'])
smmip = cd.get(nodename, {}).get('hardwaremanagement.manager', {}).get('value', None)
if smmip:
smmip = smmip.split('/', 1)[0]
if smmip and ':' not in smmip:
smmip = getaddrinfo(smmip, 0)[0]
smmip = smmip[-1][0]

View File

@ -198,6 +198,7 @@ class NodeHandler(generic.NodeHandler):
not cd['hardwaremanagement.manager']['value'].startswith(
'fe80::')):
newip = cd['hardwaremanagement.manager']['value']
newip = newip.split('/', 1)[0]
newipinfo = getaddrinfo(newip, 0)[0]
newip = newipinfo[-1][0]
if ':' in newip:
@ -234,9 +235,10 @@ def remote_nodecfg(nodename, cfm):
nodename, 'hardwaremanagement.manager')
ipaddr = cfg.get(nodename, {}).get('hardwaremanagement.manager', {}).get(
'value', None)
ipaddr = ipaddr.split('/', 1)[0]
ipaddr = getaddrinfo(ipaddr, 0)[0][-1]
if not ipaddr:
raise Excecption('Cannot remote configure a system without known '
raise Exception('Cannot remote configure a system without known '
'address')
info = {'addresses': [ipaddr]}
nh = NodeHandler(info, cfm)

View File

@ -555,6 +555,7 @@ class NodeHandler(immhandler.NodeHandler):
not cd['hardwaremanagement.manager']['value'].startswith(
'fe80::')):
newip = cd['hardwaremanagement.manager']['value']
newip = newip.split('/', 1)[0]
newipinfo = getaddrinfo(newip, 0)[0]
newip = newipinfo[-1][0]
if ':' in newip:
@ -599,6 +600,7 @@ def remote_nodecfg(nodename, cfm):
nodename, 'hardwaremanagement.manager')
ipaddr = cfg.get(nodename, {}).get('hardwaremanagement.manager', {}).get(
'value', None)
ipaddr = ipaddr.split('/', 1)[0]
ipaddr = getaddrinfo(ipaddr, 0)[0][-1]
if not ipaddr:
raise Excecption('Cannot remote configure a system without known '

View File

@ -687,6 +687,7 @@ def resourcehandler_backend(env, start_response):
start_response('404 Not Found', headers)
yield 'No hardwaremanagement.manager defined for node'
return
targip = targip.split('/', 1)[0]
funport = forwarder.get_port(targip, env['HTTP_X_FORWARDED_FOR'],
authorized['sessionid'])
host = env['HTTP_X_FORWARDED_HOST']

View File

@ -64,6 +64,7 @@ def node_by_manager(manager):
('hardwaremanagement.manager',))
for node in hmattribs:
currhm = hmattribs[node]['hardwaremanagement.manager']['value']
currhm = currhm.split('/', 1)[0]
if currhm in manageraddresses:
manager_to_nodemap[manager] = node
return node

View File

@ -46,6 +46,7 @@ def get_conn_params(node, configdata):
bmc = configdata['hardwaremanagement.manager']['value']
else:
bmc = node
bmc = bmc.split('/', 1)[0]
return {
'username': username,
'passphrase': passphrase,

View File

@ -114,6 +114,7 @@ class PDUClient(object):
'hardwaremanagement.manager', {}).get('value', None)
if not target:
target = self.node
target = target.split('/', 1)[0]
self._wc = WebConnection(target)
self.login(self.configmanager)
return self._wc

View File

@ -131,6 +131,7 @@ class PDUClient(object):
'hardwaremanagement.manager', {}).get('value', None)
if not target:
target = self.node
target = target.split('/', 1)[0]
self._wc = WebConnection(target)
self.login(self.configmanager)
return self._wc

View File

@ -44,6 +44,7 @@ class GeistClient(object):
'hardwaremanagement.manager', {}).get('value', None)
if not target:
target = self.node
target = target.split('/', 1)[0]
cv = util.TLSCertVerifier(
self.configmanager, self.node,
'pubkeys.tls_hardwaremanager').verify_cert

View File

@ -256,6 +256,7 @@ def get_conn_params(node, configdata):
bmc = configdata['hardwaremanagement.manager']['value']
else:
bmc = node
bmc = bmc.split('/', 1)[0]
if 'secret.ipmikg' in configdata:
kg = configdata['secret.ipmikg']['value']
else:

View File

@ -236,6 +236,7 @@ def get_conn_params(node, configdata):
bmc = configdata['hardwaremanagement.manager']['value']
else:
bmc = node
bmc = bmc.split('/', 1)[0]
# TODO(jbjohnso): check if the end has some number after a : without []
# for non default port
return {

View File

@ -204,6 +204,7 @@ def handle_request(env, start_response):
res['bmcvlan'] = vlan
bmcaddr = hmattr.get('hardwaremanagement.manager', {}).get('value',
None)
bmcaddr = bmcaddr.split('/', 1)[0]
bmcaddr = socket.getaddrinfo(bmcaddr, 0)[0]
bmcaddr = bmcaddr[-1][0]
if '.' in bmcaddr: # ipv4 is allowed