Unverified Commit a7b2f773 authored by Marco Marinello's avatar Marco Marinello
Browse files

Added etc parsing utility

parent b0aecc3f
# -*- coding: utf-8 -*-
# Copyright (c) 2018 Marco Marinello <marco.marinello@fuss.bz.it>
# Copyright (c) 2018-2019 Marco Marinello <marco.marinello@fuss.bz.it>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -14,6 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import json
def filter(list, query):
result = []
for x in list:
......@@ -135,3 +138,14 @@ def parse_wan_mac(components):
return macs[wan]
return ""
def parse_etc(components):
if "etc_segments" not in components:
return None
segments = int(components["etc_segments"])
j = ""
for i in range(segments):
j += components["etc_segment%s" % i]
data = json.loads(j)
return data
......@@ -56,7 +56,8 @@ def host(request, id):
'disks': utils.parse_disks(components),
'versions': utils.filter_by_list(components, GATHERED_PACKAGES),
'interfaces': utils.parse_interfaces(components),
'lc_wan_mac': utils.parse_wan_mac(components)
'lc_wan_mac': utils.parse_wan_mac(components),
'etc': utils.parse_etc(components)
for i in components:
ctx["lc_"+i.name] = i
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