mirror of
https://github.com/xcat2/confluent.git
synced 2025-01-15 12:17:47 +00:00
Wire up delete buttons to actually work
This commit is contained in:
parent
7151797402
commit
51f6a6995b
@ -554,6 +554,15 @@ class ConfigManager(object):
|
||||
nodecfg = self._cfgstore['nodes'][node]
|
||||
self._do_inheritance(nodecfg, attr, group)
|
||||
|
||||
def del_nodes(self, nodes):
|
||||
if 'nodes' not in self._cfgstore:
|
||||
return
|
||||
for node in nodes:
|
||||
if node in self._cfgstore['nodes']:
|
||||
self._sync_groups_to_node(node=node, groups=[])
|
||||
del self._cfgstore['nodes'][node]
|
||||
self._bg_sync_to_file()
|
||||
|
||||
def set_node_attributes(self, attribmap):
|
||||
if 'nodes' not in self._cfgstore:
|
||||
self._cfgstore['nodes'] = {}
|
||||
|
@ -58,6 +58,9 @@ class ConfluentMessage(object):
|
||||
snippet += 'value="%s">' % (key)
|
||||
return snippet
|
||||
|
||||
class DeletedResource(ConfluentMessage):
|
||||
def __init__(self):
|
||||
self.kvpairs = {}
|
||||
|
||||
class ConfluentChoiceMessage(ConfluentMessage):
|
||||
|
||||
|
@ -107,6 +107,12 @@ def iterate_resources(fancydict):
|
||||
resource += '/'
|
||||
yield msg.ChildCollection(resource)
|
||||
|
||||
def delete_node_collection(collectionpath, configmanager):
|
||||
if len(collectionpath) == 2: #just node
|
||||
node = collectionpath[-1]
|
||||
configmanager.del_nodes([node])
|
||||
yield msg.DeletedResource()
|
||||
|
||||
def enumerate_node_collection(collectionpath, configmanager):
|
||||
if collectionpath == [ 'node' ]: #it is simple '/node/', need a list of nodes
|
||||
return iterate_collections(configmanager.get_nodes())
|
||||
@ -146,7 +152,12 @@ def handle_path(path, operation, configmanager, inputdata=None):
|
||||
except IndexError: # doesn't actually have a long enough path
|
||||
return iterate_collections(configmanager.get_nodes())
|
||||
if iscollection:
|
||||
return enumerate_node_collection(pathcomponents, configmanager)
|
||||
if operation == "delete":
|
||||
return delete_node_collection(pathcomponents, configmanager)
|
||||
elif operation == "retrieve":
|
||||
return enumerate_node_collection(pathcomponents, configmanager)
|
||||
else:
|
||||
raise Exception("TODO here")
|
||||
del pathcomponents[0:2]
|
||||
try:
|
||||
plugroute = nested_lookup(noderesources, pathcomponents).routeinfo
|
||||
|
Loading…
x
Reference in New Issue
Block a user