agent: sync profile attributes from primary (#34210)
This commit is contained in:
parent
0ca228fa96
commit
70a230090b
|
@ -7,6 +7,7 @@ from hobo.agent.common.management.commands import hobo_deploy
|
|||
from hobo.deploy.signals import notify_agents
|
||||
from hobo.environment.models import AVAILABLE_SERVICES, Hobo, Variable
|
||||
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
|
||||
from hobo.profile.models import AttributeDefinition
|
||||
|
||||
|
||||
class Command(hobo_deploy.Command):
|
||||
|
@ -97,6 +98,20 @@ class Command(hobo_deploy.Command):
|
|||
variable.value = me['slug']
|
||||
variable.save()
|
||||
|
||||
# and reproduce profile settings from primary
|
||||
if 'profile' in hobo_environment:
|
||||
seen = []
|
||||
for i, field in enumerate(hobo_environment['profile']['fields']):
|
||||
attribute, created = AttributeDefinition.objects.get_or_create(
|
||||
name=field['name'],
|
||||
defaults={'label': field['label']})
|
||||
for k, v in field.items():
|
||||
setattr(attribute, k, v)
|
||||
attribute.order = i + 1
|
||||
attribute.save()
|
||||
seen.append(attribute.name)
|
||||
AttributeDefinition.objects.exclude(name__in=seen).delete()
|
||||
|
||||
if me.get('secondary'):
|
||||
# on the primary hobo, notify other primary services, this will
|
||||
# get authentic to know about secondary services
|
||||
|
|
Loading…
Reference in New Issue