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

View File

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

View File

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

View File

@ -67,6 +67,8 @@ def test_json(node, compute):
"x": node.x,
"y": node.y,
"z": node.z,
"width": node.width,
"height": node.height,
"symbol": node.symbol,
"label": node.label
}
@ -81,6 +83,8 @@ def test_json(node, compute):
"x": node.x,
"y": node.y,
"z": node.z,
"width": node.width,
"height": node.height,
"symbol": node.symbol,
"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)
def test_update_only_controller(node, controller, compute, project, async_run):
"""
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
def test_update_no_changes(node, compute, project, async_run):
"""
We don't call the compute node if all compute properties has not changed