Skip to content
Permalink
Browse files

Merge branch 'master' of git+ssh://10.19.0.11/opt/opensvc

  • Loading branch information...
cvaroqui committed Jul 9, 2019
2 parents e029444 + 37fabdd commit b4f0c06903f497887b7fcf8622174c57a221e54d
Showing with 63 additions and 0 deletions.
  1. +63 −0 lib/osvcd_lsnr.py
@@ -1393,6 +1393,8 @@ def multiplex(self, node, fname, options, data, original_nodename, action, strea
nodenames = [svcnodes[0]]
except KeyError:
return {"error": "unknown service", "status": 1}
if node == "ANY":
nodenames = [rcEnv.nodename]
else:
nodenames = shared.NODE.nodes_selector(node, data=shared.CLUSTER_DATA)

@@ -2839,6 +2841,67 @@ def action_whoami(self, nodename, **kwargs):
}
return data

def rbac_action_get_catalogs(self, nodename, **kwargs):
self.rbac_requires(roles=["guest"], namespaces="ANY", **kwargs)

def action_get_catalogs(self, nodename, **kwargs):
data = []
if shared.NODE.collector_env.dbopensvc is not None:
data.append({
"name": "collector",
})
return data

def rbac_action_get_templates(self, nodename, **kwargs):
self.rbac_requires(roles=["guest"], namespaces="ANY", **kwargs)

def action_get_templates(self, nodename, **kwargs):
options = kwargs.get("options", {})
catalog = options.get("catalog")
data = {}
if catalog == "collector":
if shared.NODE.collector_env.dbopensvc is None:
raise HTTP(400, "This node is not registered on a collector")
data = []
options = {
"limit": 0,
"props": "id,tpl_name,tpl_author,tpl_comment",
"orderby": "tpl_name",
}

for tpl in shared.NODE.collector_rest_get("/provisioning_templates", options)["data"]:
data.append({
"id": tpl["id"],
"name": tpl["tpl_name"],
"desc": tpl["tpl_comment"],
"author": tpl["tpl_author"],
"catalog": "collector",
})
else:
raise HTTP(400, "unknown catalog %s" % catalog)
return data

def rbac_action_get_template(self, nodename, **kwargs):
self.rbac_requires(roles=["guest"], namespaces="ANY", **kwargs)

def action_get_template(self, nodename, **kwargs):
options = kwargs.get("options", {})
catalog = options.get("catalog")
template = options.get("template")
if catalog == "collector":
if template is None:
raise HTTP(400, "template is not set")
options = {
"props": "tpl_definition"
}
try:
data = shared.NODE.collector_rest_get("/provisioning_templates/%s" % template, options)
return data["data"][0]["tpl_definition"]
except IndexError:
raise HTTP(404, "template not found")
raise HTTP(400, "unknown catalog %s" % catalog)


##########################################################################
#
# App

0 comments on commit b4f0c06

Please sign in to comment.
You can’t perform that action at this time.