Commit 151380fb authored by lukas.burgey's avatar lukas.burgey

Lint the deployments module

parent ed9af36f
......@@ -62,21 +62,15 @@ def user_info_default(): # pragma: no cover
def get_deployment(user, vo=None, service=None):
if vo is not None and service is not None:
raise ValueError('Cannot create deployment for both vo and service')
if vo is not None:
if vo is not None and service is None:
# get_deployment updates automatically
return VODeployment.get_deployment(user, vo)
if service is not None:
if service is not None and vo is None:
# get_deployment updates automatically
return ServiceDeployment.get_deployment(user, service)
deps = Deployment.objects.filter(user=user)
for dep in deps:
dep.update()
return deps
raise ValueError("Exactly one of 'vo' or 'service' must be set")
class Deployment(PolymorphicModel):
......@@ -211,17 +205,6 @@ class VODeployment(Deployment):
def routing_key(self):
return self.vo.name
@classmethod
def create(cls, *args, **kwargs):
user = kwargs.get('user')
vo = kwargs.get('vo')
if vo not in user.vos.all():
raise ValueError('User is not permitted to have a deployment of this vo!')
return cls(*args, **kwargs)
# _assure_states_exist creates missing DeploymentState for this deployment
# returns True if new states were created
def _assure_states_exist(self):
......@@ -279,19 +262,6 @@ class ServiceDeployment(Deployment):
def routing_key(self):
return self.service.name
@classmethod
def create(cls, *args, **kwargs):
user = kwargs.get('user')
service = kwargs.get('service')
# check if one of the users vos can be used for the service
for vo in user.vos.all():
if vo in service.vos.all():
return cls(*args, **kwargs)
raise ValueError('User is not permitted to have a deployment of this service!')
def _assure_states_exist(self):
_, created = DeploymentState.get_or_create(self.user, self.service, self)
return created
......@@ -642,7 +612,7 @@ class DeploymentState(models.Model):
for key in self.user.ssh_keys.all():
CredentialState.get_credential_state(key, self)
def _set_state(self, state, publish_to_user=False, publish_to_client=False):
def _set_state(self, state):
self._assure_credential_states_exist()
# same state
......@@ -656,12 +626,6 @@ class DeploymentState(models.Model):
self.save()
if publish_to_user:
self.publish_to_user()
if publish_to_client:
self.publish_to_client()
def publish_to_user(self):
if self.user is None:
LOGGER.debug(self.msg('publish_to_user: User is None'))
......@@ -676,10 +640,6 @@ class DeploymentState(models.Model):
)
def publish_to_client(self):
# no need to publish if not pending
if not self.is_pending:
return
self.audit_log_request()
LOGGER.log(settings.DEBUGX_LOG_LEVEL, self.msg('publish_to_client'))
......
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