Skip to content

Commit

Permalink
remove undersync force option from neutron config
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Fencik committed Nov 25, 2024
1 parent af84243 commit a436485
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
3 changes: 0 additions & 3 deletions python/neutron-understack/neutron_understack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
22 changes: 11 additions & 11 deletions python/neutron-understack/neutron_understack/undersync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

0 comments on commit a436485

Please sign in to comment.