Skip to content

Commit

Permalink
medium: cibconfig: Delete containers first in edits (boo#905268)
Browse files Browse the repository at this point in the history
  • Loading branch information
krig committed Nov 21, 2014
1 parent c288d54 commit f11a8a7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modules/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -3057,13 +3057,27 @@ def _cli_set_update(self, edit_d, mk_set, upd_set, del_set, method):
'''
common_debug("_cli_set_update: %s, %s, %s" % (mk_set, upd_set, del_set))
test_l = []

def obj_is_container(x):
obj = self.find_object(x)
return obj and is_container(obj.node)

del_containers = [x for x in del_set if obj_is_container(x)]
del_objs = [x for x in del_set if not obj_is_container(x)]

# delete containers first in case objects are moved elsewhere
if not self.delete(*del_containers):
common_debug("delete %s failed" % (list(del_set)))
return False

for cli in processing_sort([edit_d[x] for x in mk_set]):
obj = self.create_from_cli(cli)
if not obj:
common_debug("create_from_cli '%s' failed" %
(etree.tostring(cli, pretty_print=True)))
return False
test_l.append(obj)

for id in upd_set:
obj = self.find_object(id)
if not obj:
Expand All @@ -3078,7 +3092,7 @@ def _cli_set_update(self, edit_d, mk_set, upd_set, del_set, method):
(obj, etree.tostring(node), method))
return False
test_l.append(obj)
if not self.delete(*list(del_set)):
if not self.delete(*del_objs):
common_debug("delete %s failed" % (list(del_set)))
return False
rc = True
Expand Down

0 comments on commit f11a8a7

Please sign in to comment.