Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
salt-observer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
django
salt-observer
Merge requests
!2
Add list of listening services to minion detail
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Add list of listening services to minion detail
dev_4
into
master
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
Tim Fechner
requested to merge
dev_4
into
master
9 years ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Close
#4 (closed)
0
0
Merge request reports
Viewing commit
c70210b8
Show latest version
2 files
+
62
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
c70210b8
Add list of listening services to minion detail
· c70210b8
Tim Fechner
authored
9 years ago
Close
#4
salt_observer/management/commands/fetchlisteningservices.py
0 → 100644
+
30
−
0
View file @ c70210b8
Edit in single-file editor
Open in Web IDE
from
django.core.management.base
import
BaseCommand
from
salt_observer.models
import
Minion
from
.
import
ApiCommand
class
Command
(
ApiCommand
,
BaseCommand
):
help
=
'
Fetch and save listening network services
'
def
save_services
(
self
,
api
):
listening_services
=
api
.
get
(
'
network.netstat
'
)
for
minion_fqdn
,
services
in
listening_services
.
items
():
minion
=
Minion
.
objects
.
filter
(
fqdn
=
minion_fqdn
).
first
()
if
not
minion
:
continue
minion_services
=
[]
for
service
in
services
:
if
service
.
get
(
'
state
'
,
''
)
==
'
LISTEN
'
:
minion_services
.
append
(
service
)
minion
.
update_data
({
'
listening_services
'
:
minion_services
})
minion
.
save
()
def
handle
(
self
,
*
args
,
**
kwargs
):
api
=
super
().
handle
(
*
args
,
**
kwargs
)
self
.
save_services
(
api
)
api
.
logout
()
Loading