Projet

Général

Profil

0001-agent-sync-profile-attributes-from-primary-34210.patch

Frédéric Péters, 09 mars 2020 20:14

Télécharger (2,01 ko)

Voir les différences:

Subject: [PATCH] agent: sync profile attributes from primary (#34210)

 hobo/agent/hobo/management/commands/hobo_deploy.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
hobo/agent/hobo/management/commands/hobo_deploy.py
7 7
from hobo.deploy.signals import notify_agents
8 8
from hobo.environment.models import AVAILABLE_SERVICES, Hobo, Variable
9 9
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
10
from hobo.profile.models import AttributeDefinition
10 11

  
11 12

  
12 13
class Command(hobo_deploy.Command):
......
97 98
                    variable.value = me['slug']
98 99
                    variable.save()
99 100

  
101
                    # and reproduce profile settings from primary
102
                    seen = []
103
                    for i, field in enumerate(hobo_environment['profile']['fields']):
104
                        attribute, created = AttributeDefinition.objects.get_or_create(
105
                                name=field['name'],
106
                                defaults={'label': field['label']})
107
                        for k, v in field.items():
108
                            setattr(attribute, k, v)
109
                        attribute.order = i + 1
110
                        attribute.save()
111
                        seen.append(attribute.name)
112
                    AttributeDefinition.objects.exclude(name__in=seen).delete()
113

  
100 114
            if me.get('secondary'):
101 115
                # on the primary hobo, notify other primary services, this will
102 116
                # get authentic to know about secondary services
103
-