diff --git a/python/neutron-understack/neutron_understack/config.py b/python/neutron-understack/neutron_understack/config.py index 6b9118221..02d5338c8 100644 --- a/python/neutron-understack/neutron_understack/config.py +++ b/python/neutron-understack/neutron_understack/config.py @@ -32,9 +32,6 @@ cfg.BoolOpt( "undersync_dry_run", default=True, help="Call Undersync with dry-run mode" ), - cfg.BoolOpt( - "undersync_force", default=False, help="Call Undersync with force mode" - ), ] diff --git a/python/neutron-understack/neutron_understack/neutron_understack_mech.py b/python/neutron-understack/neutron_understack/neutron_understack_mech.py index d15982624..a5e53fe0d 100644 --- a/python/neutron-understack/neutron_understack/neutron_understack_mech.py +++ b/python/neutron-understack/neutron_understack/neutron_understack_mech.py @@ -223,9 +223,8 @@ def update_port_postcommit(self, context): nb_vlan_group_id = self.update_nautobot(network_id, connected_interface_uuid) self.undersync.sync_devices( - nb_vlan_group_id, - cfg.CONF.ml2_understack.undersync_force, - cfg.CONF.ml2_understack.undersync_dry_run, + vlan_group_uuids=nb_vlan_group_id, + dry_run=cfg.CONF.ml2_understack.undersync_dry_run, ) def delete_port_precommit(self, context): diff --git a/python/neutron-understack/neutron_understack/undersync.py b/python/neutron-understack/neutron_understack/undersync.py index 7d6285e72..e8dcfe12a 100644 --- a/python/neutron-understack/neutron_understack/undersync.py +++ b/python/neutron-understack/neutron_understack/undersync.py @@ -13,11 +13,13 @@ def __init__( self, auth_token: str | None = None, api_url: str | None = None, + timeout: int = 90 ) -> None: """Simple client for Undersync.""" self.token = auth_token or self.fetch_undersync_token() self.url = "http://undersync-service.undersync.svc.cluster.local:8080" self.api_url = api_url or self.url + self.timeout = timeout def fetch_undersync_token(self): file = pathlib.Path("/etc/undersync/token") @@ -52,20 +54,18 @@ def client(self): } return session - def sync(self, uuids: str) -> requests.Response: - response = self.client.post(f"{self.api_url}/v1/vlan-group/{uuids}/sync") - LOG.debug("undersync sync resp: %(resp)s", {"resp": response.json()}) + def undersync_post(self, action: str, uuids: str) -> requests.Response: + response = self.client.post(f"{self.api_url}/v1/vlan-group/{uuids}/{action}", + timeout=self.timeout) + LOG.debug("undersync %(action)s resp: %(resp)s", {"resp": response.json(), "action": action}) self.log_for_status(response) return response + def sync(self, uuids: str) -> requests.Response: + return self.undersync_post("sync", uuids) + def dry_run(self, uuids: str) -> requests.Response: - response = self.client.post(f"{self.api_url}/v1/vlan-group/{uuids}/dry-run") - LOG.debug("undersync dry_ryn resp: %(resp)s", {"resp": response.json()}) - self.log_for_status(response) - return response + return self.undersync_post("dry-run", uuids) def force(self, uuids: str) -> requests.Response: - response = self.client.post(f"{self.api_url}/v1/vlan-group/{uuids}/force") - LOG.debug("undersync force resp: %(resp)s", {"resp": response.json()}) - self.log_for_status(response) - return response + return self.undersync_post("force", uuids)