Add filesize for images

Fix #8
This commit is contained in:
Julien Duponchelle 2015-09-02 12:10:31 +02:00
parent c9c960c639
commit 728f092a13
13 changed files with 43 additions and 10 deletions

View File

@ -8,7 +8,7 @@
"product_name": "vEOS",
"product_url": "https://eos.arista.com/",
"registry_version": 1,
"status": "stable",
"status": "experimental",
"maintainer": "GNS3 Team",
"maintainer_email": "developers@gns3.net",
@ -24,6 +24,7 @@
{
"filename": "Aboot-veos-serial-2.1.0.iso",
"version": "2.1.0",
"filesize": 5242880,
"md5sum": "2687534f2ff11b998dec0511066457c0",
"download_url": "https://www.arista.com/en/support/software-download"
},
@ -31,6 +32,7 @@
"filename": "vEOS-lab-4.13.8M.vmdk",
"version": "4.13.8M",
"md5sum": "a47145b9e6e7a24171c0850f8755535e",
"filesize": 409010176,
"download_url": "https://www.arista.com/en/support/software-download"
}
],

View File

@ -25,12 +25,14 @@
{
"filename": "asav941-202.qcow2",
"version": "9.4.1-202",
"filesize": 155713536,
"md5sum": "6992d2a35d5682a99b124b5eaf5c603a",
"download_url": "N/A"
},
{
"filename": "asav932-200.qcow2",
"version": "9.3.2-200",
"filesize": 150208512,
"md5sum": "bcf3a9a4735a195fb70599637936ab38",
"download_url": "N/A"
}

View File

@ -28,6 +28,7 @@
{
"filename": "CumulusVX-2.5.3-4eb681f3df86c478.qcow2",
"version": "2.5.3",
"filesize": 1040973824,
"md5sum": "5128aec2568991ea0586293cb85f7a97",
"download_url": "https://cumulusnetworks.com/cumulus-vx/download/thanks/kvm/"
}

View File

@ -25,6 +25,7 @@
"filename": "VSR1000_HP-CMW710-R0204P01-X64.iso",
"version": "7.10.R0204P01",
"md5sum": "d0b539f3ba9723ad8c3ed46f6d772627",
"filesize": 236687360,
"download_url": "https://h10145.www1.hp.com/Downloads/DownloadSoftware.aspx?SoftwareReleaseUId=11832&ProductNumber=JG811AAE&lang=en&cc=us&prodSeriesId=5443163&OrderNumber=&PurchaseDate="
}
],

View File

@ -25,6 +25,7 @@
"filename": "linux-microcore-3.4.1.img",
"version": "3.4.1",
"md5sum": "fa2ec4b1fffad67d8103c3391bbf9df2",
"filesize": 24969216,
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "http://downloads.sourceforge.net/project/gns-3/Qemu%20Appliances/linux-microcore-3.4.1.img"
},
@ -32,6 +33,7 @@
"filename": "linux-microcore-4.0.2-clean.img",
"version": "4.0.2",
"md5sum": "e13d0d1c0b3999ae2386bba70417930c",
"filesize": 26411008,
"download_url": "https://sourceforge.net/projects/gns-3/files/Qemu%20Appliances/",
"direct_download_url": "http://downloads.sourceforge.net/project/gns-3/Qemu%20Appliances/linux-microcore-4.0.2-clean.img"
}

View File

@ -26,6 +26,7 @@
"filename": "openwrt-realview-vmlinux-initramfs-14.07.elf",
"version": "14.07",
"md5sum": "2411307d0794baa618537c5dfcb19575",
"filesize": 2183520,
"download_url": "http://downloads.openwrt.org/barrier_breaker/14.07/realview/generic/",
"direct_download_url": "http://downloads.openwrt.org/barrier_breaker/14.07/realview/generic/openwrt-realview-vmlinux-initramfs.elf"
}

View File

