2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-17 21:23:18 +00:00

Implement '+' plus operator in noderange

+ operator generates an 'end node' from the nodename to the left
and adding the specified value to the number at the end.  This is
as restrictive as the xCAT 2.x perl implementation to ensure best
compatibility.
This commit is contained in:
Jarrod Johnson 2015-03-24 16:12:23 -04:00
parent a85ffa8f8b
commit 13962ec69d

View File

@ -126,7 +126,6 @@ class NodeRange(object):
if self.cfm.is_node(entname):
return set([entname])
if self.cfm.is_nodegroup(entname):
nodes = set([])
grpcfg = self.cfm.get_nodegroup_attributes(entname)
nodes = grpcfg['nodes']
if 'noderange' in grpcfg and grpcfg['noderange']:
@ -171,7 +170,24 @@ class NodeRange(object):
raise Exception('Verification configmanager required')
return set(self.cfm.filter_nodenames(nameexpression, filternodes))
elif '+' in element:
raise Exception('TODO: plus range')
element, increment = element.split('+')
try:
nodename, domain = element.split('.')
except ValueError:
nodename = element
domain = ''
increment = int(increment)
elembits = _numextractor.parseString(nodename).asList()
endnum = str(int(elembits[-1]) + increment)
left = ''.join(elembits)
if domain:
left += '.' + domain
right = ''.join(elembits[:-1])
right += endnum
if domain:
right += '.' + domain
nrange = left + ':' + right
return self.expandrange(nrange, ':')
if self.cfm is None:
return set([element])
raise Exception(element + ' not a recognized node, group, or alias')