2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-08-23 19:50:23 +00:00

Implement group creation

Nodegroups can now be created through the interface
This commit is contained in:
Jarrod Johnson
2014-02-14 16:43:00 -05:00
parent 66e90394be
commit cb8f37f1b0
3 changed files with 41 additions and 2 deletions

View File

@@ -522,7 +522,7 @@ class ConfigManager(object):
elif 'groups' not in self._cfgstore['nodes'][node]:
self._cfgstore['nodes'][node]['groups'] = [group]
elif group not in self._cfgstore['nodes'][node]['groups']:
self._cfgstore['nodes'][node]['groups'].append(group)
self._cfgstore['nodes'][node]['groups'].insert(0, group)
else:
continue # next node, this node already in
self._node_added_to_group(node, group)
@@ -536,7 +536,11 @@ class ConfigManager(object):
cfgobj = self._cfgstore['groups'][group]
for attr in attribmap[group].iterkeys():
newdict = {}
if (isinstance(attribmap[group][attr], str)):
if attr == 'nodes':
if not isinstance(attribmap[group][attr], list):
raise ValueError
newdict = set(attribmap[group][attr])
elif (isinstance(attribmap[group][attr], str)):
newdict = { 'value': attribmap[group][attr] }
else:
newdict = attribmap[group][attr]

View File

@@ -31,6 +31,28 @@ opmap = {
}
def group_creation_resources():
yield confluent.messages.Attributes(
kv={'name': None}, desc="Name of the group").html() + '<br>'
yield confluent.messages.ListAttributes(kv={'nodes': []},
desc='Nodes to add to the group').html() + '<br>\n'
for attr in sorted(attribs.node.iterkeys()):
if attr == 'groups':
continue
if attr.startswith("secret."):
yield confluent.messages.CryptedAttributes(
kv={attr: None},
desc=attribs.node[attr]['description']).html() + '<br>\n'
elif 'type' in attribs.node[attr] and list == attribs.node[attr]['type']:
yield confluent.messages.ListAttributes(
kv={attr: []},
desc=attribs.node[attr]['description']).html() + '<br>\n'
else:
yield confluent.messages.Attributes(
kv={attr: None},
desc=attribs.node[attr]['description']).html() + '<br>\n'
def node_creation_resources():
yield confluent.messages.Attributes(
kv={'name': None}, desc="Name of the node").html() + '<br>'
@@ -50,6 +72,7 @@ def node_creation_resources():
create_resource_functions = {
'/node/': node_creation_resources,
'/nodegroup/': group_creation_resources,
}

View File

@@ -142,6 +142,16 @@ def enumerate_node_collection(collectionpath, configmanager):
return iterate_resources(collection)
def create_group(inputdata, configmanager):
try:
groupname = inputdata['name']
del inputdata['name']
attribmap = {groupname: inputdata}
except KeyError:
raise exc.InvalidArgumenTException()
configmanager.set_group_attributes(attribmap)
def create_node(inputdata, configmanager):
try:
nodename = inputdata['name']
@@ -176,6 +186,8 @@ def handle_path(path, operation, configmanager, inputdata=None):
try:
group = pathcomponents[1]
except IndexError:
if operation == "create":
create_group(inputdata, configmanager)
return iterate_collections(configmanager.get_groups())
if iscollection:
if operation == "delete":