1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 16:28:11 +00:00
This commit is contained in:
grossmj 2021-06-07 14:08:21 +09:30
parent 8825831106
commit 4e34ab8e4f
4 changed files with 37 additions and 0 deletions

View File

@ -124,6 +124,7 @@ class Link:
self._link_type = "ethernet" self._link_type = "ethernet"
self._suspended = False self._suspended = False
self._filters = {} self._filters = {}
self._link_style = {}
@property @property
def filters(self): def filters(self):
@ -209,6 +210,13 @@ class Link:
self._project.emit_notification("link.updated", self.__json__()) self._project.emit_notification("link.updated", self.__json__())
self._project.dump() self._project.dump()
async def update_link_style(self, link_style):
if link_style != self._link_style:
self._link_style = link_style
await self.update()
self._project.emit_notification("link.updated", self.__json__())
self._project.dump()
@property @property
def created(self): def created(self):
""" """
@ -454,6 +462,7 @@ class Link:
"nodes": res, "nodes": res,
"link_id": self._id, "link_id": self._id,
"filters": self._filters, "filters": self._filters,
"link_style": self._link_style,
"suspend": self._suspended "suspend": self._suspended
} }
return { return {
@ -466,5 +475,6 @@ class Link:
"capture_compute_id": self.capture_compute_id, "capture_compute_id": self.capture_compute_id,
"link_type": self._link_type, "link_type": self._link_type,
"filters": self._filters, "filters": self._filters,
"link_style": self._link_style,
"suspend": self._suspended "suspend": self._suspended
} }

View File

@ -957,6 +957,8 @@ class Project:
link = await self.add_link(link_id=link_data["link_id"]) link = await self.add_link(link_id=link_data["link_id"])
if "filters" in link_data: if "filters" in link_data:
await link.update_filters(link_data["filters"]) await link.update_filters(link_data["filters"])
if "link_style" in link_data:
await link.update_link_style(link_data["link_style"])
for node_link in link_data.get("nodes", []): for node_link in link_data.get("nodes", []):
node = self.get_node(node_link["node_id"]) node = self.get_node(node_link["node_id"])
port = node.get_port(node_link["adapter_number"], node_link["port_number"]) port = node.get_port(node_link["adapter_number"], node_link["port_number"])

View File

@ -64,6 +64,8 @@ class LinkHandler:
link = await project.add_link() link = await project.add_link()
if "filters" in request.json: if "filters" in request.json:
await link.update_filters(request.json["filters"]) await link.update_filters(request.json["filters"])
if "link_style" in request.json:
await link.update_link_style(request.json["link_style"])
if "suspend" in request.json: if "suspend" in request.json:
await link.update_suspend(request.json["suspend"]) await link.update_suspend(request.json["suspend"])
try: try:
@ -135,6 +137,8 @@ class LinkHandler:
link = project.get_link(request.match_info["link_id"]) link = project.get_link(request.match_info["link_id"])
if "filters" in request.json: if "filters" in request.json:
await link.update_filters(request.json["filters"]) await link.update_filters(request.json["filters"])
if "link_style" in request.json:
await link.update_link_style(request.json["link_style"])
if "suspend" in request.json: if "suspend" in request.json:
await link.update_suspend(request.json["suspend"]) await link.update_suspend(request.json["suspend"])
if "nodes" in request.json: if "nodes" in request.json:

View File

@ -68,6 +68,27 @@ LINK_OBJECT_SCHEMA = {
"type": "boolean", "type": "boolean",
"description": "Suspend the link" "description": "Suspend the link"
}, },
"link_style": {
"type": "object",
"description": "Link line style",
"items": {
"type": "object",
"properties": {
"color": {
"description": "Link line color",
"type": "string"
},
"width": {
"description": "Link line width",
"type": "integer"
},
"type": {
"description": "Link line type",
"type": "integer"
}
}
}
},
"filters": FILTER_OBJECT_SCHEMA, "filters": FILTER_OBJECT_SCHEMA,
"capturing": { "capturing": {
"description": "Read only property. True if a capture running on the link", "description": "Read only property. True if a capture running on the link",