Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
FUSS
octomon
Commits
a7b2f773
Unverified
Commit
a7b2f773
authored
Mar 23, 2019
by
Marco Marinello
Browse files
Added etc parsing utility
parent
b0aecc3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
hosts/utils.py
View file @
a7b2f773
# -*- 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
]
except
:
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
hosts/views.py
View file @
a7b2f773
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment