mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-30 21:03:49 +02:00
Support for 1.3 topologies
This commit is contained in:
parent
c0abe0edfd
commit
45591aa74b
@ -159,7 +159,15 @@ def _convert_1_3_later(topo, topo_path):
|
|||||||
node["name"] = old_node["label"]["text"]
|
node["name"] = old_node["label"]["text"]
|
||||||
node["label"] = _convert_label(old_node["label"])
|
node["label"] = _convert_label(old_node["label"])
|
||||||
node["node_id"] = old_node.get("vm_id", str(uuid.uuid4()))
|
node["node_id"] = old_node.get("vm_id", str(uuid.uuid4()))
|
||||||
|
|
||||||
node["symbol"] = old_node.get("symbol", None)
|
node["symbol"] = old_node.get("symbol", None)
|
||||||
|
# Compatibility with <= 1.3
|
||||||
|
if node["symbol"] is None and "default_symbol" in old_node:
|
||||||
|
if old_node["default_symbol"].endswith("normal.svg"):
|
||||||
|
node["symbol"] = old_node["default_symbol"][:-11] + ".svg"
|
||||||
|
else:
|
||||||
|
node["symbol"] = old_node["default_symbol"]
|
||||||
|
|
||||||
node["x"] = int(old_node["x"])
|
node["x"] = int(old_node["x"])
|
||||||
node["y"] = int(old_node["y"])
|
node["y"] = int(old_node["y"])
|
||||||
node["z"] = int(old_node.get("z", 1))
|
node["z"] = int(old_node.get("z", 1))
|
||||||
@ -393,8 +401,12 @@ def _convert_label(label):
|
|||||||
style += "font-style: italic;"
|
style += "font-style: italic;"
|
||||||
color = label["color"]
|
color = label["color"]
|
||||||
|
|
||||||
|
if len(color) == 9:
|
||||||
style += "fill: #" + color[-6:] + ";"
|
style += "fill: #" + color[-6:] + ";"
|
||||||
style += "fill-opacity: {};".format(round(1.0 / 255 * int(color[:3][-2:], base=16), 2))
|
style += "fill-opacity: {};".format(round(1.0 / 255 * int(color[:3][-2:], base=16), 2))
|
||||||
|
else:
|
||||||
|
style += "fill: #" + color[-6:] + ";"
|
||||||
|
style += "fill-opacity: {};".format(1.0)
|
||||||
return {
|
return {
|
||||||
"text": label["text"],
|
"text": label["text"],
|
||||||
"rotation": 0,
|
"rotation": 0,
|
||||||
|
@ -106,6 +106,9 @@ def compare_dict(path, source, reference):
|
|||||||
elif isinstance(val, list):
|
elif isinstance(val, list):
|
||||||
assert len(val) == len(source[key]), "Not enough value in {} ({}/{}) it shoud be {} not {}".format(key, len(val), len(source[key]), val, source[key])
|
assert len(val) == len(source[key]), "Not enough value in {} ({}/{}) it shoud be {} not {}".format(key, len(val), len(source[key]), val, source[key])
|
||||||
for idx, element in enumerate(source[key]):
|
for idx, element in enumerate(source[key]):
|
||||||
|
if isinstance(element, dict):
|
||||||
compare_dict(path + key + "/", element, val[idx])
|
compare_dict(path + key + "/", element, val[idx])
|
||||||
|
else:
|
||||||
|
assert element == val[idx]
|
||||||
else:
|
else:
|
||||||
assert False, "Value type for {} is not supported".format(key)
|
assert False, "Value type for {} is not supported".format(key)
|
||||||
|
74
tests/topologies/1_3_dynamips/after/1_3_dynamips.gns3
Normal file
74
tests/topologies/1_3_dynamips/after/1_3_dynamips.gns3
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"auto_start": false,
|
||||||
|
"name": "1_3_dynamips",
|
||||||
|
"project_id": "ba5790e1-2f51-443e-a3cc-1a2eee132888",
|
||||||
|
"revision": 5,
|
||||||
|
"topology": {
|
||||||
|
"computes": [
|
||||||
|
{
|
||||||
|
"compute_id": "local",
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"name": "Local",
|
||||||
|
"port": 8000,
|
||||||
|
"protocol": "http"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"drawings": [],
|
||||||
|
"links": [],
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"symbol": ":/symbols/iosv_virl.svg",
|
||||||
|
"compute_id": "local",
|
||||||
|
"console": 2001,
|
||||||
|
"console_type": "telnet",
|
||||||
|
"label": {
|
||||||
|
"rotation": 0,
|
||||||
|
"style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;",
|
||||||
|
"text": "R1",
|
||||||
|
"x": 22,
|
||||||
|
"y": -25
|
||||||
|
},
|
||||||
|
"name": "R1",
|
||||||
|
"node_id": "0bce6ad5-c688-4d4d-a425-f21aaf3927e2",
|
||||||
|
"node_type": "dynamips",
|
||||||
|
"properties": {
|
||||||
|
"dynamips_id": 1,
|
||||||
|
"auto_delete_disks": true,
|
||||||
|
"clock_divisor": 4,
|
||||||
|
"disk0": 0,
|
||||||
|
"disk1": 0,
|
||||||
|
"exec_area": 64,
|
||||||
|
"idlemax": 500,
|
||||||
|
"idlesleep": 30,
|
||||||
|
"image": "c7200-adventerprisek9-mz.124-24.T8.image",
|
||||||
|
"mac_addr": "ca01.2f39.0000",
|
||||||
|
"midplane": "vxr",
|
||||||
|
"mmap": true,
|
||||||
|
"npe": "npe-400",
|
||||||
|
"nvram": 512,
|
||||||
|
"platform": "c7200",
|
||||||
|
"power_supplies": [
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"ram": 512,
|
||||||
|
"sensors": [
|
||||||
|
22,
|
||||||
|
22,
|
||||||
|
22,
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"slot0": "C7200-IO-FE",
|
||||||
|
"sparsemem": true,
|
||||||
|
"startup_config": "configs/i1_startup-config.cfg",
|
||||||
|
"system_id": "FTX0945W0MY"
|
||||||
|
},
|
||||||
|
"x": -112,
|
||||||
|
"y": -100,
|
||||||
|
"z": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": "topology",
|
||||||
|
"version": "2.0.0dev1"
|
||||||
|
}
|
81
tests/topologies/1_3_dynamips/before/1_3_dynamips.gns3
Normal file
81
tests/topologies/1_3_dynamips/before/1_3_dynamips.gns3
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{
|
||||||
|
"auto_start": false,
|
||||||
|
"name": "1_3_dynamips",
|
||||||
|
"project_id": "ba5790e1-2f51-443e-a3cc-1a2eee132888",
|
||||||
|
"revision": 3,
|
||||||
|
"topology": {
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"default_symbol": ":/symbols/iosv_virl.normal.svg",
|
||||||
|
"description": "Router c7200",
|
||||||
|
"dynamips_id": 1,
|
||||||
|
"hover_symbol": ":/symbols/iosv_virl.selected.svg",
|
||||||
|
"id": 1,
|
||||||
|
"label": {
|
||||||
|
"color": "#000000",
|
||||||
|
"font": "TypeWriter,10,-1,5,75,0,0,0,0,0",
|
||||||
|
"text": "R1",
|
||||||
|
"x": 22.6171875,
|
||||||
|
"y": -25.0
|
||||||
|
},
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"adapter_number": 0,
|
||||||
|
"id": 1,
|
||||||
|
"name": "FastEthernet0/0",
|
||||||
|
"port_number": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"auto_delete_disks": true,
|
||||||
|
"clock_divisor": 4,
|
||||||
|
"console": 2001,
|
||||||
|
"disk0": 0,
|
||||||
|
"disk1": 0,
|
||||||
|
"exec_area": 64,
|
||||||
|
"idlemax": 500,
|
||||||
|
"idlesleep": 30,
|
||||||
|
"image": "c7200-adventerprisek9-mz.124-24.T8.image",
|
||||||
|
"mac_addr": "ca01.2f39.0000",
|
||||||
|
"midplane": "vxr",
|
||||||
|
"mmap": true,
|
||||||
|
"name": "R1",
|
||||||
|
"npe": "npe-400",
|
||||||
|
"nvram": 512,
|
||||||
|
"platform": "c7200",
|
||||||
|
"power_supplies": [
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"ram": 512,
|
||||||
|
"sensors": [
|
||||||
|
22,
|
||||||
|
22,
|
||||||
|
22,
|
||||||
|
22
|
||||||
|
],
|
||||||
|
"slot0": "C7200-IO-FE",
|
||||||
|
"sparsemem": true,
|
||||||
|
"startup_config": "configs/i1_startup-config.cfg",
|
||||||
|
"system_id": "FTX0945W0MY"
|
||||||
|
},
|
||||||
|
"server_id": 1,
|
||||||
|
"type": "C7200",
|
||||||
|
"vm_id": "0bce6ad5-c688-4d4d-a425-f21aaf3927e2",
|
||||||
|
"x": -112.0,
|
||||||
|
"y": -100.0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"cloud": false,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"id": 1,
|
||||||
|
"local": true,
|
||||||
|
"port": 8000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": "topology",
|
||||||
|
"version": "1.3.13"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user