diff --git a/orchestra/apps/domains/admin.py b/orchestra/apps/domains/admin.py index 9d965078..fb518a13 100644 --- a/orchestra/apps/domains/admin.py +++ b/orchestra/apps/domains/admin.py @@ -81,6 +81,7 @@ class DomainAdmin(AccountAdminMixin, ExtendedModelAdmin): def display_is_top(self, domain): return domain.is_top + display_is_top.short_description = _("Is top") display_is_top.boolean = True display_is_top.admin_order_field = 'top' diff --git a/orchestra/apps/orchestration/backends.py b/orchestra/apps/orchestration/backends.py index c231821d..2efa8eee 100644 --- a/orchestra/apps/orchestration/backends.py +++ b/orchestra/apps/orchestration/backends.py @@ -1,5 +1,6 @@ from functools import partial +from django.db.models.loading import get_model from django.utils import timezone from django.utils.translation import ugettext_lazy as _ @@ -70,6 +71,10 @@ class ServiceBackend(plugins.Plugin): def get_backend(cls, name): return cls.get_plugin(name) + @classmethod + def model_class(cls): + return get_model(cls.model) + def get_banner(self): time = timezone.now().strftime("%h %d, %Y %I:%M:%S") return "Generated by Orchestra at %s" % time diff --git a/orchestra/apps/resources/models.py b/orchestra/apps/resources/models.py index e4c291b5..b65f9505 100644 --- a/orchestra/apps/resources/models.py +++ b/orchestra/apps/resources/models.py @@ -93,7 +93,7 @@ class Resource(models.Model): self.sync_periodic_task() # This only work on tests (multiprocessing used on real deployments) apps.get_app_config('resources').reload_relations() - run('sleep 2 && touch %s/wsgi.py' % get_project_root(), async=True, display=True) + run('sleep 2 && touch %s/wsgi.py' % get_project_root(), async=True) def delete(self, *args, **kwargs): super(Resource, self).delete(*args, **kwargs) diff --git a/orchestra/apps/resources/tasks.py b/orchestra/apps/resources/tasks.py index 9b571c7f..8ffb05c0 100644 --- a/orchestra/apps/resources/tasks.py +++ b/orchestra/apps/resources/tasks.py @@ -1,5 +1,4 @@ from celery import shared_task -from django.db.models.loading import get_model from orchestra.apps.orchestration.models import BackendOperation as Operation from orchestra.models.utils import get_model_field_path @@ -16,7 +15,7 @@ def monitor(resource_id, ids=None): # Execute monitors for monitor_name in resource.monitors: backend = ServiceMonitor.get_backend(monitor_name) - model = get_model(backend.model) + model = backend.model_class() kwargs = {} if ids: path = get_model_field_path(model, resource_model) diff --git a/orchestra/utils/system.py b/orchestra/utils/system.py index a51434f5..dffcf6e6 100644 --- a/orchestra/utils/system.py +++ b/orchestra/utils/system.py @@ -113,7 +113,7 @@ def run(command, display=False, error_codes=[0], silent=False, stdin='', async=F if return_code not in error_codes: out.failed = True msg = "\nrun() encountered an error (return code %s) while executing '%s'\n" - msg = msg % (p.returncode, command) + msg = msg % (return_code, command) if display: sys.stderr.write("\n\033[1;31mCommandError: %s %s\033[m\n" % (msg, err)) if not silent: