Listing Flavors

Once you have the server image URL, you will need the URL of the virtual machine flavor. You can list available flavors by sending your request to the /flavors URL using the GET method. The following example shows how it is done using the curl command:

$ curl -v -H "X-Auth-Token:999888777666" http://localhost:8774/v1.1/openstack/flavors

As with every call you make to the OpenStack Compute API you must include the X-Auth-Token header with a valid token otherwise the OpenStack Compute API will return the 401 Unauthorized error.

When all goes well, you will get a JSON string that looks like the one below:

{"flavors": [{"id": 3, "links": [{"href": "http://localhost:8774/v1.1/openstack/flavors/3", "rel": "self"}, {"href": "http://localhost:8774/openstack/flavors/3", "rel": "bookmark"}], "name": "m1.medium"}, {"id": 4, "links": [{"href": "http://localhost:8774/v1.1/openstack/flavors/4", "rel": "self"}, {"href": "http://localhost:8774/openstack/flavors/4", "rel": "bookmark"}], "name": "m1.large"}, {"id": 1, "links": [{"href": "http://localhost:8774/v1.1/openstack/flavors/1", "rel": "self"}, {"href": "http://localhost:8774/openstack/flavors/1", "rel": "bookmark"}], "name": "m1.tiny"}, {"id": 5, "links": [{"href": "http://localhost:8774/v1.1/openstack/flavors/5", "rel": "self"}, {"href": "http://localhost:8774/openstack/flavors/5", "rel": "bookmark"}], "name": "m1.xlarge"}, {"id": 2, "links": [{"href": "http://localhost:8774/v1.1/openstack/flavors/2", "rel": "self"}, {"href": "http://localhost:8774/openstack/flavors/2", "rel": "bookmark"}], "name": "m1.small"}]}

Here is a version that is easier to read:

{
  "flavors": [
    {
      "id": 3, 
      "links": [
        {
          "href": "http://localhost:8774/v1.1/openstack/flavors/3", 
          "rel": "self"
        }, 
        {
          "href": "http://localhost:8774/openstack/flavors/3", 
          "rel": "bookmark"
        }
      ], 
      "name": "m1.medium"
    }, 
    {
      "id": 4, 
      "links": [
        {
          "href": "http://localhost:8774/v1.1/openstack/flavors/4", 
          "rel": "self"
        }, 
        {
          "href": "http://localhost:8774/openstack/flavors/4", 
          "rel": "bookmark"
        }
      ], 
      "name": "m1.large"
    }, 
    {
      "id": 1, 
      "links": [
        {
          "href": "http://localhost:8774/v1.1/openstack/flavors/1", 
          "rel": "self"
        }, 
        {
          "href": "http://localhost:8774/openstack/flavors/1", 
          "rel": "bookmark"
        }
      ], 
      "name": "m1.tiny"
    }, 
    {
      "id": 5, 
      "links": [
        {
          "href": "http://localhost:8774/v1.1/openstack/flavors/5", 
          "rel": "self"
        }, 
        {
          "href": "http://localhost:8774/openstack/flavors/5", 
          "rel": "bookmark"
        }
      ], 
      "name": "m1.xlarge"
    }, 
    {
      "id": 2, 
      "links": [
        {
          "href": "http://localhost:8774/v1.1/openstack/flavors/2", 
          "rel": "self"
        }, 
        {
          "href": "http://localhost:8774/openstack/flavors/2", 
          "rel": "bookmark"
        }
      ], 
      "name": "m1.small"
    }
  ]
}

The list of virtual machine flavors is arranged in a way similar to the list of server images. Each item on the flavors list represents a single virtual machine flavor. It is a dictionary with three keys:

  • id — the numeric ID of the flavor.

  • links — the list of the URLs of the locations where you can find the flavor.

  • name — a descriptive name of the flavor.

Here's how one virtual machine flavor is represented in that response:

{
  "id": 1, 
  "links": [
    {
      "href": "http://localhost:8774/v1.1/openstack/flavors/1", 
      "rel": "self"
    }, 
    {
      "href": "http://localhost:8774/openstack/flavors/1", 
      "rel": "bookmark"
    }
  ], 
  "name": "m1.tiny"
}, 


loading table of contents...