Fix for missing cfg01
It appears that cfg01 was needed after all. This commit
introduces changes needed to account for it. Since its
definition deviates from expected additional logic is required
for interim period.
PROD-26064
Change-Id: I918731c4121076cd52c2caf345ba7618419e8012
diff --git a/reclass/nodegenerator.py b/reclass/nodegenerator.py
index b161a33..bb21c48 100644
--- a/reclass/nodegenerator.py
+++ b/reclass/nodegenerator.py
@@ -122,7 +122,7 @@
update_dict(result, expansion)
return result
-
+external = {}
def get_configs(base, cluster):
configs_to_process, out = [], []
cluster_def = os.path.join(base, cluster)
@@ -130,6 +130,12 @@
for fname in [x for x in files if x.endswith('yml')]:
config = os.path.join(rootdir, fname)
if fname == 'init.yml':
+ if config.find("infra/init.yml") != -1:
+ with open(config, 'r') as f:
+ ddd = yaml.load(f)
+ external.update(ddd.get("parameters", {}).
+ get("linux", {}).
+ get("system", {}))
configs_to_process.append(config)
# NOTE: this is a special case left here for the time being.
elif fname == 'nodes.yml': # TODO: refactor it.
@@ -176,6 +182,11 @@
else:
out[nodename]['src'] = [x]
update_dict(out[nodename], nodecontent, False)
+ # NOTE: this fixes cfg01 till its definition starts confirming
+ # to rules observed for other nodes.
+ if 'cfg01' in nodename:
+ out[nodename].update({'name': external['name'],
+ 'domain': external['domain']})
return out
@@ -188,15 +199,25 @@
systemdesc = UnsortableDict()
systemdesc['name'] = res.get('name', 'FOO')
systemdesc['domain'] = res.get('domain', 'BAR')
- # Are the two below ever used in production?:
- systemdesc['cluster'] = res.get('cluster', 'default')
- systemdesc['environment'] = res.get('environment', 'prd')
- contents = {'classes': res['classes'],
- 'parameters': {
- '_param': res.get('params', {}),
- 'linux': {
- 'system': systemdesc
- }}}
+ # NOTE: this should stay here until cfg01 definition stabilizes.
+ if systemdesc['name'] != 'cfg01':
+ systemdesc['cluster'] = res.get('cluster', 'default')
+ systemdesc['environment'] = res.get('environment', 'prd')
+ params = res.get('params', {})
+ if params:
+ contents = {'classes': res['classes'],
+ 'parameters': {
+ '_param': params,
+ 'linux': {
+ 'system': systemdesc
+ }}}
+ # NOTE: this should stay here until cfg01 definition stabilizes.
+ else:
+ contents = {'classes': res['classes'],
+ 'parameters': {
+ 'linux': {
+ 'system': systemdesc
+ }}}
# NOTE: the original formula contains hints to other possible sections.
# Since it is not immediately clear whether those are used or just
# a preacution for future work thay are omited for now.
@@ -273,9 +294,10 @@
for nname, node in basic_nodes.iteritems():
if needs_expansion(node):
continue
- node.get('classes', []).extend(nodes_init.get(nname, {}).
- get('classes', []))
- # OK, this crap could be dangerous
+ extension = nodes_init.get(nname, {}).get('classes', [])
+ to_extend = node.get('classes', [])#.extend(extension)
+ if to_extend != extension:
+ to_extend.extend(extension)
node.get('params', {}).update(nodes_init.get(nname, {}).
get('params', {}))
basic_nodes_extended[nname] = node