«

»

Download Image From Nutanix Image Configuration Via REST API

The Nutanix Image Configuration available in Nutanix hypervisor, AHV, based Nutanix Clusters is used to hold Disk and ISO files from which you want to create create new virtual machines from or use during operations system (e.g. VirtIO) or other software installations. It is easily accessible via:

Nutanix PRISM -> Gear Icon (in the top right corner) -> Image Configuration


From the Image Configuration you can:

  • Upload Image – You define:
    • Name
    • Annotation
    • Image Type
      • Disk
      • ISO
    • Specify Target Container
    • Specify Image Source:
      • From URL
      • Upload A File
  • Edit Existing Image – You can change:
    • Name
    • Annotation
    • Image Type
  • Delete Existing Image

I have received a few questions lately about how to download an Image from the Image Configuration and this is easily down via the REST API v3 which is Tech Preview at the time being and the below text is taken from Nutanix official REST API v3 web page

The V3 APIs are not GA yet. They are subject to change and are not supported for production use. Please contact your Nutanix account team for further information

Use the following commands, just change the red text to match your values, to list the available images and download the image of your choice:

  1. List all images in the Image Configuration service:
    curl -k -u admin -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{
    \"kind\": \"image\",
    \"sort_order\": \"ASCENDING\",
    \"sort_attribute\": \"name\"
    }" 'https://npx5.vcdx56.com:9440/api/nutanix/v3/images/list' | python -m json.tool

    Note: Make sure to get the formatting correct regarding e.g. double quotes

  2. Now go to the “Get All Images Command Output” and find the uuid for the image you want to download and in my case I’ll download the VirtIO driver ISO with uuid fd7d5c45-f219-4465-938b-0a9713ce4041
  3. Download the image using the below command where -o specifies the full path including file name to the directory where you want to download the image :
    curl -k -u admin -X GET --header "Accept: application/json" "https://npx5.vcdx56.com:9440/api/nutanix/v3/images/fd7d5c45-f219-4465-938b-0a9713ce4041/file" -o /Users/magander/Downloads/Nutanix-VirtIO-1.1.1.iso


And there you go, Image downloaded to my MacBook 🙂

Check out Nutanix Developer site to learn more about Nutanix REST API and to try out REST API v3 on your own non production cluster you can access the following URL https://Cluster-FQDN:9440/api/nutanix/v3/api_explorer/index.html

Get All Images Output

{
“api_version”: “3.0”,
“entities”: [
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “8de24885-4055-45be-ae66-aa57924b42f7”
},
“spec”: {
“description”: “64 bit v 1611”,
“name”: “CentOS7”,
“resources”: {
“image_type”: “ISO_IMAGE”
}
},
“status”: {
“description”: “64 bit v 1611”,
“name”: “CentOS7”,
“resources”: {
“image_type”: “ISO_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/8de24885-4055-45be-ae66-aa57924b42f7/file”
],
“size_bytes”: 4379901952
},
“state”: “COMPLETE”
}
},
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “8a2532e4-31fd-401e-b951-857bea6d9d04”
},
“spec”: {
“description”: “Test server”,
“name”: “dmzsrv01”,
“resources”: {
“image_type”: “DISK_IMAGE”,
“source_uri”: “file://8a2532e4-31fd-401e-b951-857bea6d9d04”
}
},
“status”: {
“description”: “Test server”,
“name”: “dmzsrv01”,
“resources”: {
“image_type”: “DISK_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/8a2532e4-31fd-401e-b951-857bea6d9d04/file”
],
“size_bytes”: 34359738368,
“source_uri”: “file://8a2532e4-31fd-401e-b951-857bea6d9d04”
},
“state”: “COMPLETE”
}
},
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “273ef7eb-d590-48c8-ba23-5b2354b39654”
},
“spec”: {
“description”: “Disk stress test VM”,
“name”: “fio_image”,
“resources”: {
“image_type”: “DISK_IMAGE”
}
},
“status”: {
“description”: “Disk stress test VM”,
“name”: “fio_image”,
“resources”: {
“image_type”: “DISK_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/273ef7eb-d590-48c8-ba23-5b2354b39654/file”
],
“size_bytes”: 16106127360
},
“state”: “COMPLETE”
}
},
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “bdc22ac4-3eb6-47a1-a9d3-5a3561a70c91”
},
“spec”: {
“description”: “CPU and Memory stress test VM”,
“name”: “stress-ng”,
“resources”: {
“image_type”: “DISK_IMAGE”,
“source_uri”: “”
}
},
“status”: {
“description”: “CPU and Memory stress test VM”,
“name”: “stress-ng”,
“resources”: {
“image_type”: “DISK_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/bdc22ac4-3eb6-47a1-a9d3-5a3561a70c91/file”
],
“size_bytes”: 26843545600,
“source_uri”: “”
},
“state”: “COMPLETE”
}
},
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “fd7d5c45-f219-4465-938b-0a9713ce4041”
},
“spec”: {
“description”: “Version 1.1.1 which will give you correct memory utilization”,
“name”: “VirtIO1.1.1”,
“resources”: {
“image_type”: “ISO_IMAGE”,
“source_uri”: “http://download.nutanix.com/mobility/1.1.1/Nutanix-VirtIO-1.1.1.iso”
}
},
“status”: {
“description”: “Version 1.1.1 which will give you correct memory utilization”,
“name”: “VirtIO1.1.1”,
“resources”: {
“image_type”: “ISO_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/fd7d5c45-f219-4465-938b-0a9713ce4041/file”
],
“size_bytes”: 47220736,
“source_uri”: “http://download.nutanix.com/mobility/1.1.1/Nutanix-VirtIO-1.1.1.iso”
},
“state”: “COMPLETE”
}
},
{
“metadata”: {
“categories”: {},
“kind”: “image”,
“spec_version”: 0,
“uuid”: “9397ab17-1a20-4d9b-a4dc-587552a9c732”
},
“spec”: {
“description”: “Windows Server 2012 R2”,
“name”: “Win2012R2”,
“resources”: {
“image_type”: “ISO_IMAGE”
}
},
“status”: {
“description”: “Windows Server 2012 R2”,
“name”: “Win2012R2”,
“resources”: {
“image_type”: “ISO_IMAGE”,
“retrieval_uri_list”: [
“https://127.0.0.1:9440/api/nutanix/v3/images/9397ab17-1a20-4d9b-a4dc-587552a9c732/file”
],
“size_bytes”: 4543252480
},
“state”: “COMPLETE”
}
}
],
“metadata”: {
“kind”: “image”,
“length”: 6,
“offset”: 0,
“sort_attribute”: “name”,
“sort_order”: “ASCENDING”,
“total_matches”: 6
}
}

 

1 ping

Comments have been disabled.