mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 04:47:54 +00:00
Cloud support for old topologies
This commit is contained in:
parent
7c7662f1b6
commit
2c62b1eeb8
@ -217,8 +217,7 @@ def _convert_1_3_later(topo):
|
||||
if node["symbol"] is None:
|
||||
node["symbol"] = ":/symbols/vbox_guest.svg"
|
||||
elif old_node["type"] == "Cloud":
|
||||
node["node_type"] = "cloud"
|
||||
node["symbol"] = ":/symbols/cloud.svg"
|
||||
_create_cloud(node, old_node)
|
||||
else:
|
||||
raise NotImplementedError("Conversion of {} is not supported".format(old_node["type"]))
|
||||
|
||||
@ -374,3 +373,33 @@ def _convert_label(label):
|
||||
"x": int(label["x"]),
|
||||
"y": int(label["y"])
|
||||
}
|
||||
|
||||
|
||||
def _create_cloud(node, old_node):
|
||||
node["node_type"] = "cloud"
|
||||
node["symbol"] = ":/symbols/cloud.svg"
|
||||
node["console_type"] = None
|
||||
node["console"] = None
|
||||
del old_node["properties"]["nios"]
|
||||
|
||||
ports = []
|
||||
for old_port in old_node.get("ports", []):
|
||||
if old_port["name"].startswith("nio_gen_eth"):
|
||||
port_type = "ethernet"
|
||||
elif old_port["name"].startswith("nio_gen_linux"):
|
||||
port_type = "ethernet"
|
||||
elif old_port["name"].startswith("nio_tap"):
|
||||
port_type = "tap"
|
||||
else:
|
||||
raise NotImplementedError("The conversion of cloud with {} is not supporterd".format(old_port["name"]))
|
||||
|
||||
port = {
|
||||
"interface": old_port["name"].split(":")[1],
|
||||
"name": old_port["name"].split(":")[1],
|
||||
"port_number": len(ports) + 1,
|
||||
"type": port_type
|
||||
}
|
||||
ports.append(port)
|
||||
|
||||
node["properties"]["ports"] = ports
|
||||
node["properties"]["interfaces"] = []
|
||||
|
60
tests/topologies/1_5_cloud/after/1_5_cloud.gns3
Normal file
60
tests/topologies/1_5_cloud/after/1_5_cloud.gns3
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"auto_start": false,
|
||||
"name": "1_5_cloud",
|
||||
"project_id": "467ce18d-4848-494a-88d2-4f53ddaca111",
|
||||
"revision": 5,
|
||||
"topology": {
|
||||
"computes": [
|
||||
{
|
||||
"compute_id": "local",
|
||||
"host": "127.0.0.1",
|
||||
"name": "Local",
|
||||
"port": 3080,
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"drawings": [],
|
||||
"links": [],
|
||||
"nodes": [
|
||||
{
|
||||
"compute_id": "local",
|
||||
"console": null,
|
||||
"console_type": null,
|
||||
"label": {
|
||||
"rotation": 0,
|
||||
"style": "font-family: TypeWriter;font-size: 10;font-weight: bold;fill: #000000;fill-opacity: 1.0;",
|
||||
"text": "Cloud 1",
|
||||
"x": 55,
|
||||
"y": -25
|
||||
},
|
||||
"name": "Cloud 1",
|
||||
"node_id": "ANYUUID",
|
||||
"node_type": "cloud",
|
||||
"properties": {
|
||||
"interfaces": [
|
||||
],
|
||||
"ports": [
|
||||
{
|
||||
"interface": "bridge0",
|
||||
"name": "bridge0",
|
||||
"port_number": 1,
|
||||
"type": "ethernet"
|
||||
},
|
||||
{
|
||||
"interface": "tap0",
|
||||
"name": "tap0",
|
||||
"port_number": 2,
|
||||
"type": "tap"
|
||||
}
|
||||
]
|
||||
},
|
||||
"symbol": ":/symbols/cloud.svg",
|
||||
"x": 57,
|
||||
"y": -2,
|
||||
"z": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "topology",
|
||||
"version": "ANYSTR"
|
||||
}
|
56
tests/topologies/1_5_cloud/before/1_5_cloud.gns3
Normal file
56
tests/topologies/1_5_cloud/before/1_5_cloud.gns3
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"auto_start": false,
|
||||
"name": "1_5_cloud",
|
||||
"project_id": "467ce18d-4848-494a-88d2-4f53ddaca111",
|
||||
"revision": 4,
|
||||
"topology": {
|
||||
"nodes": [
|
||||
{
|
||||
"description": "Cloud",
|
||||
"id": 1,
|
||||
"label": {
|
||||
"color": "#ff000000",
|
||||
"font": "TypeWriter,10,-1,5,75,0,0,0,0,0",
|
||||
"text": "Cloud 1",
|
||||
"x": 55.6015625,
|
||||
"y": -25.0
|
||||
},
|
||||
"ports": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "nio_gen_eth:bridge0",
|
||||
"stub": true
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "nio_tap:tap0",
|
||||
"stub": true
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"name": "Cloud 1",
|
||||
"nios": [
|
||||
"nio_tap:tap0",
|
||||
"nio_gen_eth:bridge0"
|
||||
]
|
||||
},
|
||||
"server_id": 3,
|
||||
"type": "Cloud",
|
||||
"x": 57,
|
||||
"y": -2
|
||||
}
|
||||
],
|
||||
"servers": [
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"id": 3,
|
||||
"local": true,
|
||||
"port": 3080,
|
||||
"protocol": "http",
|
||||
"vm": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "topology",
|
||||
"version": "1.5.1dev1"
|
||||
}
|
Loading…
Reference in New Issue
Block a user