1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-29 02:08:10 +00:00

Fix error 500 on PUT for cloud, nat, vmware and vpcs nodes. Fixes #2426

This commit is contained in:
grossmj 2024-11-19 12:21:35 +10:00
parent 8db81de153
commit a00f53fbaa
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD
6 changed files with 17 additions and 11 deletions

View File

@ -85,7 +85,7 @@ def get_cloud(node: Cloud = Depends(dep_node)) -> schemas.Cloud:
@router.put("/{node_id}", response_model=schemas.Cloud)
def update_cloud(node_data: schemas.CloudUpdate, node: Cloud = Depends(dep_node)) -> schemas.Cloud:
async def update_cloud(node_data: schemas.CloudUpdate, node: Cloud = Depends(dep_node)) -> schemas.Cloud:
"""
Update a cloud node.
"""

View File

@ -80,7 +80,7 @@ def get_nat_node(node: Nat = Depends(dep_node)) -> schemas.NAT:
@router.put("/{node_id}", response_model=schemas.NAT)
def update_nat_node(node_data: schemas.NATUpdate, node: Nat = Depends(dep_node)) -> schemas.NAT:
async def update_nat_node(node_data: schemas.NATUpdate, node: Nat = Depends(dep_node)) -> schemas.NAT:
"""
Update a NAT node.
"""

View File

@ -97,7 +97,7 @@ def get_vmware_node(node: VMwareVM = Depends(dep_node)) -> schemas.VMware:
response_model=schemas.VMware,
dependencies=[Depends(compute_authentication)]
)
def update_vmware_node(node_data: schemas.VMwareUpdate, node: VMwareVM = Depends(dep_node)) -> schemas.VMware:
async def update_vmware_node(node_data: schemas.VMwareUpdate, node: VMwareVM = Depends(dep_node)) -> schemas.VMware:
"""
Update a VMware node.
"""

View File

@ -91,15 +91,21 @@ def get_vpcs_node(node: VPCSVM = Depends(dep_node)) -> schemas.VPCS:
response_model=schemas.VPCS,
dependencies=[Depends(compute_authentication)]
)
def update_vpcs_node(node_data: schemas.VPCSUpdate, node: VPCSVM = Depends(dep_node)) -> schemas.VPCS:
async def update_vpcs_node(node_data: schemas.VPCSUpdate, node: VPCSVM = Depends(dep_node)) -> schemas.VPCS:
"""
Update a VPCS node.
"""
node_data = jsonable_encoder(node_data, exclude_unset=True)
node.name = node_data.get("name", node.name)
node.console = node_data.get("console", node.console)
node.console_type = node_data.get("console_type", node.console_type)
name = node_data.get("name", node.name)
if node.name != name:
node.name = name
console = node_data.get("console", node.console)
if node.console != console:
node.console = console
console_type = node_data.get("console_type", node.console_type)
if node.console_type != console_type:
node.console_type = console_type
node.updated()
return node.asdict()

View File

@ -54,7 +54,7 @@ class NotificationManager:
"""
for listener in self._listeners:
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
asyncio.get_running_loop().call_soon_threadsafe(listener.put_nowait, (action, event, kwargs))
@staticmethod
def reset():

View File

@ -73,7 +73,7 @@ class Notification:
"""
for controller_listener in self._controller_listeners:
asyncio.get_event_loop().call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))
asyncio.get_running_loop().call_soon_threadsafe(controller_listener.put_nowait, (action, event, {}))
def project_has_listeners(self, project_id):
"""
@ -134,7 +134,7 @@ class Notification:
except KeyError:
return
for listener in project_listeners:
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))
asyncio.get_running_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))
def _send_event_to_all_projects(self, action, event):
"""
@ -146,4 +146,4 @@ class Notification:
"""
for project_listeners in self._project_listeners.values():
for listener in project_listeners:
asyncio.get_event_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))
asyncio.get_running_loop().call_soon_threadsafe(listener.put_nowait, (action, event, {}))