This commit is contained in:
parent
02dffb1a88
commit
351c12eed1
3 changed files with 19 additions and 4 deletions
|
@ -35,14 +35,20 @@ def main():
|
||||||
current_os = find_os(content)
|
current_os = find_os(content)
|
||||||
if "freebsd" in current_os:
|
if "freebsd" in current_os:
|
||||||
infos = parse_freebsd(content)
|
infos = parse_freebsd(content)
|
||||||
|
infos["extend_exists"] = False
|
||||||
template = env.get_template('freebsd.rst.j2')
|
template = env.get_template('freebsd.rst.j2')
|
||||||
output = template.render(**infos)
|
|
||||||
elif "debian" in current_os:
|
elif "debian" in current_os:
|
||||||
infos = parse_debian(content)
|
infos = parse_debian(content)
|
||||||
|
infos["extend_exists"] = False
|
||||||
template = env.get_template('debian.rst.j2')
|
template = env.get_template('debian.rst.j2')
|
||||||
output = template.render(**infos)
|
|
||||||
else:
|
else:
|
||||||
parse_freebox(content)
|
infos = parse_freebox(content)
|
||||||
|
infos = {
|
||||||
|
"hostname":"Freebox",
|
||||||
|
"os":{"NAME":"FreeboxOS","VERSION":"None"},
|
||||||
|
}
|
||||||
|
infos["extend_exists"] = False
|
||||||
|
output = template.render(**infos)
|
||||||
with open("../source/devices/{host}.rst".format(host=infos["hostname"].replace("\n","")), "w") as f:
|
with open("../source/devices/{host}.rst".format(host=infos["hostname"].replace("\n","")), "w") as f:
|
||||||
f.write(output)
|
f.write(output)
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,13 @@ def parse_ip(raw_ip):
|
||||||
result.append(interface)
|
result.append(interface)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def parse_docker(raw_docker):
|
||||||
|
result = []
|
||||||
|
for line in raw_docker.splitlines():
|
||||||
|
print(line)
|
||||||
|
result.append(loads(line))
|
||||||
|
return result
|
||||||
|
|
||||||
def parse_debian(content):
|
def parse_debian(content):
|
||||||
current_section = ""
|
current_section = ""
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -24,7 +31,7 @@ def parse_debian(content):
|
||||||
if current_section:
|
if current_section:
|
||||||
result[current_section] += line + "\n"
|
result[current_section] += line + "\n"
|
||||||
for section in result:
|
for section in result:
|
||||||
if section in ["services","routes"]:
|
if section in ["services","routes", "docker"]:
|
||||||
result[section] = loads(result[section])
|
result[section] = loads(result[section])
|
||||||
result["ip"] = parse_ip(result["ip"])
|
result["ip"] = parse_ip(result["ip"])
|
||||||
result["os"] = loads(result["version"])
|
result["os"] = loads(result["version"])
|
||||||
|
|
|
@ -5,3 +5,5 @@
|
||||||
:os: {{ os["NAME"] }}
|
:os: {{ os["NAME"] }}
|
||||||
:version: {{ os["VERSION"] }}
|
:version: {{ os["VERSION"] }}
|
||||||
|
|
||||||
|
{% if extend_exists %}{% include "{hostname}.rst.j2".format(hostname=hostname) %}{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue