inode71
Contributor
Contributor

rest API get resource_pool not returning all values

According to the VMware developer documentation, GET https://{api_host}/api/vcenter/resource-pool/{resource_pool} should return this ResourcePoolInfo json:

{
    "cpu_allocation": {
        "expandable_reservation": false,
        "limit": 0,
        "reservation": 0,
        "shares": {
            "level": "enum",
            "shares": 0
        }
    },
    "memory_allocation": {
        "expandable_reservation": false,
        "limit": 0,
        "reservation": 0,
        "shares": {
            "level": "enum",
            "shares": 0
        }
    },
    "name": "string",
    "resource_pools": [
        "string"
    ]
}

When I run it, I only get name and resource_pools:

{'value': {'name': 'rp-rancher-dev-310', 'resource_pools': []}}

I can't see what might be wrong with my code that it isn't returning the expected info.

Anyone see it?

resp = requests.get("https://vcdb004.my.domain/rest/vcenter/resource-pool", verify=True, headers={"vmware-api-session-id": session_id})

for line in json.loads(resp.text)['value']:
    if re.search('rp-rancher-dev-310', line['name']):
        resp = requests.get(f"https://vcdb004.my.domain/rest/vcenter/resource-pool/{line['resource_pool']}",
                            verify=True, headers={"vmware-api-session-id": session_id})
        pool_json = json.loads(resp.text)
        pprint.pprint(pool_json)
0 Kudos
0 Replies