0001-command-checking-services-status.patch
hobo/environment/management/commands/check_operational.py | ||
---|---|---|
1 |
from optparse import make_option |
|
2 | ||
3 |
from django.core.management.base import BaseCommand |
|
4 | ||
5 |
from hobo.environment import models |
|
6 | ||
7 |
class Command(BaseCommand): |
|
8 |
help = '''Checks if all services are operational''' |
|
9 | ||
10 |
def handle(self, *args, **kwargs): |
|
11 |
for klass in models.AVAILABLE_SERVICES: |
|
12 |
for obj in klass.objects.all(): |
|
13 |
obj.check_operational() |
|
14 |
if int(kwargs.get('verbosity')) > 1: |
|
15 |
if obj.is_operational(): |
|
16 |
print("%s is operational" % obj.title) |
|
17 |
else: |
|
18 |
print self.style.NOTICE('%s is still NOT operational' % obj.title) |
|
19 |
if obj.last_operational_success_timestamp: |
|
20 |
print self.style.NOTICE(' last operational success: %s' % obj.last_operational_success_timestamp) |
|
0 |
- |