From 13962ec69daa70fdaebb3ef2ae9c2278f48b2fcd Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 24 Mar 2015 16:12:23 -0400 Subject: [PATCH] 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. --- confluent_server/confluent/noderange.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/noderange.py b/confluent_server/confluent/noderange.py index 84532174..22c80a4e 100644 --- a/confluent_server/confluent/noderange.py +++ b/confluent_server/confluent/noderange.py @@ -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')