|
16 | 16 | from django.conf import settings |
17 | 17 | from django.contrib.auth.models import User |
18 | 18 | from django.db import models |
19 | | -from django.db.models.signals import post_save |
20 | 19 | from django.dispatch import receiver |
21 | 20 | from django.dispatch.dispatcher import Signal |
22 | 21 | from django.utils.encoding import python_2_unicode_compatible |
23 | | -from rest_framework.authtoken.models import Token |
24 | 22 |
|
25 | 23 | from api import fields |
26 | 24 | from celerytasks import controller |
@@ -323,9 +321,9 @@ def scale_containers(self, **kwargs): |
323 | 321 | return databag |
324 | 322 |
|
325 | 323 | def balance(self, **kwargs): |
326 | | - containers_balanced = self._balance_containers() |
| 324 | + changed = self._balance_containers() |
327 | 325 | databag = self.calculate() |
328 | | - if containers_balanced: |
| 326 | + if changed: |
329 | 327 | self.converge(databag) |
330 | 328 | return databag |
331 | 329 |
|
@@ -376,12 +374,6 @@ def _balance_containers(self, **kwargs): |
376 | 374 | def __str__(self): |
377 | 375 | return self.id |
378 | 376 |
|
379 | | - def prepare_provider(self, *args, **kwargs): |
380 | | - tasks = import_tasks(self.flavor.provider.type) |
381 | | - args = (self.id, self.flavor.provider.creds.copy(), |
382 | | - self.flavor.params.copy()) |
383 | | - return tasks.prepare_formation.subtask(args) |
384 | | - |
385 | 377 | def calculate(self): |
386 | 378 | "Return a Chef data bag item for this formation" |
387 | 379 | release = self.release_set.all().order_by('-created')[0] |
@@ -771,58 +763,3 @@ def new_release(sender, **kwargs): |
771 | 763 | image=image, config=config, build=build, version=new_version) |
772 | 764 | return release |
773 | 765 |
|
774 | | - |
775 | | -@python_2_unicode_compatible |
776 | | -class Access(UuidAuditedModel): |
777 | | - |
778 | | - """ |
779 | | - An access control list (ACL) entry specifying what role a user has for |
780 | | - an app. |
781 | | -
|
782 | | - A user is considered always to have "admin" access to his or her own |
783 | | - apps whether or not a specific Access entry exists. |
784 | | - """ |
785 | | - |
786 | | - VIEWER = 'viewer' |
787 | | - USER = 'user' |
788 | | - ADMIN = 'admin' |
789 | | - ACCESS_ROLES = ( |
790 | | - (VIEWER, 'Viewer'), |
791 | | - (USER, 'User'), |
792 | | - (ADMIN, 'Administrator'), |
793 | | - ) |
794 | | - |
795 | | - owner = models.ForeignKey(settings.AUTH_USER_MODEL) |
796 | | - formation = models.ForeignKey('Formation') |
797 | | - role = models.CharField(max_length=6, choices=ACCESS_ROLES, default=USER) |
798 | | - |
799 | | - class Meta: |
800 | | - """Metadata options for an Access model.""" |
801 | | - verbose_name_plural = 'accesses' |
802 | | - |
803 | | - def __str__(self): |
804 | | - return '{0}: {1} is {2}'.format(self.app, self.user, self.role) |
805 | | - |
806 | | - |
807 | | -@python_2_unicode_compatible |
808 | | -class Event(UuidAuditedModel): |
809 | | - |
810 | | - """ |
811 | | - A change in an Application's state worth persisting so it can be |
812 | | - searched for in the future. |
813 | | - """ |
814 | | - |
815 | | - owner = models.ForeignKey(settings.AUTH_USER_MODEL) |
816 | | - formation = models.ForeignKey('Formation') |
817 | | - |
818 | | - def __str__(self): |
819 | | - # TODO: what's a useful string representation of this object? |
820 | | - return '{0} event ?'.format(self.app) |
821 | | - |
822 | | - |
823 | | -@receiver(post_save, sender=settings.AUTH_USER_MODEL) |
824 | | -def create_auth_token(sender, instance=None, created=False, **kwargs): |
825 | | - """Adds an auth Token to each newly created user.""" |
826 | | - if created: |
827 | | - # pylint: disable=E1101 |
828 | | - Token.objects.create(user=instance) |
0 commit comments