diff --git a/README.rst b/README.rst index f97398a..2697806 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,13 @@ GNS3-registry ================ -This is the GNS3 devices registry. +This is the GNS3 registry. + +Add a new appliance +################### + +Copy paste a JSON from the appliances directory and send a pull request. + Build website ############# @@ -20,4 +26,3 @@ Run website python server.py - diff --git a/devices/arista-veos.json b/appliances/arista-veos.json similarity index 100% rename from devices/arista-veos.json rename to appliances/arista-veos.json diff --git a/devices/cumulus-vx.json b/appliances/cumulus-vx.json similarity index 100% rename from devices/cumulus-vx.json rename to appliances/cumulus-vx.json diff --git a/devices/hp-vsr1001.json b/appliances/hp-vsr1001.json similarity index 100% rename from devices/hp-vsr1001.json rename to appliances/hp-vsr1001.json diff --git a/devices/microcore-linux.json b/appliances/microcore-linux.json similarity index 100% rename from devices/microcore-linux.json rename to appliances/microcore-linux.json diff --git a/build.py b/build.py index 598f300..7c2f508 100644 --- a/build.py +++ b/build.py @@ -41,7 +41,7 @@ if os.path.exists('build'): os.remove(os.path.join('build', file)) else: os.mkdir('build') -os.mkdir(os.path.join('build', 'devices')) +os.mkdir(os.path.join('build', 'appliances')) os.mkdir(os.path.join('build', 'images')) @@ -54,18 +54,18 @@ def render(template_file, out, **kwargs): template.stream(**kwargs).dump(os.path.join('build', out)) -def keep_only_version_with_device(md5sum, device): +def keep_only_version_with_appliance(md5sum, appliance): """ - Filter device version in order to keep only the + Filter appliance version in order to keep only the version where the image is present. :param md5sum: Md5sum of the image - :param device: Device hash + :param appliance: Device hash :returns: List of version """ new_versions = [] - for version in device["versions"]: + for version in appliance["versions"]: found = False for image in version["images"].values(): if image["md5sum"] == md5sum: @@ -81,39 +81,39 @@ render('chat.html', 'chat.html') render('downloads.html', 'downloads.html') -devices = [] -for device_file in os.listdir('devices'): - log.info("Process " + device_file) - out_filename = device_file[:-5] - with open(os.path.join('devices', device_file)) as f: - device = json.load(f) - device['id'] = out_filename +appliances = [] +for appliance_file in os.listdir('appliances'): + log.info("Process " + appliance_file) + out_filename = appliance_file[:-5] + with open(os.path.join('appliances', appliance_file)) as f: + appliance = json.load(f) + appliance['id'] = out_filename # Resolve version image to the corresponding file - for version in device['versions']: + for version in appliance['versions']: for image_type, filename in version['images'].items(): found = False - for file in device['images']: + for file in appliance['images']: if file['filename'] == filename: version['images'][image_type] = copy.copy(file) version['images'][image_type]["type"] = image_type found = True break if not found: - log.critical('Image for {} {} with filename {} is missing'.format(device["name"], version["name"], file['filename'])) + log.critical('Image for {} {} with filename {} is missing'.format(appliance["name"], version["name"], file['filename'])) sys.exit(1) - render('device.html', os.path.join('devices', out_filename + '.html'), device=device) - devices.append(device) + render('appliance.html', os.path.join('appliances', out_filename + '.html'), appliance=appliance) + appliances.append(appliance) - # Build a page named with the md5sum of each file of the device - # it's allow to get the device informations via HTTP with just an md5sum + # Build a page named with the md5sum of each file of the appliance + # it's allow to get the appliance informations via HTTP with just an md5sum # it's what powered the import feature - for image in device['images']: + for image in appliance['images']: # We keep only version with this image in the page - image_device = copy.copy(device) - image_device['versions'] = keep_only_version_with_device(image['md5sum'], device) - render('device.html', os.path.join('images', image['md5sum'] + '.html'), device=image_device) + image_appliance = copy.copy(appliance) + image_appliance['versions'] = keep_only_version_with_appliance(image['md5sum'], appliance) + render('appliance.html', os.path.join('images', image['md5sum'] + '.html'), appliance=image_appliance) -render('devices.html', os.path.join('devices', 'index.html'), devices=devices) +render('appliances.html', os.path.join('appliances', 'index.html'), appliances=appliances) diff --git a/templates/device.html b/templates/appliance.html similarity index 55% rename from templates/device.html rename to templates/appliance.html index 352346f..0262f18 100644 --- a/templates/device.html +++ b/templates/appliance.html @@ -2,9 +2,9 @@ {% block script %} -function download(device, md5sum) { +function download(appliance, md5sum) { if (gns3_button(function() { - return gns3.download(device, md5sum) + return gns3.download(appliance, md5sum) })) { gns3_notif("success", "You can see the download progress in the Downloads section"); return true; @@ -16,16 +16,16 @@ function download(device, md5sum) { {% block body %}