Commit 00589692 authored by lukas.burgey's avatar lukas.burgey

Remove _assure_states .. nonsense

parent 0866fd9d
......@@ -111,20 +111,10 @@ class Deployment(PolymorphicModel):
def target_reached(self):
return self.state_target == self.state
def _assure_states_exist(self): # pragma: no cover
raise NotImplementedError('Should be overwritten in subclass')
def update(self):
self._assure_states_exist()
self.publish_to_user()
# call when you changed Deployment.state_target
def target_changed(self):
LOGGER.debug(self.msg('Target changed to {}'.format(self.state_target)))
self._assure_states_exist()
for item in self.states.all():
item.dep_target_changed()
......@@ -192,18 +182,6 @@ class VODeployment(Deployment):
def services(self):
return self.vo.services.all()
# _assure_states_exist creates missing DeploymentState for this deployment
# returns True if new states were created
def _assure_states_exist(self):
created_new_states = False
for service in self.services:
_, created = DeploymentState.get_or_create(self.user, service, self)
if created:
created_new_states = True
return created_new_states
@classmethod
def get_deployment(cls, user, vo):
deployment, created = cls.objects.get_or_create(
......@@ -213,7 +191,9 @@ class VODeployment(Deployment):
if created:
LOGGER.debug(deployment.msg('Created'))
deployment.update() # creates deployment states and publishes the creation
for service in vo.services.all():
DeploymentState.get_or_create(user, service, deployment)
return deployment
......@@ -240,16 +220,14 @@ class ServiceDeployment(Deployment):
on_delete=models.CASCADE,
)
def _assure_states_exist(self):
_, created = DeploymentState.get_or_create(self.user, self.service, self)
return created
@classmethod
def get_deployment(cls, user, service):
deployment, created = cls.objects.get_or_create(user=user, service=service)
if created:
LOGGER.debug(deployment.msg('Created'))
deployment.update()
DeploymentState.get_or_create(user, service, deployment)
return deployment
......
......@@ -86,10 +86,6 @@ class ConfigurationView(views.APIView):
except VO.DoesNotExist:
service.vos.add(vo)
# we need to update the Deployments here
for dep in vo.vo_deployments.all():
dep.update()
# returns the service ID to service mapping contained in the request
def parse_sid_to_service(self, request):
self.sid_to_service = {}
......
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 to comment