1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Breaking change for 2.X topologies! Store width and height for nodes & a

style properties
This commit is contained in:
Julien Duponchelle 2016-07-01 14:37:59 +02:00
parent fe7bcae6a1
commit 818174824b
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
4 changed files with 55 additions and 24 deletions

View File

@ -59,16 +59,17 @@ class Node:
self._command_line = None self._command_line = None
self._node_directory = None self._node_directory = None
self._status = "stopped" self._status = "stopped"
self._width = 70
self._height = 70
self._x = 0 self._x = 0
self._y = 0 self._y = 0
self._z = 0 self._z = 0
self._symbol = ":/symbols/computer.svg" self._symbol = ":/symbols/computer.svg"
self._label = { self._label = {
"color": "#ff000000", "y": -25,
"y": -25.0,
"text": "", "text": "",
"font": "TypeWriter,10,-1,5,75,0,0,0,0,0", "style": "",
"x": -17.0234375 "x": -17
} }
# Update node properties with additional elements # Update node properties with additional elements
for prop in kwargs: for prop in kwargs:
@ -164,6 +165,22 @@ class Node:
def z(self, val): def z(self, val):
self._z = val self._z = val
@property
def width(self):
return self._width
@width.setter
def width(self, val):
self._width = val
@property
def height(self):
return self._height
@height.setter
def height(self, val):
self._height = val
@property @property
def symbol(self): def symbol(self):
return self._symbol return self._symbol
@ -396,9 +413,11 @@ class Node:
"console_type": self._console_type, "console_type": self._console_type,
"properties": self._properties, "properties": self._properties,
"label": self._label, "label": self._label,
"x": int(self._x), "x": self._x,
"y": int(self._y), "y": self._y,
"z": int(self._z), "z": self._z,
"width": self._width,
"height": self._height,
"symbol": self._symbol "symbol": self._symbol
} }
return { return {
@ -415,8 +434,10 @@ class Node:
"properties": self._properties, "properties": self._properties,
"status": self._status, "status": self._status,
"label": self._label, "label": self._label,
"x": int(self._x), "x": self._x,
"y": int(self._y), "y": self._y,
"z": int(self._z), "z": self._z,
"width": self._width,
"height": self._height,
"symbol": self._symbol "symbol": self._symbol
} }

View File

@ -18,19 +18,19 @@
LABEL_OBJECT_SCHEMA = { LABEL_OBJECT_SCHEMA = {
"type": "object", "type": "object",
"properties": { "properties": {
"color": {
"type": "string",
"pattern": "^#[0-9a-f]{6,8}$"
},
"font": {
"type": "string",
"minLength": 1
},
"text": {"type": "string"}, "text": {"type": "string"},
"x": {"type": "number"}, "style": {
"y": {"type": "number"}, "description": "SVG style attribute",
"z": {"type": "number"}, "type": "string"
"rotation": {"type": "number"} },
"x": {
"description": "Relative X position of the label",
"type": "integer"
},
"y": {
"description": "Relative Y position of the label",
"type": "integer"
},
}, },
"required": [ "required": [
"text", "text",

View File

@ -144,6 +144,14 @@ NODE_OBJECT_SCHEMA = {
"type": "string", "type": "string",
"minLength": 1 "minLength": 1
}, },
"width": {
"description": "Width of the node",
"type": "integer"
},
"height": {
"description": "Height of the node",
"type": "integer"
},
"x": { "x": {
"description": "X position of the node", "description": "X position of the node",
"type": "integer" "type": "integer"

View File

@ -67,6 +67,8 @@ def test_json(node, compute):
"x": node.x, "x": node.x,
"y": node.y, "y": node.y,
"z": node.z, "z": node.z,
"width": node.width,
"height": node.height,
"symbol": node.symbol, "symbol": node.symbol,
"label": node.label "label": node.label
} }
@ -81,6 +83,8 @@ def test_json(node, compute):
"x": node.x, "x": node.x,
"y": node.y, "y": node.y,
"z": node.z, "z": node.z,
"width": node.width,
"height": node.height,
"symbol": node.symbol, "symbol": node.symbol,
"label": node.label "label": node.label
} }
@ -186,7 +190,6 @@ def test_update_properties(node, compute, project, async_run, controller):
controller._notification.emit.assert_called_with("node.updated", node_notif) controller._notification.emit.assert_called_with("node.updated", node_notif)
def test_update_only_controller(node, controller, compute, project, async_run): def test_update_only_controller(node, controller, compute, project, async_run):
""" """
When updating property used only on controller we don't need to When updating property used only on controller we don't need to
@ -206,7 +209,6 @@ def test_update_only_controller(node, controller, compute, project, async_run):
assert not controller._notification.emit.called assert not controller._notification.emit.called
def test_update_no_changes(node, compute, project, async_run): def test_update_no_changes(node, compute, project, async_run):
""" """
We don't call the compute node if all compute properties has not changed We don't call the compute node if all compute properties has not changed