Cheat Sheet - Cloud Foundry

Quotas

Org

## Query single org
$ cf quota org1
Getting quota org1 info as john.doe@somecorp.com...
OK

Total Memory           16G
Instance Memory        4G
Routes                 -1
Services               unlimited
Paid service plans     allowed
App instance limit     unlimited
Reserved Route Ports   unlimited


## Query multiple orgs
$ cf quotas | awk 'NR == 4 || /(org1|org2) /'
name                      total memory   instance memory   routes      service instances   paid plans   app instances   route ports
org1                      16G            4G                unlimited   unlimited           allowed      unlimited       unlimited
org2                      48G            4G                unlimited   unlimited           allowed      unlimited       unlimited

Quota usage

Currently the organization API does not fully summarize this information. However, you could construct it out of the following calls. Quota usage currently consists of memory reserved, service_instances created, and routes created. To get memory and instances, first get the org summary:

cf curl /v2/organizations/ORG_GUID/summary
{
  "spaces": [
  {
      "mem_prod_total": 0,
      "mem_dev_total": 2816,
      "app_count": 5,
      "service_count": 5,
      "name": "some-space",
      "guid": "SPACE_GUID"
    },
    {
      "mem_prod_total": 0,
      "mem_dev_total": 2816,
      "app_count": 6,
      "service_count": 3,
      "name": "some-other-space",
      "guid": "SPACE_GUID"
    }
  ],
  "status": "active",
  "name": "org-name",
  "guid": "ORG_GUID"
}

You can then tally up mem_prod_totaland mem_dev_total for each space to get the memory usage, and tally up service_count to get service instances used.

To get total routes used, take the space guids from the previous call and request the routes:

cf curl /v2/spaces/SPACE_GUID/routes

total_results or a count of the returned resources will give you the number of routes for that space.

Space

$ cf space-quotas
Getting space quotas as john.doe@somecorp.com...
OK

name   total memory   instance memory   routes   service instances   paid plans   app instances   route ports
int    8G             4G                -1       unlimited           allowed      unlimited       unlimited
prod   8G             4G                -1       unlimited           allowed      unlimited       unlimited

Sources: