diff --git a/app/models.py b/app/models.py index 86685dc132dae2b42606e4190c0da9661e60c60c..b5d25a7287115c0084229028857e4adb8654ad9e 100644 --- a/app/models.py +++ b/app/models.py @@ -1852,17 +1852,17 @@ class Task(db.Model): 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 """ - # In session.dirty, we need to check session.is_modified(instance) because when updating a Host, - # the interface is added to the session even if not modified. + # In session.dirty, we need to check session.is_modified(instance) because the instance + # 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.new, it will always be True and we don't need to check it. for kind in ("new", "dirty", "deleted"): for instance in getattr(session, kind): - if isinstance(instance, Interface) and ( + if isinstance(instance, (Host, Interface)) and ( (kind == "dirty" and session.is_modified(instance)) or (kind in ("new", "deleted")) ): diff --git a/app/utils.py b/app/utils.py index f866b2e71597c9bb1ae2ce69e0ef9152840c4159..b05f3cd9f11a9a23e031d6f59e8ca4dc6e831b9e 100644 --- a/app/utils.py +++ b/app/utils.py @@ -296,7 +296,7 @@ def trigger_job_once(name, queue_name="low", **kwargs): def trigger_core_services_update(): """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 blocking the main inventory update when running.