diff options
author | 2016-11-18 20:25:43 -0800 | |
---|---|---|
committer | 2016-11-18 20:25:43 -0800 | |
commit | 96af8475e3db496be22d2ede78081c1c67a51f96 (patch) | |
tree | c5207f6fffef26d9c0793f494ecf6edee6720908 /lib/partitioner/partitioner.py | |
parent | 6aa5772f98296bf9bbb9bbed144cf52d48949119 (diff) |
JIRA Issue DOMINO-20
Change-Id: I86a2b72d36c5807f384d39bd72305b9b4b36835c
Signed-off-by: Ulas Kozat <ulas.kozat@gmail.com>
Diffstat (limited to 'lib/partitioner/partitioner.py')
-rw-r--r-- | lib/partitioner/partitioner.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/partitioner/partitioner.py b/lib/partitioner/partitioner.py index 5177b1b..75adc63 100644 --- a/lib/partitioner/partitioner.py +++ b/lib/partitioner/partitioner.py @@ -27,7 +27,7 @@ def partition_tosca(filepath, nodesite, tpl): for node in nodesite: for site in sitenodes: if node not in sitenodes[site]: - del tpl_local[site]['topology_template']['node_templates'][node] + tpl_local[site]['topology_template']['node_templates'].pop(node,None) rm_dependents(tpl_local[site]['topology_template']['node_templates'] , node) #remove from policy targets if tpl_local[site]['topology_template'].has_key('policies'): @@ -38,10 +38,10 @@ def partition_tosca(filepath, nodesite, tpl): # remove the rule if there is no target left! if len(rule[key]['targets']) is 0: tpl_local[site]['topology_template']['policies'].remove(rule) - + for site in sitenodes: tpl_l = tpl_local[site] - print tpl_l , '\n' + rm_orphans(tpl_l) file_paths[site] = filepath + '_part' + str(site) + '.yaml' fout = open(file_paths[site],'w') @@ -125,3 +125,15 @@ def rm_dependents(node_template , node): #remove the dependents for i in range(len(del_list)): del node_template[del_list[i]] + +def rm_orphans(tpl): + nodes = tpl['topology_template']['node_templates'] + keep_list = [] + for node in nodes: + if nodes[node].has_key('requirements'): + for i in range(len(nodes[node]['requirements'])): + if nodes[node]['requirements'][i].has_key('virtualLink'): + keep_list.append(nodes[node]['requirements'][i]['virtualLink']['node']) + for node in list(nodes): + if (nodes[node]['type'] == 'tosca.nodes.nfv.VL') and (node not in keep_list): + del nodes[node] |