Skip to content

Commit

Permalink
Add the get_keywords listener handler
Browse files Browse the repository at this point in the history
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 33ea9c2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/keywords.py
Expand Up @@ -193,6 +193,26 @@ def template_rst(self, section=None):
s += '\n' s += '\n'
return s 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): class Section(object):
def __init__(self, section, top=None): def __init__(self, section, top=None):
self.section = section self.section = section
Expand All @@ -205,6 +225,12 @@ def __iadd__(self, o):
self.keywords.append(o) self.keywords.append(o)
return self 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): def template(self, fmt="text", write=False):
k = self.getkey("type") k = self.getkey("type")
if k is None: if k is None:
Expand Down Expand Up @@ -379,6 +405,12 @@ def __getitem__(self, key):
return Section(k, top=self) return Section(k, top=self)
return self.sections[k] 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"): def print_templates(self, fmt="text"):
""" """
Print templates in the spectified format (text by default, or rst). Print templates in the spectified format (text by default, or rst).
Expand Down
27 changes: 27 additions & 0 deletions lib/osvcd_lsnr.py
Expand Up @@ -3084,6 +3084,33 @@ def action_get_node(self, nodename, **kwargs):
data = shared.NODE.asset.get_asset_dict() data = shared.NODE.asset.get_asset_dict()
return data 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()


########################################################################## ##########################################################################
# #
Expand Down

0 comments on commit 33ea9c2

Please sign in to comment.