mirror of
https://github.com/GNS3/gns3-registry.git
synced 2024-12-24 06:56:41 +00:00
Support devices stored in sub directories
This commit is contained in:
parent
10cd2861d3
commit
78542eee40
@ -37,11 +37,13 @@ class Repository:
|
||||
|
||||
#TODO: Manage open error
|
||||
devices_path = self._get_devices_path()
|
||||
for file in os.listdir(devices_path):
|
||||
with open(os.path.join(devices_path, file)) as f:
|
||||
config = json.load(f)
|
||||
if self._image_match(image, config):
|
||||
configurations.append(config)
|
||||
for (dirpath, dirnames, filenames) in os.walk(devices_path):
|
||||
for filename in filenames:
|
||||
file = os.path.join(dirpath, filename)
|
||||
with open(os.path.join(devices_path, file)) as f:
|
||||
config = json.load(f)
|
||||
if self._image_match(image, config):
|
||||
configurations.append(config)
|
||||
|
||||
return configurations
|
||||
|
||||
|
@ -76,7 +76,7 @@ def empty_config(tmpdir):
|
||||
|
||||
|
||||
def test_add_image(empty_config, linux_microcore_img):
|
||||
with open("devices/microcore-linux.json") as f:
|
||||
with open("devices/qemu/microcore-linux.json") as f:
|
||||
config = json.load(f)
|
||||
image = Image(linux_microcore_img)
|
||||
image.version = "3.4.1"
|
||||
@ -107,7 +107,7 @@ def test_add_image(empty_config, linux_microcore_img):
|
||||
|
||||
|
||||
def test_add_image_uniq(empty_config, linux_microcore_img):
|
||||
with open("devices/microcore-linux.json") as f:
|
||||
with open("devices/qemu/microcore-linux.json") as f:
|
||||
config = json.load(f)
|
||||
image = Image(linux_microcore_img)
|
||||
image.version = "3.4.1"
|
||||
@ -120,7 +120,7 @@ def test_add_image_uniq(empty_config, linux_microcore_img):
|
||||
|
||||
def test_save(empty_config, linux_microcore_img):
|
||||
|
||||
with open("devices/microcore-linux.json") as f:
|
||||
with open("devices/qemu/microcore-linux.json") as f:
|
||||
config = json.load(f)
|
||||
empty_config.add_image(config)
|
||||
empty_config.save()
|
||||
|
@ -25,7 +25,7 @@ from gns3repository.repository import Repository
|
||||
|
||||
def test_detect_image(linux_microcore_img):
|
||||
|
||||
with open("devices/microcore-linux.json") as f:
|
||||
with open("devices/qemu/microcore-linux.json") as f:
|
||||
config = json.load(f)
|
||||
|
||||
repository = Repository()
|
||||
|
Loading…
Reference in New Issue
Block a user