diff --git a/gns3server/api/routes/compute/cloud_nodes.py b/gns3server/api/routes/compute/cloud_nodes.py index 6dc135d55..fd333ab3c 100644 --- a/gns3server/api/routes/compute/cloud_nodes.py +++ b/gns3server/api/routes/compute/cloud_nodes.py @@ -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. """ diff --git a/gns3server/api/routes/compute/nat_nodes.py b/gns3server/api/routes/compute/nat_nodes.py index d271d2798..06788f6a8 100644 --- a/gns3server/api/routes/compute/nat_nodes.py +++ b/gns3server/api/routes/compute/nat_nodes.py @@ -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. """ diff --git a/gns3server/api/routes/compute/vmware_nodes.py b/gns3server/api/routes/compute/vmware_nodes.py index f1e3752ce..30f79902c 100644 --- a/gns3server/api/routes/compute/vmware_nodes.py +++ b/gns3server/api/routes/compute/vmware_nodes.py @@ -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. """ diff --git a/gns3server/api/routes/compute/vpcs_nodes.py b/gns3server/api/routes/compute/vpcs_nodes.py index 143ceef81..bd5181b67 100644 --- a/gns3server/api/routes/compute/vpcs_nodes.py +++ b/gns3server/api/routes/compute/vpcs_nodes.py @@ -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() diff --git a/gns3server/compute/notification_manager.py b/gns3server/compute/notification_manager.py index 44c9ca391..30f0a8050 100644 --- a/gns3server/compute/notification_manager.py +++ b/gns3server/compute/notification_manager.py @@ -54,7 +54,7 @@ def emit(self, action, event, **kwargs): """ 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(): diff --git a/gns3server/controller/notification.py b/gns3server/controller/notification.py index 19672fb0d..3a63d9b87 100644 --- a/gns3server/controller/notification.py +++ b/gns3server/controller/notification.py @@ -73,7 +73,7 @@ def controller_emit(self, action, event): """ 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 @@ def _send_event_to_project(self, project_id, action, event): 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 @@ def _send_event_to_all_projects(self, action, event): """ 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, {}))