Commit 05bf081a authored by Roland Denis's avatar Roland Denis
Browse files

Adding cluster list and clusters. Some other fixes

parent 3ecd703b
Pipeline #6599 passed with stages
in 55 seconds
......@@ -34,12 +34,28 @@ class meso(nodes.General, nodes.Element):
""" mesocenter description """
class cluster_list(nodes.General, nodes.Element):
""" clusters list """
class cluster(nodes.General, nodes.Element):
""" cluster description """
class storage_list(nodes.General, nodes.Element):
""" storage list """
class storage(nodes.General, nodes.Element):
""" storage description """
###############################################################################
# Directives
class Region(Directive):
required_arguments = 0
optional_arguments = 1
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = {}
has_content = True
......@@ -55,8 +71,7 @@ class Region(Directive):
class MesoList(Directive):
required_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
optional_arguments = 0
option_spec = {
'json_url': directives.uri,
}
......@@ -81,8 +96,8 @@ class MesoList(Directive):
class Meso(Directive):
required_arguments = 0
optional_arguments = 10
required_arguments = 1
optional_arguments = 0
final_argument_whitespace = True
option_spec = { # Option name in lowercase!
'institutesname': multiline_list(str),
......@@ -93,7 +108,7 @@ class Meso(Directive):
'contactname': str,
'contactaddress': str,
'totalcorenumber': int,
'totalstorage': int,
'totalstorage': float,
'totalgpunumber': int,
'totalram': int,
'distributedinfra': multiline_list(str),
......@@ -115,8 +130,51 @@ class Meso(Directive):
return [node]
class ClusterList(Directive):
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = True
option_spec = {}
has_content = True
def run(self):
node = cluster_list()
if self.content:
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
class Cluster(Directive):
required_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
option_spec = { # Option name in lowercase!
'clustercorenumber': int,
'networktype': str,
'networkbandwidth': float,
'networktopology': str,
'jobshedulername': str,
'vendorname': str,
}
has_content = True
def run(self):
node = cluster()
node['name'] = self.arguments[0] if self.arguments else ''
for key in self.option_spec:
node[key] = self.options.get(key, None)
self.state.nested_parse(self.content, self.content_offset, node)
return [node]
def register():
directives.register_directive('region', Region)
directives.register_directive('meso_list', MesoList)
directives.register_directive('meso', Meso)
directives.register_directive('cluster_list', ClusterList)
directives.register_directive('cluster', Cluster)
......@@ -74,6 +74,18 @@ class myHTMLTranslator(PelicanHTMLTranslator):
def depart_meso(self, node):
self.body.extend(self.meso_template.render(meso=node, footer=True).splitlines(True))
def visit_cluster_list(self, node):
pass
def depart_cluster_list(self, node):
pass
def visit_cluster(self, node):
pass
def depart_cluster(self, node):
pass
# Overwrite default translator so that extensions can be chained
readers.PelicanHTMLTranslator = myHTMLTranslator
......
......@@ -36,14 +36,24 @@ def filter_options(directive, options):
""" Filters keys of given dict depending on option_sep of the directive """
return dict(((key, value) for key, value in options.items() if key.lower() in directive.option_spec))
def build_meso(meso):
""" Filters and formats attributes of a meso depending on the Meso directive """
return {
'name': meso['name'],
'options': filter_options(directives.Meso, meso),
'content': meso['fullDescription'],
'content': meso.get('fullDescription', ''),
'cluster_list': list(map(build_cluster, meso.get('clusterList', []))),
}
def build_cluster(cluster):
""" Fitlers and formats attributes of a cluster depending on the Cluster directive """
return {
'name': cluster.get('name', ''),
'options': filter_options(directives.Cluster, cluster),
}
def json_mesolist_to_rst(url):
"""
Parses a json file containing the list of mesocenters and returns an rst like describing them.
......@@ -95,6 +105,14 @@ _json_mesolist_rst_template = _json_mesolist_rst_env.from_string(dedent("""
{{ l }}
{%- endfor %}
{% for cluster in meso["cluster_list"] %}
.. cluster:: {{ cluster['name'] }}
{%- for l in cluster["options"] | rst_options %}
{{ l }}
{%- endfor %}
{% endfor %}
{%- endfor %}
{% endfor %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment