mirror of
https://github.com/GNS3/gns3-registry.git
synced 2024-12-20 05:17:55 +00:00
device => appliance
This commit is contained in:
parent
2ed07bcfe1
commit
3e1a1fafbe
@ -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
|
Build website
|
||||||
#############
|
#############
|
||||||
@ -20,4 +26,3 @@ Run website
|
|||||||
python server.py
|
python server.py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
48
build.py
48
build.py
@ -41,7 +41,7 @@ if os.path.exists('build'):
|
|||||||
os.remove(os.path.join('build', file))
|
os.remove(os.path.join('build', file))
|
||||||
else:
|
else:
|
||||||
os.mkdir('build')
|
os.mkdir('build')
|
||||||
os.mkdir(os.path.join('build', 'devices'))
|
os.mkdir(os.path.join('build', 'appliances'))
|
||||||
os.mkdir(os.path.join('build', 'images'))
|
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))
|
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.
|
version where the image is present.
|
||||||
|
|
||||||
:param md5sum: Md5sum of the image
|
:param md5sum: Md5sum of the image
|
||||||
:param device: Device hash
|
:param appliance: Device hash
|
||||||
:returns: List of version
|
:returns: List of version
|
||||||
"""
|
"""
|
||||||
|
|
||||||
new_versions = []
|
new_versions = []
|
||||||
for version in device["versions"]:
|
for version in appliance["versions"]:
|
||||||
found = False
|
found = False
|
||||||
for image in version["images"].values():
|
for image in version["images"].values():
|
||||||
if image["md5sum"] == md5sum:
|
if image["md5sum"] == md5sum:
|
||||||
@ -81,39 +81,39 @@ render('chat.html', 'chat.html')
|
|||||||
render('downloads.html', 'downloads.html')
|
render('downloads.html', 'downloads.html')
|
||||||
|
|
||||||
|
|
||||||
devices = []
|
appliances = []
|
||||||
for device_file in os.listdir('devices'):
|
for appliance_file in os.listdir('appliances'):
|
||||||
log.info("Process " + device_file)
|
log.info("Process " + appliance_file)
|
||||||
out_filename = device_file[:-5]
|
out_filename = appliance_file[:-5]
|
||||||
with open(os.path.join('devices', device_file)) as f:
|
with open(os.path.join('appliances', appliance_file)) as f:
|
||||||
device = json.load(f)
|
appliance = json.load(f)
|
||||||
device['id'] = out_filename
|
appliance['id'] = out_filename
|
||||||
|
|
||||||
# Resolve version image to the corresponding file
|
# 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():
|
for image_type, filename in version['images'].items():
|
||||||
found = False
|
found = False
|
||||||
for file in device['images']:
|
for file in appliance['images']:
|
||||||
if file['filename'] == filename:
|
if file['filename'] == filename:
|
||||||
version['images'][image_type] = copy.copy(file)
|
version['images'][image_type] = copy.copy(file)
|
||||||
version['images'][image_type]["type"] = image_type
|
version['images'][image_type]["type"] = image_type
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if not found:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
render('device.html', os.path.join('devices', out_filename + '.html'), device=device)
|
render('appliance.html', os.path.join('appliances', out_filename + '.html'), appliance=appliance)
|
||||||
devices.append(device)
|
appliances.append(appliance)
|
||||||
|
|
||||||
# Build a page named with the md5sum of each file of the device
|
# Build a page named with the md5sum of each file of the appliance
|
||||||
# it's allow to get the device informations via HTTP with just an md5sum
|
# it's allow to get the appliance informations via HTTP with just an md5sum
|
||||||
# it's what powered the import feature
|
# 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
|
# We keep only version with this image in the page
|
||||||
image_device = copy.copy(device)
|
image_appliance = copy.copy(appliance)
|
||||||
image_device['versions'] = keep_only_version_with_device(image['md5sum'], device)
|
image_appliance['versions'] = keep_only_version_with_appliance(image['md5sum'], appliance)
|
||||||
render('device.html', os.path.join('images', image['md5sum'] + '.html'), device=image_device)
|
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)
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
|
||||||
function download(device, md5sum) {
|
function download(appliance, md5sum) {
|
||||||
if (gns3_button(function() {
|
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 <a href=\"/downloads.html\">Downloads</a> section");
|
gns3_notif("success", "You can see the download progress in the <a href=\"/downloads.html\">Downloads</a> section");
|
||||||
return true;
|
return true;
|
||||||
@ -16,16 +16,16 @@ function download(device, md5sum) {
|
|||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<h1>{{ device["name"] }}</h1>
|
<h1>{{ appliance["name"] }}</h1>
|
||||||
Category {{ device["category"] }}<br />
|
Category {{ appliance["category"] }}<br />
|
||||||
Product: <a href="{{ device["product_url"] }}">{{ device["product_name"] }}</a><br />
|
Product: <a href="{{ appliance["product_url"] }}">{{ appliance["product_name"] }}</a><br />
|
||||||
Vendor: <a href="{{ device["vendor_url"] }}">{{ device["vendor_name"] }}</a><br />
|
Vendor: <a href="{{ appliance["vendor_url"] }}">{{ appliance["vendor_name"] }}</a><br />
|
||||||
Documentation: <a href="{{ device["documentation_url"] }}">{{ device["documentation_url"] }}</a><br />
|
Documentation: <a href="{{ appliance["documentation_url"] }}">{{ appliance["documentation_url"] }}</a><br />
|
||||||
Status: {{ device["status"] }}<br />
|
Status: {{ appliance["status"] }}<br />
|
||||||
Maintainer: <a href="mailto:{{ device["maintainer_email"] }}">{{ device["maintainer"] }}</a>
|
Maintainer: <a href="mailto:{{ appliance["maintainer_email"] }}">{{ appliance["maintainer"] }}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if device["status"] == "broken" %}
|
{% if appliance["status"] == "broken" %}
|
||||||
<div class="alert alert-danger" role="alert">
|
<div class="alert alert-danger" role="alert">
|
||||||
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
||||||
<span class="sr-only">Error:</span>
|
<span class="sr-only">Error:</span>
|
||||||
@ -33,15 +33,15 @@ function download(device, md5sum) {
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if "qemu" in device %}
|
{% if "qemu" in appliance %}
|
||||||
<h2>Qemu settings</h2>
|
<h2>Qemu settings</h2>
|
||||||
{% for key in device["qemu"] %}
|
{% for key in appliance["qemu"] %}
|
||||||
{{ key }}: {{ device["qemu"][key] }}<br />
|
{{ key }}: {{ appliance["qemu"][key] }}<br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for version in device["versions"] | reverse %}
|
{% for version in appliance["versions"] | reverse %}
|
||||||
<h2>{{ device["name"] }} {{version["name"]}}</h2>
|
<h2>{{ appliance["name"] }} {{version["name"]}}</h2>
|
||||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3_button(function() { return gns3.install("{{device|jsonify|b64encode}}", "{{version["name"]}}") })'>Install</button>
|
<button class="btn btn-primary btn-lg" type="button" onclick='gns3_button(function() { return gns3.install("{{appliance|jsonify|b64encode}}", "{{version["name"]}}") })'>Install</button>
|
||||||
<h3>Require files</h3>
|
<h3>Require files</h3>
|
||||||
{% for image in version.images.values() %}
|
{% for image in version.images.values() %}
|
||||||
<h4>{{image["filename"]}}</h4>
|
<h4>{{image["filename"]}}</h4>
|
||||||
@ -51,7 +51,7 @@ function download(device, md5sum) {
|
|||||||
Download url: <a href="{{image["download_url"]}}">{{image["download_url"]}}</a><br />
|
Download url: <a href="{{image["download_url"]}}">{{image["download_url"]}}</a><br />
|
||||||
{% if "direct_download_url" in image %}
|
{% if "direct_download_url" in image %}
|
||||||
Direct download url: <a href="{{image["direct_download_url"]}}">{{image["direct_download_url"]}}</a><br />
|
Direct download url: <a href="{{image["direct_download_url"]}}">{{image["direct_download_url"]}}</a><br />
|
||||||
<button class="btn btn-primary btn-lg" type="button" onclick='return download("{{device|jsonify|b64encode}}", "{{image["md5sum"]}}")'>Download</button>
|
<button class="btn btn-primary btn-lg" type="button" onclick='return download("{{appliance|jsonify|b64encode}}", "{{image["md5sum"]}}")'>Download</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<hr />
|
<hr />
|
||||||
{% endfor %}
|
{% endfor %}
|
8
templates/appliances.html
Normal file
8
templates/appliances.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{% extends "layout/default.html" %}
|
||||||
|
{% block body %}
|
||||||
|
<ul>
|
||||||
|
{% for appliance in appliances %}
|
||||||
|
<li><a href="/appliances/{{appliance["id"]}}.html">{{appliance["name"]}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
@ -1,8 +0,0 @@
|
|||||||
{% extends "layout/default.html" %}
|
|
||||||
{% block body %}
|
|
||||||
<ul>
|
|
||||||
{% for device in devices %}
|
|
||||||
<li><a href="/devices/{{device["id"]}}.html">{{device["name"]}}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endblock %}
|
|
@ -13,7 +13,7 @@ function importDevice() {
|
|||||||
<a href="http://www.spiceworks.com/gns3/download-free-tftp-server-for-network-configuration-management/?utm_function=acq&utm_channel=aff&medium=aff&utm_source=150158&utm_campaign=&utm_content=tftp-cobrand-980x324"><img src="http://adn.impactradius.com/display-ad/2435-216679"></a>
|
<a href="http://www.spiceworks.com/gns3/download-free-tftp-server-for-network-configuration-management/?utm_function=acq&utm_channel=aff&medium=aff&utm_source=150158&utm_campaign=&utm_content=tftp-cobrand-980x324"><img src="http://adn.impactradius.com/display-ad/2435-216679"></a>
|
||||||
</div
|
</div
|
||||||
<p>
|
<p>
|
||||||
<a class="btn btn-primary btn-lg" href="/devices" role="button">Show devices</a>
|
<a class="btn btn-primary btn-lg" href="/appliances" role="button">Show appliances</a>
|
||||||
<a class="btn btn-primary btn-lg" href="#" role="button" onclick="return importDevice()">Import device</a>
|
<a class="btn btn-primary btn-lg" href="#" role="button" onclick="return importDevice()">Import appliance</a>
|
||||||
</p>
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=appliance-width, initial-scale=1">
|
||||||
<title></title>
|
<title></title>
|
||||||
<!-- Latest compiled and minified CSS -->
|
<!-- Latest compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><a href="/devices">Devices</a></li>
|
<li><a href="/appliances">Devices</a></li>
|
||||||
<li><a href="/downloads.html">Downloads</a></li>
|
<li><a href="/downloads.html">Downloads</a></li>
|
||||||
<li><a href="/chat.html">Chat</a></li>
|
<li><a href="/chat.html">Chat</a></li>
|
||||||
<li><a href="https://community.gns3.com">Community</a></li>
|
<li><a href="https://community.gns3.com">Community</a></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user