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

Compatybility with controller, default_symbol and hover_symbol, Fixes: #2444

This commit is contained in:
ziajka 2018-03-02 13:48:27 +01:00
parent c714c9c8de
commit 05b6be2e42
2 changed files with 60 additions and 1 deletions

View File

@ -121,8 +121,21 @@ class Controller:
for vm in vms: for vm in vms:
# remove deprecated properties # remove deprecated properties
for prop in vm.copy(): for prop in vm.copy():
if prop in ["enable_remote_console", "use_ubridge"]: if prop in ["enable_remote_console", "use_ubridge", "default_symbol", "hover_symbol"]:
del vm[prop] del vm[prop]
# remove deprecated default_symbol and hover_symbol
# and set symbol if not present
deprecated = ["default_symbol", "hover_symbol"]
if len([prop for prop in vm.keys() if prop in deprecated]) > 0:
if "default_symbol" in vm.keys():
del vm["default_symbol"]
if "hover_symbol" in vm.keys():
del vm["hover_symbol"]
if "symbol" not in vm.keys():
vm["symbol"] = ":/symbols/computer.svg"
vm.setdefault("appliance_id", str(uuid.uuid4())) vm.setdefault("appliance_id", str(uuid.uuid4()))
try: try:
appliance = Appliance(vm["appliance_id"], vm) appliance = Appliance(vm["appliance_id"], vm)

View File

@ -540,6 +540,52 @@ def test_load_appliances(controller):
assert cloud_uuid == appliance.id assert cloud_uuid == appliance.id
def test_load_appliances_deprecated_features_default_symbol(controller):
controller._settings = {
"Qemu": {
"vms": [
{
"name": "Test",
"node_type": "qemu",
"category": "router",
"default_symbol": ":/symbols/iosv_virl.normal.svg",
"hover_symbol": ":/symbols/iosv_virl.selected.svg",
}
]
}
}
controller.load_appliances()
appliances = dict([(a.name, a) for a in controller.appliances.values()])
assert appliances["Test"].__json__()["symbol"] == ":/symbols/computer.svg"
assert "default_symbol" not in appliances["Test"].data.keys()
assert "hover_symbol" not in appliances["Test"].data.keys()
def test_load_appliances_deprecated_features_default_symbol_with_symbol(controller):
controller._settings = {
"Qemu": {
"vms": [
{
"name": "Test",
"node_type": "qemu",
"category": "router",
"default_symbol": ":/symbols/iosv_virl.normal.svg",
"hover_symbol": ":/symbols/iosv_virl.selected.svg",
"symbol": ":/symbols/my-symbol.svg"
}
]
}
}
controller.load_appliances()
appliances = dict([(a.name, a) for a in controller.appliances.values()])
assert appliances["Test"].__json__()["symbol"] == ":/symbols/my-symbol.svg"
assert "default_symbol" not in appliances["Test"].data.keys()
assert "hover_symbol" not in appliances["Test"].data.keys()
def test_autoidlepc(controller, async_run): def test_autoidlepc(controller, async_run):
controller._computes["local"] = AsyncioMagicMock() controller._computes["local"] = AsyncioMagicMock()
node_mock = AsyncioMagicMock() node_mock = AsyncioMagicMock()