Commit 3159f5f9 by Bach Dániel

dashboard: fix status reporting in

parent 45cd15cd
......@@ -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))'New %s: %s', model, obj)
self.changed = True
return obj
return qs[0]
def print_state(self):
changed = "yes" if len(self.changed) else "no"
print "\nchanged=%s comment='%s'" % (changed, ", ".join(self.changed))
print "\nchanged=%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']):
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 sign in to comment