Skip to content
Snippets Groups Projects
Commit c7925d3e authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Trigger core services update on host change

The device_type has an impact on the DHCP configuration.

JIRA INFRA-1846 #action In Progress
parent fe60ff23
No related branches found
No related tags found
No related merge requests found
...@@ -1852,17 +1852,17 @@ class Task(db.Model): ...@@ -1852,17 +1852,17 @@ class Task(db.Model):
def trigger_core_services_update(session): def trigger_core_services_update(session):
"""Trigger core services update on any Interface modification. """Trigger core services update on any Interface or Host modification.
Called by before flush hook Called by before flush hook
""" """
# In session.dirty, we need to check session.is_modified(instance) because when updating a Host, # In session.dirty, we need to check session.is_modified(instance) because the instance
# the interface is added to the session even if not modified. # could have been added to the session without being modified
# In session.deleted, session.is_modified(instance) is usually False (we shouldn't check it). # In session.deleted, session.is_modified(instance) is usually False (we shouldn't check it).
# In session.new, it will always be True and we don't need to check it. # In session.new, it will always be True and we don't need to check it.
for kind in ("new", "dirty", "deleted"): for kind in ("new", "dirty", "deleted"):
for instance in getattr(session, kind): for instance in getattr(session, kind):
if isinstance(instance, Interface) and ( if isinstance(instance, (Host, Interface)) and (
(kind == "dirty" and session.is_modified(instance)) (kind == "dirty" and session.is_modified(instance))
or (kind in ("new", "deleted")) or (kind in ("new", "deleted"))
): ):
......
...@@ -296,7 +296,7 @@ def trigger_job_once(name, queue_name="low", **kwargs): ...@@ -296,7 +296,7 @@ def trigger_job_once(name, queue_name="low", **kwargs):
def trigger_core_services_update(): def trigger_core_services_update():
"""Trigger a job to update the core services (DNS/DHCP/radius) """Trigger a job to update the core services (DNS/DHCP/radius)
This function should be called every time an interface is created/edited This function should be called every time an interface or host is created/edited
The AWX template uses its own inventory that is updated on launch to avoid The AWX template uses its own inventory that is updated on launch to avoid
blocking the main inventory update when running. blocking the main inventory update when running.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment