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:
parent
c714c9c8de
commit
05b6be2e42
@ -121,8 +121,21 @@ class Controller:
|
||||
for vm in vms:
|
||||
# remove deprecated properties
|
||||
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]
|
||||
|
||||
# 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()))
|
||||
try:
|
||||
appliance = Appliance(vm["appliance_id"], vm)
|
||||
|
@ -540,6 +540,52 @@ def test_load_appliances(controller):
|
||||
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):
|
||||
controller._computes["local"] = AsyncioMagicMock()
|
||||
node_mock = AsyncioMagicMock()
|
||||
|
Loading…
Reference in New Issue
Block a user