@ -8,7 +8,7 @@
"product_name": "Drone",
"product_url": "http://ostinato.org/",
"registry_version": 1,
"status": "stable",
"status": "experimental",
"maintainer": "Bernhard Ehler",
"maintainer_email": "be@bernhard-ehlers.de",
"usage": "The traffic generator listen on port 50001.\n Use the Ostinato GUI to control it. If you want to use two traffic geneator at the same time you need to modify the port in the VM Qemu options.\nThe drone VM and the Ostinato GUI must use the same version.",
@ -27,6 +27,7 @@
"filename": "ost-drone-0.7-v1.qcow2",
"version": "0.7",
"md5sum": "6c20f767f89782e66929e6cbb7143ab1",
"filesize": 18415616,
"download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/install-qemu.html",
"direct_download_url": "http://www.bernhard-ehlers.de/projects/ostinato4gns3/ost-drone-0.7-v1.qcow2"
}

View File

@ -48,12 +48,21 @@ os.mkdir(os.path.join('build', 'appliances'))
os.mkdir(os.path.join('build', 'images'))
def human_filesize(num):
for unit in ['B','KB','MB','GB']:
if abs(num) < 1024.0:
return "%3.1f%s" % (num, unit)
num /= 1024.0
return "%.1f%s" % (num, 'TB')
def render(template_file, out, **kwargs):
log.info('Build %s', out)
env = Environment(loader=FileSystemLoader('templates'))
env.filters['nl2br'] = lambda s: s.replace('\n', '<br />')
env.filters['jsonify'] = json.dumps
env.filters['b64encode'] = lambda s: base64.b64encode(s.encode()).decode("utf-8")
env.filters['human_filesize'] = human_filesize
template = env.get_template(template_file)
template.stream(**kwargs).dump(os.path.join('build', out))

View File

@ -138,6 +138,10 @@
"format": "md5",
"title": "md5sum of the file"
},
"filesize": {
"type": "integer",
"title": "File size in bytes"
},
"download_url": {
"type": "string",
"format": "uri",
@ -153,6 +157,7 @@
"filename",
"version",
"md5sum",
"filesize",
"download_url"
]
}

View File

@ -23,6 +23,13 @@ function download(appliance, md5sum) {
This appliance is actually not working
</div>
{% endif %}
{% if appliance["status"] == "experimental" %}
<div class="alert alert-warning" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
This appliance is actually experimental
</div>
{% endif %}
<h1>{{ appliance["name"] }}</h1>
Category {{ appliance["category"] }}<br />
Product: <a href="{{ appliance["product_url"] }}">{{ appliance["product_name"] }}</a><br />
@ -55,6 +62,7 @@ function download(appliance, md5sum) {
<h4>{{image["filename"]}}</h4>
Slot: {{image["type"]}}<br />
File Version: {{image["version"]}}<br />
Size: {{ image["filesize"] | human_filesize}}<br />
Checksum: {{image["md5sum"]}}<br />
Download url: <a href="{{image["download_url"]}}">{{image["download_url"]}}</a><br />
{% if "direct_download_url" in image %}

View File

@ -1,13 +1,6 @@
{% extends "layout/default.html" %}
{% block script %}
function humanFileSize(bytes) {
var exp = Math.log(bytes) / Math.log(1024) | 0;
var result = (bytes / Math.pow(1024, exp)).toFixed(2);
return result + ' ' + (exp == 0 ? 'bytes': 'KMGTPEZY'[exp - 1] + 'B');
}
function update_progress_download_div(div, download_info) {
var percent = Math.round(100 / download_info.total * download_info.received)
div.text(percent + "% "+ humanFileSize(download_info.received) + " / " + humanFileSize(download_info.total));

View File

@ -52,6 +52,13 @@
return false;
}
}
function humanFileSize(bytes) {
var exp = Math.log(bytes) / Math.log(1024) | 0;
var result = (bytes / Math.pow(1024, exp)).toFixed(2);
return result + ' ' + (exp == 0 ? 'bytes': 'KMGTPEZY'[exp - 1] + 'B');
}
</script>
<script>

View File

@ -9,7 +9,7 @@ $(function() {
var tr = $("<tr>");
tr.append($("<td>").text(image_info.filename));
tr.append($("<td>").text(image_info.md5sum));
tr.append($("<td>").text(humanFileSize(image_info.filesize)));
var a = $("<a>");
a.attr("href", "/images/" + image_info.md5sum + ".html");
a.append($("<button>").attr("class", "btn btn-primary btn-lg").text("Search appliance"));
@ -25,6 +25,7 @@ $(function() {
<tr>
<th>Filename</th>
<th>MD5 sum</th>
<th>Size</th>
<th>Action</th>
</tr>
</table>