Counting protected virtual machines

You can count the virtual machines that are protected by IBM Spectrum Protect Plus.

Method and URI

To count protected virtual machines that are registered with IBM Spectrum Protect Plus, use a POST method and a URI:

POST    https://{hostname|IP}/api/endeavour/catalog/recovery/hypervisorvm

Parameters

Parameter 1: action

Invoke aggregate functions. For more information about aggregate functions, see Aggregate functions.

  • Value: aggregate

  • Type: System string. Required. Available in the web user interface.

Parameter 2: filter

Optionally, you may use a filter to specify the type of virtualized systems. If this parameter is not used, the request counts all protected virtual machines regardless of type. You can use the filter operation parameters that are described in Filter.

  • Example value: To search protected virtual machines for only VMware instances, use the following filter parameter:

[
    {
         "property": "hypervisorType",
         "value":    "vmware",
         "op":       "="
    }
]

Use one of the following values to specify the virtualized system:

Virtualized system

Value

VMware vCenter

vmware

Hyper-V

hyperv

Amazon EC2

awsec2

  • Type: Array. Available in the web user interface.

Data

Data 1: op

Use the COUNT() function for the pk values. For more information about the COUNT() function, see COUNT().

  • Value:

[
    {
        "operation":  "count",
        "fieldname":  "pk",
        "outputname": "count"
    }
]
  • Type: Array. Required. Available in the web user interface.

Example 1: Count protected virtual machines

A Python snippet that is similar to the following example can be used to invoke an aggregate function that counts virtual machines that are protected by IBM Spectrum Protect Plus.

_params = {"action": "aggregate"}

_data = f'''{{
    "op": [
        {{
            "operation":  "count",
            "fieldname":  "pk",
            "outputname": "count"
        }}
    ]
}}'''

requests.post('https://' + spp_ipv4
    + '/api/endeavour/recovery/hypervisorvm',
    headers={...}, params=_params, data=_data, verify=...)

The request prompts a response that is structured as shown, with the HTTP status of 200 (OK).

{
    "links": {...},
    "results": [
        {
            "_id": null,
            "count": 890
        }
    ]
}

Example 2: Count only VMware virtual machines

Add a filter to count only virtual machines that are hosted on VMware vCenter servers.

_params = {"action": "aggregate"}

_data = f'''{{
    "op": [
        {{
            "operation":  "count",
            "fieldname":  "pk",
            "outputname": "count"
        }}
    ],
    "filter": [
        {{
             "op":       "=",
             "property": "hypervisorType",
             "value":    "vmware"
        }}
    ]
}}'''

requests.post('https://' + spp_ipv4
    + '/api/endeavour/recovery/hypervisorvm',
    headers={...}, params=_params, data=_data, verify=...)

The request prompts a response that is structured as shown, with the HTTP status of 200 (OK).

{
    "links": {...},
    "results": [
        {
            "_id": null,
            "count": 700
        }
    ]
}