Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3159f5f9
authored
Mar 18, 2015
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix status reporting in init.py
parent
45cd15cd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
circle/dashboard/management/commands/init.py
+8
-4
No files found.
circle/dashboard/management/commands/init.py
View file @
3159f5f9
...
...
@@ -17,6 +17,7 @@
from
__future__
import
unicode_literals
,
absolute_import
import
logging
from
optparse
import
make_option
from
django.contrib.auth.models
import
User
...
...
@@ -28,6 +29,9 @@ from storage.models import DataStore
from
vm.models
import
Lease
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--force'
,
action
=
"store_true"
),
...
...
@@ -49,18 +53,18 @@ class Command(BaseCommand):
qs
=
model
.
objects
.
filter
(
**
{
field
:
value
})[:
1
]
if
not
qs
.
exists
():
obj
=
model
.
objects
.
create
(
**
kwargs
)
self
.
changed
.
append
(
'New
%
s:
%
s'
%
(
model
,
obj
))
logger
.
info
(
'New
%
s:
%
s'
,
model
,
obj
)
self
.
changed
=
True
return
obj
else
:
return
qs
[
0
]
# http://docs.saltstack.com/en/latest/ref/states/all/salt.states.cmd.html
def
print_state
(
self
):
changed
=
"yes"
if
len
(
self
.
changed
)
else
"no"
print
"
\n
changed=
%
s comment='
%
s'"
%
(
changed
,
", "
.
join
(
self
.
changed
))
print
"
\n
changed=
%
s"
%
(
"yes"
if
self
.
changed
else
"no"
)
def
handle
(
self
,
*
args
,
**
options
):
self
.
changed
=
[]
self
.
changed
=
False
if
(
DataStore
.
objects
.
exists
()
and
Vlan
.
objects
.
exists
()
and
not
options
[
'force'
]):
...
...
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