mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Create/update project on compute when variables changes
This commit is contained in:
1 parent
83445214be
commit
7b3d5ae5e3
9 files changed
+98
-11
No files matched your search
@@ -460,11 +460,12 @@ class Compute:
|
||||
msg = json.loads(response.data)
|
||||
action = msg.pop("action")
|
||||
event = msg.pop("event")
|
||||
|
||||
if action == "ping":
|
||||
self._cpu_usage_percent = event["cpu_usage_percent"]
|
||||
self._memory_usage_percent = event["memory_usage_percent"]
|
||||
self._controller.notification.emit("compute.updated", self.__json__())
|
||||
elif action == 'project.updated':
|
||||
print(event)
|
||||
else:
|
||||
yield from self._controller.notification.dispatch(action, event, compute_id=self.id)
|
||||
if self._ws:
|
||||
|
||||
@@ -136,6 +136,15 @@ class Project:
|
||||
self.controller.notification.emit("project.updated", self.__json__())
|
||||
self.dump()
|
||||
|
||||
# update on computes
|
||||
for compute in list(self._project_created_on_compute):
|
||||
yield from compute.put(
|
||||
"/projects/{}".format(self._id), {
|
||||
"variables": self.variables
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Called when open/close a project. Cleanup internal stuff
|
||||
@@ -493,12 +502,14 @@ class Project:
|
||||
yield from compute.post("/projects", data={
|
||||
"name": self._name,
|
||||
"project_id": self._id,
|
||||
"path": self._path
|
||||
"path": self._path,
|
||||
"variables": self._variables
|
||||
})
|
||||
else:
|
||||
yield from compute.post("/projects", data={
|
||||
"name": self._name,
|
||||
"project_id": self._id,
|
||||
"variables": self._variables
|
||||
})
|
||||
|
||||
self._project_created_on_compute.add(compute)
|
||||
|
||||
Reference in new issue
Block a user