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
Commits
bae89501
Commit
bae89501
authored
9 years ago
by
Tim Fechner
Committed by
Tim Fechner
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Let domain.check_if_valid() save itself
parent
a723b6da
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
salt_observer/admin.py
+3
-2
3 additions, 2 deletions
salt_observer/admin.py
salt_observer/migrations/0015_auto_20160718_1812.py
+30
-0
30 additions, 0 deletions
salt_observer/migrations/0015_auto_20160718_1812.py
salt_observer/models.py
+6
-3
6 additions, 3 deletions
salt_observer/models.py
with
39 additions
and
5 deletions
salt_observer/admin.py
+
3
−
2
View file @
bae89501
...
@@ -20,13 +20,14 @@ class NetworkInterfaceInline(admin.TabularInline):
...
@@ -20,13 +20,14 @@ class NetworkInterfaceInline(admin.TabularInline):
class
MinionAdmin
(
admin
.
ModelAdmin
):
class
MinionAdmin
(
admin
.
ModelAdmin
):
inlines
=
[
NetworkInterfaceInline
]
inlines
=
[
NetworkInterfaceInline
]
readonly_fields
=
(
'
fqdn
'
,
'
data
'
,
'
last_updated
'
)
readonly_fields
=
(
'
fqdn
'
,
'
data
'
,
'
last_updated
'
)
exclude
=
(
'
_data
'
,)
exclude
=
(
'
_data
'
,
'
md_content
'
)
admin
.
site
.
register
(
Minion
,
MinionAdmin
)
admin
.
site
.
register
(
Minion
,
MinionAdmin
)
class
NetworkAdmin
(
admin
.
ModelAdmin
):
class
NetworkAdmin
(
admin
.
ModelAdmin
):
inlines
=
[
NetworkInterfaceInline
]
inlines
=
[
NetworkInterfaceInline
]
readonly_fields
=
(
'
ipv4
'
,
'
mask
'
,
'
last_updated
'
)
readonly_fields
=
(
'
ipv4
'
,
'
mask
'
,
'
last_updated
'
)
exclude
=
(
'
md_content
'
,)
admin
.
site
.
register
(
Network
,
NetworkAdmin
)
admin
.
site
.
register
(
Network
,
NetworkAdmin
)
...
@@ -34,5 +35,5 @@ class DomainAdmin(admin.ModelAdmin):
...
@@ -34,5 +35,5 @@ class DomainAdmin(admin.ModelAdmin):
list_display
=
(
'
fqdn
'
,
'
minion_count
'
,
'
valid
'
,
'
public
'
,
'
can_speak_https
'
)
list_display
=
(
'
fqdn
'
,
'
minion_count
'
,
'
valid
'
,
'
public
'
,
'
can_speak_https
'
)
filter_horizontal
=
(
'
minion
'
,)
filter_horizontal
=
(
'
minion
'
,)
readonly_fields
=
(
'
ssl_lab_status
'
,)
readonly_fields
=
(
'
ssl_lab_status
'
,)
exclude
=
(
'
_ssl_lab_status
'
,)
exclude
=
(
'
_ssl_lab_status
'
,
'
md_content
'
)
admin
.
site
.
register
(
Domain
,
DomainAdmin
)
admin
.
site
.
register
(
Domain
,
DomainAdmin
)
This diff is collapsed.
Click to expand it.
salt_observer/migrations/0015_auto_20160718_1812.py
0 → 100644
+
30
−
0
View file @
bae89501
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-07-18 16:12
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
salt_observer
'
,
'
0014_domain_md_content
'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'
domain
'
,
name
=
'
md_content
'
,
field
=
models
.
TextField
(
blank
=
True
),
),
migrations
.
AlterField
(
model_name
=
'
minion
'
,
name
=
'
md_content
'
,
field
=
models
.
TextField
(
blank
=
True
),
),
migrations
.
AlterField
(
model_name
=
'
network
'
,
name
=
'
md_content
'
,
field
=
models
.
TextField
(
blank
=
True
),
),
]
This diff is collapsed.
Click to expand it.
salt_observer/models.py
+
6
−
3
View file @
bae89501
...
@@ -7,7 +7,7 @@ import requests
...
@@ -7,7 +7,7 @@ import requests
class
MarkdownContent
(
models
.
Model
):
class
MarkdownContent
(
models
.
Model
):
'''
To enable on-the-fly modification of templates
'''
'''
To enable on-the-fly modification of templates
'''
md_content
=
models
.
TextField
()
md_content
=
models
.
TextField
(
blank
=
True
)
class
Meta
:
class
Meta
:
abstract
=
True
abstract
=
True
...
@@ -47,7 +47,7 @@ class Domain(MarkdownContent):
...
@@ -47,7 +47,7 @@ class Domain(MarkdownContent):
def
ssl_lab_status
(
self
,
value
):
def
ssl_lab_status
(
self
,
value
):
self
.
_ssl_lab_status
=
json
.
dumps
(
value
)
self
.
_ssl_lab_status
=
json
.
dumps
(
value
)
def
check_if_valid
(
self
):
def
check_if_valid
(
self
,
commit
=
True
):
try
:
try
:
a
=
requests
.
get
(
'
http://{}/
'
.
format
(
self
.
fqdn
),
timeout
=
5
,
verify
=
False
)
a
=
requests
.
get
(
'
http://{}/
'
.
format
(
self
.
fqdn
),
timeout
=
5
,
verify
=
False
)
b
=
requests
.
get
(
'
https://{}/
'
.
format
(
self
.
fqdn
),
timeout
=
5
,
verify
=
False
)
b
=
requests
.
get
(
'
https://{}/
'
.
format
(
self
.
fqdn
),
timeout
=
5
,
verify
=
False
)
...
@@ -56,12 +56,15 @@ class Domain(MarkdownContent):
...
@@ -56,12 +56,15 @@ class Domain(MarkdownContent):
else
:
else
:
self
.
valid
=
True
self
.
valid
=
True
if
commit
:
self
.
save
()
def
minion_count
(
self
):
def
minion_count
(
self
):
return
len
(
self
.
minion
.
all
())
return
len
(
self
.
minion
.
all
())
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
id
:
if
not
self
.
id
:
self
.
check_if_valid
()
self
.
check_if_valid
(
commit
=
False
)
super
().
save
(
*
args
,
**
kwargs
)
super
().
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment