Custom patches for GNS3 network topology simulator & planning software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. Author: Pekka Helenius <pekka.helenius@fjordtek.com>
  2. Date: Sun, 22 Aug 2021 17:12:44 +0200
  3. Subject: [PATCH] GNS3 Server: Link colors.
  4. Add link color support for GNS3 Server.
  5. --- a/gns3server/schemas/link.py
  6. +++ b/gns3server/schemas/link.py
  7. @@ -68,6 +68,27 @@
  8. "type": "boolean",
  9. "description": "Suspend the link"
  10. },
  11. + "link_style": {
  12. + "type": "object",
  13. + "description": "Link line style",
  14. + "items": {
  15. + "type": "object",
  16. + "properties": {
  17. + "color": {
  18. + "description": "Link line color",
  19. + "type": "string"
  20. + },
  21. + "width": {
  22. + "description": "Link line width",
  23. + "type": "integer"
  24. + },
  25. + "type": {
  26. + "description": "Link line type",
  27. + "type": "integer"
  28. + }
  29. + }
  30. + }
  31. + },
  32. "filters": FILTER_OBJECT_SCHEMA,
  33. "capturing": {
  34. "description": "Read only property. True if a capture running on the link",
  35. --- a/gns3server/handlers/api/controller/link_handler.py
  36. +++ b/gns3server/handlers/api/controller/link_handler.py
  37. @@ -64,6 +64,8 @@
  38. link = await project.add_link()
  39. if "filters" in request.json:
  40. await link.update_filters(request.json["filters"])
  41. + if "link_style" in request.json:
  42. + await link.update_link_style(request.json["link_style"])
  43. if "suspend" in request.json:
  44. await link.update_suspend(request.json["suspend"])
  45. try:
  46. @@ -135,6 +137,8 @@
  47. link = project.get_link(request.match_info["link_id"])
  48. if "filters" in request.json:
  49. await link.update_filters(request.json["filters"])
  50. + if "link_style" in request.json:
  51. + await link.update_link_style(request.json["link_style"])
  52. if "suspend" in request.json:
  53. await link.update_suspend(request.json["suspend"])
  54. if "nodes" in request.json:
  55. --- a/gns3server/controller/project.py
  56. +++ b/gns3server/controller/project.py
  57. @@ -905,6 +905,8 @@
  58. link = await self.add_link(link_id=link_data["link_id"])
  59. if "filters" in link_data:
  60. await link.update_filters(link_data["filters"])
  61. + if "link_style" in link_data:
  62. + await link.update_link_style(link_data["link_style"])
  63. for node_link in link_data.get("nodes", []):
  64. node = self.get_node(node_link["node_id"])
  65. port = node.get_port(node_link["adapter_number"], node_link["port_number"])
  66. --- a/gns3server/controller/link.py
  67. +++ b/gns3server/controller/link.py
  68. @@ -125,6 +125,8 @@ class Link:
  69. self._suspended = False
  70. self._filters = {}
  71. + self._link_style = {}
  72. +
  73. @property
  74. def filters(self):
  75. """
  76. @@ -209,6 +211,12 @@ class Link:
  77. self._project.emit_notification("link.updated", self.__json__())
  78. self._project.dump()
  79. + async def update_link_style(self, link_style):
  80. + if link_style != self._link_style:
  81. + self._link_style = link_style
  82. + self._project.emit_notification("link.updated", self.__json__())
  83. + self._project.dump()
  84. +
  85. @property
  86. def created(self):
  87. """
  88. @@ -446,6 +454,7 @@ class Link:
  89. "nodes": res,
  90. "link_id": self._id,
  91. "filters": self._filters,
  92. + "link_style": self._link_style,
  93. "suspend": self._suspended
  94. }
  95. return {
  96. @@ -457,5 +466,6 @@ class Link:
  97. "capture_file_path": self.capture_file_path,
  98. "link_type": self._link_type,
  99. "filters": self._filters,
  100. + "link_style": self._link_style,
  101. "suspend": self._suspended
  102. }