summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-07-31 18:43:27 +0300
committermakkalot <makkalot@gmail.com>2008-07-31 18:43:27 +0300
commitf2690e9fecbbb038835f05c935598bf07857587c (patch)
tree0b900b44f7f9486f814ddaef78c7125777840d9f /funcweb
parent2c2dfebee9a648227417119374accb47e062cc36 (diff)
downloadfunc-f2690e9fecbbb038835f05c935598bf07857587c.tar.gz
func-f2690e9fecbbb038835f05c935598bf07857587c.tar.xz
func-f2690e9fecbbb038835f05c935598bf07857587c.zip
groups api actions added to main controller
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/controllers.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/funcweb/funcweb/controllers.py b/funcweb/funcweb/controllers.py
index 2bdbe80..efc2c83 100644
--- a/funcweb/funcweb/controllers.py
+++ b/funcweb/funcweb/controllers.py
@@ -428,9 +428,62 @@ class Funcweb(object):
"""
identity.current.logout()
raise redirect("/")
+
+################################ Groups API methods here #############################
+ @expose(template="funcweb.templates.groups_main")
+ @identity.require(identity.not_anonymous())
+ def groups_main(self):
+ """
+ The main page of the groups
+ """
+ #a dummy object to let us to get the groups api
+ #we dont supply a new group file it will handle the default
+ minion_api = Minions("*")
+ groups = minion_api.group_class.get_group_names()
+ del minion_api
+ #result to the template please :)
+ return dict(groups = groups)
+
+ @expose(template="funcweb.templates.list_group")
+ @identity.require(identity.not_anonymous())
+ def add_new_group(self,group_name,submit):
+ """
+ Adding a new group
+ """
+ minion_api = Minions("*")
+ minion_api.group_class.add_group(group_name,save=True)
+ groups = minion_api.group_class.get_group_names()
+ del minion_api
+ return dict(groups = groups)
+ @expose(template="funcweb.templates.list_group")
+ @identity.require(identity.not_anonymous())
+ def remove_group(self,**kw):
+ """
+ Adding a new group
+ """
+ minion_api = Minions("*")
+ minion_api.group_class.remove_group(kw['group_name'],save=True)
+ groups = minion_api.group_class.get_group_names()
+ del minion_api
+ return dict(groups = groups)
+ @expose(template="funcweb.templates.list_group")
+ @identity.require(identity.not_anonymous())
+ def list_host_by_group(self,group_name):
+ """
+ Get the hosts for the specified group_name
+ """
+ if not group_name.startswith('@'):
+ group_name = "".join(["@",group_name.strip()])
+
+ minion_api = Minions("*")
+ hosts = minion_api.group_class.get_hosts_by_group_glob(kw['group_name'])
+ all_minions = minion_api.get_all_hosts()
+ del minion_api
+ return dict(hosts = hosts,all_minions = all_minions)
+############################# END of GROUPS API METHODS ############################
class Root(controllers.RootController):
@expose()