Commit 3342a545 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Refactor minor details

parent 2ec58c45
......@@ -39,19 +39,6 @@ def questionnaire_default():
def credential_default():
return {}
# takes a list of states
# return '<state>' if all states are equal to '<state>'
# else it returns 'mixed'
def analyze_states(states):
_state = ''
for state in states:
if _state == '':
_state = state
elif _state != state:
return 'mixed'
return _state
# singleton for simple configs
......@@ -529,9 +516,12 @@ class Service(models.Model):
# all group deployments have the same keys
# TODO check that assumption
deployment = user.deployments.filter(group=group)
if deployment.exists():
deployment = user.deployments.get(group=group)
except Deployment.DoesNotExist:
LOGGER.error('Inconsistency in group deployment')
class SSHPublicKey(models.Model):
......@@ -817,7 +807,22 @@ class DeploymentState(models.Model):
def state(self):
return analyze_states(self.states)
if self.states:
_state = ''
for state in self.states:
if _state == '':
_state = state
elif _state != state:
return 'mixed'
return _state
# if we have no states we have nothing to do
return self.state_target
def target_reached(self):
return self.state_target == self.state
def service(self):
......@@ -831,10 +836,6 @@ class DeploymentState(models.Model):
def group(self):
def target_reached(self):
return self.state_target == self.state
# get a state for a user/service.
# if it does not exist it is created
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