Skip to content
Jiří Stránský edited this page Jul 31, 2013 · 30 revisions

Resources:


Rack

create

curl -vX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d  '
{
  "subnet": "192.168.1.0/255",
  "name": "my_rack",
  "capacities": [{
    "name": "total_cpu",
    "value": "64"
  }, {
    "name": "total_memory",
    "value": "1024"
  }],
  "nodes": [{
    "id": "123"
  }, {
    "id": "345"
  }],
  "slots": 1
}
' http://0.0.0.0:6385/v1/racks

Create with Resource Class

curl -vX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d  '
{
  "subnet": "192.168.1.0/255",
  "name": "my_rack",
  "capacities": [{
    "name": "total_cpu",
    "value": "64"
  }, {
    "name": "total_memory",
    "value": "1024"
  }],
  "nodes": [{
    "id": "123"
  }, {
    "id": "345"
  }],
  "slots": 1,
  "resource_class":{
       "id":1,
       "links":[
          {
             "href":"http://0.0.0.0:6385/v1/resource_clases/1",
             "rel":"self"
          }
       ]
    }
}
' http://0.0.0.0:6385/v1/racks

### delete curl -vX DELETE http://localhost:6385/v1/racks/1
### update curl -v -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d '{ "name": "new_name" }' http://0.0.0.0:6385/v1/racks/1

update (change nodes to Rack 1)

curl -v -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d '{ "nodes": [ { "id": "1" }, { "id": "2"}] }' http://0.0.0.0:6385/v1/racks/1

back to top


Flavor - this resource only exists as part of ResourceClass:

Create a new Flavor for a specific ResourceClass:

curl -v -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d '
{
           "max_vms": 10,
           "name": "tiny",
           "capacities":
           [
               {
                   "value": "1",
                   "name": "cpu",
                   "unit": "count"
               },
               {
                   "value": "512",
                   "name": "memory",
                   "unit": "MiB"
               },
               {
                   "value": "512",
                   "name": "storage",
                   "unit": "GiB"
               }
           ]
 }'
http://0.0.0.0:6385/v1/resource_classes/1/flavors

Flavors can also be created as part of ResourceClass create operation:


### Can see the Flavor(s) for a particular ResourceClass:
curl -H "Accept: application/xml" http://0.0.0.0:6385/v1/resource_classes/1/flavors(/2)

### Can delete a specific Flavor from a given ResourceClass:
curl -X DELETE -H "Accept: application/xml" http://0.0.0.0:6385/v1/resource_classes/1/flavors/1

Update an existing Flavor in a specified ResourceClass:

curl -v -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d '
    {
       "capacities":
       [
           {
               "value": "5000",
               "name": "cpu",
               "unit": "count"
           },
           {
               "value": "1111",
               "name": "memory",
               "unit": "MiB"
           },
           {
               "value": "2222",
               "name": "storage",
               "unit": "GiB"
           }
       ],
       "max_vms": 9999,
       "name": "tiny_update"
    }'
http://0.0.0.0:6385/v1/resource_classes/1/flavors/3

NOTE: The above operation can be performed to change only part of a given flavor - such as updating the name or max_vms, or even a specific capacity. The body of the PUT request will determine what is updated. For example, to update the 'cpu' capacity and 'max_vms':

curl -v -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -v -d '
{   "max_vms": 1234,
   "capacities" :  [ 
                     {  "name": "cpu", 
                        "value" : "1",
                        "unit" : "count"  }
                   ]
}'
http://0.0.0.0:6385/v1/resource_classes/1/flavors/3

back to top


Resource Class

Get One

curl -H 'Accept: application/json' http://0.0.0.0:6385/v1/resource_classes/1

Response

{
   "id":11,
   "name":"test-chassis",
   "service_type":"compute",
   "racks":[
      {
         "id":1,
         "links":[
            {
               "href":"http://0.0.0.0:6385/v1/rack/1",
               "rel":"self"
            }
         ]
      }
   ],
   "links":[
      {
         "href":"http://0.0.0.0:6385/v1/resource_classes/11",
         "rel":"self"
      }
   ]
}

### Get Collection ``` curl -H 'Accept: application/json' http://0.0.0.0:6385/v1/resource_classes ```
### Create

Without Racks

  curl -iX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
  {
    "service_type": "compute",
    "name": "test-chassis"
  }
' http://0.0.0.0:6385/v1/resource_classes

With Racks and Flavor definitions:

    curl -iX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
    {
          "name": "test-chassis", 
          "service_type":"compute",
          "racks": [
              { "id":1,
                "links":[{"href":"http://0.0.0.0:6385/v1/racks/1","rel":"self"}]
              }
           ], 
           "flavors": [
                { "name" : "x-large",
                  "capacities" : [
                     {   "name": "cpu", 
                         "value" : "4",
                          "unit" : "count" }, 
                     {   "name": "memory",
                         "value" : "8192",
                         "unit" : "MiB" },
                     {   "name": "storage", 
                         "value" : "1024",
                         "unit" : "GiB" }
                  ]
                }
           ]
      }
' http://0.0.0.0:6385/v1/resource_classes

As a one-liner (copy/paste):

curl -iX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"service_type": "compute_1","name": "test-chassis", "service_type":"compute","racks":[{"id":1,"links":[{"href":"http://0.0.0.0:6385/v1/racks/1","rel":"self"}]}], "flavors": [{"name" : "x-large", "capacities" : [ { "name": "cpu", "value" : "4", "unit" : "count" }, { "name": "memory", "value" : "8192", "unit" : "MiB" }, { "name": "storage", "value" : "1024", "unit" : "GiB" }]}]}' http://0.0.0.0:6385/v1/resource_classes
  curl -iX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
  {
    "service_type": "compute",
    "name": "test-chassis",
    "racks":[
      {
        "id": 1,
        "links": [
          { 
            "href":"http://0.0.0.0:6385/v1/racks/1",
            "rel":"self"
          }
        ]
      }
    ]
  }
' http://0.0.0.0:6385/v1/resource_classes

as a one-liner (copy/paste):

curl -iX POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"service_type": "compute","name": "test-chassis", "service_type":"compute","racks":[{"id":1,"links":[{"href":"http://0.0.0.0:6385/v1/racks/1","rel":"self"}]}]}' http://0.0.0.0:6385/v1/resource_classes

### Update

To add or remove Racks on a resource class simply do an update and alter the racks array attribute accordingly.

  curl -iX PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -d '
  {
    "service_type": "compute",
    "name": "test-chassis",
    "racks":[
      {
        "id": 1,
        "links": [
          { 
            "href":"http://0.0.0.0:6385/v1/racks/1",
            "rel":"self"
          }
        ]
      }
    ]
  }
' http://0.0.0.0:6385/v1/resource_classes/13

Delete

curl -X DELETE http://0.0.0.0:6385/v1/resource_classes/1

back to top


DataCenter

Provision All

This will provision the data center according to its description in Tuskar.

curl -XPOST -H 'Content-Type:application/json' -H 'Accept: application/json' http://0.0.0.0:6385/v1/data_centers/

back to top