mirror of
https://github.com/sophos/sophos-firewall-sdk.git
synced 2026-04-27 08:35:49 +03:00
[GH-ISSUE #88] API Multiple Connections #1
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/sophos-firewall-sdk#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mgesca46 on GitHub (Nov 26, 2024).
Original GitHub issue: https://github.com/sophos/sophos-firewall-sdk/issues/88
Hi,
i have a question about the API with the following code:
when i made a single POST request the API is able to create the ip host and update the host group.
But when a send 3/4 POST request at the same time the API is able to create the IP Host but is not able to update the host group.
This is occurred also with multiprocessing and threading.
Can you help me?
Thank you
@mamullen13316 commented on GitHub (Dec 11, 2024):
The update method works by first doing a get on the existing hostgroup, extracting the current members of the hostgroup and adding the new one to it. Then it submits the payload including all of the members. It has to be done that way due to how the API currently works. There's no "add to list" feature when updating a list in the API. If you try to use set operation of "update" and only include a new host in the payload, any existing members get erased. You have to first get the existing and add them to the payload along with any new additions.
Trying to update the same group at the same time might yield inconsistent results because of this. If two processes start at the same time updating a hostgroup, the second process might not see the host added by the first process when it does the get, because the first process didn't complete yet. Is that what you mean by it is not able to update the host group? One or more of the additions is missing?
I'd suggest doing some type of task queue to ensure that the updates are performed in the sequence that they are submitted to the app. For example: https://medium.com/@Aman-tech/celery-with-flask-d1f1c555ceb7
@mgesca46 commented on GitHub (Dec 12, 2024):
Hi @mamullen13316 ,
thank you for your reply.
I just changed the code to celery days ago.
Now seems to be working.
Thank you for your information.
I close the issue