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 %}
-

{{ device["name"] }}

- Category {{ device["category"] }}
- Product: {{ device["product_name"] }}
- Vendor: {{ device["vendor_name"] }}
- Documentation: {{ device["documentation_url"] }}
- Status: {{ device["status"] }}
- Maintainer: {{ device["maintainer"] }} +

{{ appliance["name"] }}

+ Category {{ appliance["category"] }}
+ Product: {{ appliance["product_name"] }}
+ Vendor: {{ appliance["vendor_name"] }}
+ Documentation: {{ appliance["documentation_url"] }}
+ Status: {{ appliance["status"] }}
+ Maintainer: {{ appliance["maintainer"] }}
- {% if device["status"] == "broken" %} + {% if appliance["status"] == "broken" %} {% endif %} - {% if "qemu" in device %} + {% if "qemu" in appliance %}

Qemu settings

- {% for key in device["qemu"] %} - {{ key }}: {{ device["qemu"][key] }}
+ {% for key in appliance["qemu"] %} + {{ key }}: {{ appliance["qemu"][key] }}
{% endfor %} {% endif %} - {% for version in device["versions"] | reverse %} -

{{ device["name"] }} {{version["name"]}}

- + {% for version in appliance["versions"] | reverse %} +

{{ appliance["name"] }} {{version["name"]}}

+

Require files

{% for image in version.images.values() %}

{{image["filename"]}}

@@ -51,7 +51,7 @@ function download(device, md5sum) { Download url: {{image["download_url"]}}
{% if "direct_download_url" in image %} Direct download url: {{image["direct_download_url"]}}
- + {% endif %}
{% endfor %} diff --git a/templates/appliances.html b/templates/appliances.html new file mode 100644 index 0000000..1d2e5d1 --- /dev/null +++ b/templates/appliances.html @@ -0,0 +1,8 @@ +{% extends "layout/default.html" %} +{% block body %} + +{% endblock %} diff --git a/templates/devices.html b/templates/devices.html deleted file mode 100644 index 76c8932..0000000 --- a/templates/devices.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "layout/default.html" %} -{% block body %} - -{% endblock %} diff --git a/templates/index.html b/templates/index.html index 24c58b6..70adc4d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,7 +13,7 @@ function importDevice() { - Show devices - Import device + Show appliances + Import appliance

{% endblock %} diff --git a/templates/layout/default.html b/templates/layout/default.html index f42056f..2fcd33e 100644 --- a/templates/layout/default.html +++ b/templates/layout/default.html @@ -2,7 +2,7 @@ - + @@ -69,7 +69,7 @@