Skip to content
Permalink
Browse files

Add the get_keywords listener handler

So the cluster manager webapp can format forms to configure
the node, ccfg and objects.

This handler requires the "kind" option.
  • Loading branch information...
cvaroqui committed Jul 29, 2019
1 parent c874693 commit 33ea9c2f84e812c6025b08c05feff0d57a4998d5
Showing with 59 additions and 0 deletions.
  1. +32 −0 lib/keywords.py
  2. +27 −0 lib/osvcd_lsnr.py
@@ -193,6 +193,26 @@ def template_rst(self, section=None):
s += '\n'
return s

def dump(self):
data = {}
if self.at:
data["at"] = self.at
if self.required:
data["required"] = self.required
if self.candidates:
data["candidates"] = self.candidates
if self.default:
data["default"] = self.default
if self.provisioning:
data["provisioning"] = self.provisioning
if self.depends:
data["depends"] = self.depends
if self.convert:
data["convert"] = self.convert
if self.text:
data["text"] = self.text
return data

class Section(object):
def __init__(self, section, top=None):
self.section = section
@@ -205,6 +225,12 @@ def __iadd__(self, o):
self.keywords.append(o)
return self

def dump(self):
data = {}
for kw in self.keywords:
data[kw.keyword] = kw.dump()
return data

def template(self, fmt="text", write=False):
k = self.getkey("type")
if k is None:
@@ -379,6 +405,12 @@ def __getitem__(self, key):
return Section(k, top=self)
return self.sections[k]

def dump(self):
data = {}
for section in sorted(self.sections):
data[section] = self.sections[section].dump()
return data

def print_templates(self, fmt="text"):
"""
Print templates in the spectified format (text by default, or rst).
@@ -3084,6 +3084,33 @@ def action_get_node(self, nodename, **kwargs):
data = shared.NODE.asset.get_asset_dict()
return data

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

def action_get_pools(self, nodename, **kwargs):
data = shared.NODE.pool_status_data()
return data

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

def action_get_networks(self, nodename, **kwargs):
data = shared.NODE.network_status_data()
return data

def rbac_action_get_keywords(self, nodename, **kwargs):
pass

def action_get_keywords(self, nodename, **kwargs):
options = kwargs.get("options", {})
kind = options.get("kind", {})
if kind == "node":
obj = shared.NODE
elif kind:
obj = factory(kind)(node=self)
else:
raise HTTP(400, "A kind must be specified.")
return obj.kwdict.KEYS.dump()

##########################################################################
#

0 comments on commit 33ea9c2

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