GNS3 / gns3-web-ui

WebUI implementation for GNS3
GNU General Public License v3.0
144 stars 51 forks source link

Use md5 checksum to know if image is available #986

Closed grossmj closed 3 years ago

grossmj commented 3 years ago

An image won't be marked available if the name doesn't exactly match.

For instance, the file for image vios-adventerprisek9-m.vmdk.SPA.156-2.T has been uploaded but is still not marked as available:

md5sum_1

The reason is that the file name is vios-adventerprisek9-m.vmdk.SPA.156-2 .T (there is a space) as seen using the API request below.

md5sum_2

We need to use the MD5 checksum information instead of the name to validate that the image is available.

piotrpekala7 commented 3 years ago

C2

on Windows & Chrome 84.0.4147.105 everything works as expected so I'm not able to reproduce this error

piotrpekala7 commented 3 years ago

I have appliance to install, list of files iterated by version so I have to compare disk name from image from version to find image to install then compare md5sum from this with md5sum from uploaded file?

`{
        "builtin": true,
        "category": "router",
        "description": "vThunder, part of A10 Networks' award-winning A10 Thunder and AX Series Application Delivery Controller (ADC) family, is designed to meet the growing needs of organizations that require a flexible and easy-to-deploy application delivery and server load balancer solution running within a virtualized infrastructure.",
        "documentation_url": "https://www.a10networks.com/support",
        "first_port_name": "mgmt",
        "images": [
            {
                "download_url": "https://www.a10networks.com/vthunder-embed",
                "filename": "vThunder_410_P9.qcow2",
                "filesize": 6311706624,
                "md5sum": "6ef0f69ba7a099a7f43b5815c2abc691",
                "version": "4.1.0.P9"
            },
            {
                "download_url": "https://www.a10networks.com/vthunder-embed",
                "filename": "vThunder_410_P3.qcow2",
                "filesize": 6098780160,
                "md5sum": "daacefa4e0eb1cad9b253926624be4b9",
                "version": "4.1.0.P3"
            },
            {
                "download_url": "https://www.a10networks.com/vthunder-embed",
                "filename": "vth401.GA.12G_Disk.qcow2",
                "filesize": 4768464896,
                "md5sum": "311806ad414403359216da6119ddb823",
                "version": "4.0.1"
            }
        ],
        "maintainer": "GNS3 Team",
        "maintainer_email": "developers@gns3.net",
        "name": "A10 vThunder",
        "port_name_format": "ethernet {port1}",
        "product_name": "A10 vThunder",
        "product_url": "https://www.a10networks.com/products/thunder-series-appliances/vthunder-virtualized-application_delivery_controller/",
        "qemu": {
            "adapter_type": "virtio-net-pci",
            "adapters": 4,
            "arch": "x86_64",
            "boot_priority": "cd",
            "console_type": "telnet",
            "hda_disk_interface": "virtio",
            "kvm": "require",
            "ram": 4096
        },
        "registry_version": 3,
        "status": "stable",
        "symbol": "loadbalancer.svg",
        "usage": "Default credentials:\n- CLI: admin / a10.\n- Enable mode: <none>\n\nDefault management IP: 172.31.31.31/24",
        "vendor_name": "A10",
        "vendor_url": "https://www.a10networks.com/",
        "versions": [
            {
                "images": {
                    "hda_disk_image": "vThunder_410_P9.qcow2"
                },
                "name": "4.1.0.P9"
            },
            {
                "images": {
                    "hda_disk_image": "vThunder_410_P3.qcow2"
                },
                "name": "4.1.0.P3"
            },
            {
                "images": {
                    "hda_disk_image": "vth401.GA.12G_Disk.qcow2"
                },
                "name": "4.0.1"
            }
        ]
    `
grossmj commented 3 years ago

on Windows & Chrome 84.0.4147.105 everything works as expected so I'm not able to reproduce this error

This should be platform independent error, just rename an image before you upload it and it won't be listed as available.

I have appliance to install, list of files iterated by version so I have to compare disk name from image from version to find image to install then compare md5sum from this with md5sum from uploaded file?

Almost, just use the MD5 checksum and ignore the image names since this is not reliable (problem described above). You have all the MD5 checksum information for each image in the appliance file or data returned by the server. Then you would have to match these with what is returned by the server when the list of images is refreshed (API requests to /v2/computes/local/qemu/images etc.). Hope this makes sense.

piotrpekala7 commented 3 years ago

@grossmj should be fixed in https://github.com/GNS3/gns3-web-ui/commit/e335a552c5ecb66f0d21b0aef549f9f69605c613, please let me know, I tested with two examples

grossmj commented 3 years ago

Looks good, thanks :+1:

grossmj commented 3 years ago

Looks like we still have issues importing images: iosv import issues.zip

piotrpekala7 commented 3 years ago

issue I cannot reproduce this issue, as you see everything works as expected in latest version...

grossmj commented 3 years ago

I can reproduce the error.

  1. Download a fresh GNS3 VM version 2.2.16
  2. Open Chrome and go to the IP address displayed in the VM.
  3. Create a TEST project.
  4. Create a new IOSv template.
  5. Import IOSv_startup_config.img first.

Screenshot from 2020-11-29 12-01-25

At this point, going to http://<IP>/v2/computes/local/qemu/images in the browser, I see

[
    {
        "filename": "IOSv_startup_config.img",
        "filesize": 1048576,
        "md5sum": "bc605651c4688276f81fd59dcf5cc786",
        "path": "IOSv_startup_config.img"
    }
]
  1. Import any other IOSv image, vios-adventerprisek9-m.vmdk.SPA.156-2.T in my case. I noticed the image is uploaded almost immediately which is suspicious for this 130Mb image. Refresh http://<IP>/v2/computes/local/qemu/images and now I see.
[
    {
        "filename": "IOSv_startup_config.img",
        "filesize": 1048576,
        "md5sum": "bc605651c4688276f81fd59dcf5cc786",
        "path": "IOSv_startup_config.img"
    },
    {
        "filename": "vios-adventerprisek9-m.vmdk.SPA.156-2.T",
        "filesize": 1048576,
        "md5sum": "bc605651c4688276f81fd59dcf5cc786",
        "path": "vios-adventerprisek9-m.vmdk.SPA.156-2.T"
    }
]

Notice the size and MD5 checksum are the same. Looks like IOSv_startup_config.img (or any image that has been uploaded first) is always re-uploaded whatever other IOSv image I want to upload. I have tried on Firefox and got the same issue. Closing the create new template dialog and opening it again them import vios-adventerprisek9-m.vmdk.SPA.156-2.T fixes the issue.

To try again, just delete the image files in the VM:

Screenshot from 2020-11-29 12-10-37

piotrpekala7 commented 3 years ago

should be fixed, please verify, I tested with 3 different examples

grossmj commented 3 years ago

Tested, seems fixed thanks :+1: