add per-service default set of variables (#5841)

This commit is contained in:
Frédéric Péters 2014-10-31 15:35:25 +01:00
parent a689108198
commit a9d8481489
2 changed files with 19 additions and 0 deletions

View File

@ -120,6 +120,15 @@ SERVICE_URL_TEMPLATE = 'https://${app}.example.net'
# }
SERVICE_TEMPLATES = None
# SERVICE_EXTRA_VARIABLES: variables to create automatically for the
# given service types.
#
# Example:
# SERVICE_EXTRA_VARIABLES = {
# 'wcs': ['legal_url', 'commune_url', 'domain_key'],
# }
SERVICE_EXTRA_VARIABLES = None
AGENT_HOST_PATTERNS = None
AGENT_WCS_APP_DIR = '/var/lib/wcs'
AGENT_WCS_COMMAND = '/usr/sbin/wcsctl check-hobos'

View File

@ -88,6 +88,16 @@ class ServiceBase(models.Model):
def name(self):
return self.title
def save(self, *args, **kwargs):
is_new = (self.id is None)
super(ServiceBase, self).save(*args, **kwargs)
if is_new and settings.SERVICE_EXTRA_VARIABLES:
for variable in settings.SERVICE_EXTRA_VARIABLES.get(self.Extra.service_id, []):
v = Variable()
v.name = variable
v.service = self
v.save()
class Authentic(ServiceBase):
class Meta: