netapp_ontap.resources.metrocluster API documentation
Description: Copyright &copy; 2020 NetApp Inc. All rights reserved …

# Module `netapp_ontap.resources.metrocluster`

Copyright © 2020 NetApp Inc. All rights reserved.

# Overview

You can use this API to create, perform operations, and retrieve relevant information pertaining to MetroCluster. The GET operation fetches MetroCluster status and configuration parameters for the local and partner cluster. The PATCH operation executes a switchover or switchback operation. The POST request can be used to setup a MetroCluster.

## Creating a MetroCluster

A new MetroCluster can be set up by issuing a POST to /cluster/metrocluster. Parameters are provided in the body of the POST request.

### Fields used for setting up a MetroCluster configuration

The fields used for MetroCluster APIs are either required or optional and are described as follows:

### Required configuration fields

These fields are always required for any POST /cluster/metrocluster request.

- `partner_cluster.name` - Specifies the partner cluster name to which cluster peering has been established.
- `dr_pairs` - Specifies local and DR partner node pairs. Each pair uniquely identifies a DR group.

### Optional configuration fields

This field is used to set up additional components in a MetroCluster configuration.

- `mediator.*` - Specifies mediator parameters. If Mediator Assisted Unplanned Switchover (MAUSO) functionality is required, then a mediator should be configured.
- `vlans` - Specifies VLAN IDs and port combination for MetroCluster platforms supporting custom VLAN IDs.

### Polling the setup job

After a successful POST /cluster/metrocluster is issued, an HTTP status code of 202 (Accepted) is returned along with a job UUID and a link in the body of the response. The setup job continues asynchronously and can be monitored by using the job UUID and the /cluster/jobs API. The "message" field in the response of the GET /cluster/jobs/{uuid} request shows the current step in the job, and the "state" field shows the overall state of the job.

## Examples

## Setting up a 4-node MetroCluster

    This example shows the POST body when setting up a 4-node MetroCluster along with a mediator. It is required that cluster peering be established between two clusters, in this example, site "mcc_siteA" and "mcc_siteB" before issuing the POST request. Nodes "node-a" and "node-b" are HA partners and part of the local cluster "mcc_siteA", wheres nodes "node-c" and "node-d" are HA partners in the partner cluster  "mcc_siteB". Specifying a single DR pairing of "node-a" and "node-c" is sufficient to identify a DR group -- "node-a" and "node-c" will be designated primary DR partners ("node-b" and "node-d" too). "node-d" will then be designated auxiliary partner of "node-a". Once the MetroCluster configuration has been completed, and since mediator parameters have been provided, the mediator will be setup and MAUSO enabled.
    # API
    /api/cluster/metrocluster

### POST body included from file

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Metrocluster

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Metrocluster()
        resource.partner_cluster.name = "mcc_siteB"
        resource.dr_pairs = [{"node": {"name": "node-a"}, "partner": {"name": "node-c"}}]
        resource.mediator.ip_address = "1.2.3.4"
        resource.mediator.user = "mcc_mediator"
        resource.mediator.password = "openMediator"
        resource.post(hydrate=True)
        print(resource)

### Inline POST body

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Metrocluster

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Metrocluster()
        resource.partner_cluster.name = "mcc_siteB"
        resource.dr_pairs = [{"node": {"name": "node-a"}, "partner": {"name": "node-c"}}]
        resource.mediator.ip_address = "1.2.3.4"
        resource.mediator.user = "mcc_mediator"
        resource.mediator.password = "openMediator"
        resource.post(hydrate=True)
        print(resource)

### POST Response

    HTTP/1.1 202 Accepted
    Date: Thu, 09 Jan 2020 20:38:05 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Location: /api/cluster/metrocluster
    Content-Length: 189
    Content-Type: application/hal+json
    {
      "job": {
        "uuid": "f23abbdb-331f-11ea-acd3-005056a708b2",
        "_links": {
          "self": {
            "href": "/api/cluster/jobs/f23abbdb-331f-11ea-acd3-005056a708b2"
          }
        }
      }
    }

### Monitoring the job progress

Use the link provided in the response to the POST request to fetch information for the setup job.

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Job

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Job(uuid="f23abbdb-331f-11ea-acd3-005056a708b2")
        resource.get()
        print(resource)

#### Job status response

The following is an example of the job status response returned by the running MetroCluster setup job:

    HTTP/1.1 200 OK
    Date: Thu, 09 Jan 2020 20:40:20 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Content-Length: 373
    Content-Type: application/hal+json
    {
      "uuid": "f23abbdb-331f-11ea-acd3-005056a708b2",
      "description": "POST /api/cluster/metrocluster",
      "state": "running",
      "message": "Checking remote storage pool",
      "code": 2432844,
      "start_time": "2020-01-09T15:38:08-05:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/f23abbdb-331f-11ea-acd3-005056a708b2"
        }
    }

### Completion message

This is the final update message from the setup job indicating completion.

    {
      "uuid": "f23abbdb-331f-11ea-acd3-005056a708b2",
      "description": "POST /api/cluster/metrocluster",
      "state": "running",
      "message": "MetroCluster setup is complete",
      "code": 2432849,
      "start_time": "2020-01-09T15:38:08-05:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/f23abbdb-331f-11ea-acd3-005056a708b2"
        }
      }
    }

### Final status of a successful MetroCluster setup workflow

When the setup job completes, the 'end_time' field is populated, and the 'state' and 'message' fields report the final status.

    HTTP/1.1 200 OK
    Date: Thu, 09 Jan 2020 20:43:54 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Content-Length: 360
    Content-Type: application/hal+json
    {
      "uuid": "f23abbdb-331f-11ea-acd3-005056a708b2",
      "description": "POST /api/cluster/metrocluster",
      "state": "success",
      "message": "success",
      "code": 0,
      "start_time": "2020-01-09T15:38:08-05:00",
      "end_time": "2020-01-09T15:43:50-05:00",
      "_links": {
        "self": {
          "href": "/api/cluster/jobs/f23abbdb-331f-11ea-acd3-005056a708b2"
        }
      }
    }

### Retrieving the MetroCluster configuration after completion of the POST request

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Metrocluster

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Metrocluster()
        resource.get()
        print(resource)

#### Response

    HTTP/1.1 200 OK
    Date: Thu, 09 Jan 2020 20:49:40 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Content-Length: 849
    Content-Type: application/hal+json
    {
      "local": {
        "configuration_state": "configured",
        "periodic_check_enabled": true,
        "mode": "normal",
        "partner_cluster_reachable": true,
        "cluster": {
          "name": "mcc_siteA",
          "uuid": "4294c4f2-30e2-11ea-8cac-005056a708b2",
          "_links": {
            "self": {
              "href": "/api/cluster/4294c4f2-30e2-11ea-8cac-005056a708b2"
            }
          }
        }
      },
      "remote": {
        "configuration_state": "configured",
        "periodic_check_enabled": true,
        "mode": "normal",
        "cluster": {
          "name": "mcc_siteB",
          "uuid": "4207c6a5-30e2-11ea-be25-005056a7dc84",
          "_links": {
            "self": {
              "href": "/api/cluster/4207c6a5-30e2-11ea-be25-005056a7dc84"
            }
          }
        }
      },
      "_links": {
        "self": {
          "href": "/api/cluster/metrocluster"
        }
      }
    }

### Retrieving information about the nodes in a MetroCluster configuration

#### Request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import MetroclusterNode

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(MetroclusterNode.get_collection()))

#### Response

    HTTP/1.1 200 OK
    Date: Fri, 10 Jan 2020 02:26:20 GMT
    Server: libzapid-httpd
    X-Content-Type-Options: nosniff
    Cache-Control: no-cache,no-store,must-revalidate
    Content-Type: application/hal+json
    Transfer-Encoding: chunked
    {
      "records": [
        {
          "dr_group_id": 1,
          "cluster": {
            "name": "mcc_siteA",
            "uuid": "4294c4f2-30e2-11ea-8cac-005056a708b2",
            "_links": {
              "self": {
                "href": "/api/cluster/4294c4f2-30e2-11ea-8cac-005056a708b2"
              }
            }
          },
          "node": {
            "name": "node-a",
            "uuid": "1e6b0137-30dd-11ea-82ba-005056a7c78a",
            "_links": {
              "self": {
                "href": "/api/cluster/nodes/1e6b0137-30dd-11ea-82ba-005056a7c78a"
              }
            }
          },
          "_links": {
            "self": {
              "href": "/api/cluster/metrocluster/nodes/1e6b0137-30dd-11ea-82ba-005056a7c78a"
            }
          }
        },
        {
          "dr_group_id": 1,
          "cluster": {
            "name": "mcc_siteA",
            "uuid": "4294c4f2-30e2-11ea-8cac-005056a708b2",
            "_links": {
              "self": {
                "href": "/api/cluster/4294c4f2-30e2-11ea-8cac-005056a708b2"
              }
            }
          },
          "node": {
            "name": "node-b",
            "uuid": "1e57ba22-30dd-11ea-8b19-005056a708b2",
            "_links": {
              "self": {
                "href": "/api/cluster/nodes/1e57ba22-30dd-11ea-8b19-005056a708b2"
              }
            }
          },
          "_links": {
            "self": {
              "href": "/api/cluster/metrocluster/nodes/1e57ba22-30dd-11ea-8b19-005056a708b2"
            }
          }
        },
        {
          "dr_group_id": 1,
          "cluster": {
            "name": "mcc_siteB",
            "uuid": "4207c6a5-30e2-11ea-be25-005056a7dc84",
            "_links": {
              "self": {
                "href": "/api/cluster/4207c6a5-30e2-11ea-be25-005056a7dc84"
              }
            }
          },
          "node": {
            "name": "node-c",
            "uuid": "1e563efc-30dd-11ea-a9d3-005056a71573",
            "_links": {
              "self": {
                "href": "/api/cluster/nodes/1e563efc-30dd-11ea-a9d3-005056a71573"
              }
            }
          },
          "_links": {
            "self": {
              "href": "/api/cluster/metrocluster/nodes/1e563efc-30dd-11ea-a9d3-005056a71573"
            }
          }
        },
        {
          "dr_group_id": 1,
          "cluster": {
            "name": "mcc_siteB",
            "uuid": "4207c6a5-30e2-11ea-be25-005056a7dc84",
            "_links": {
              "self": {
                "href": "/api/cluster/4207c6a5-30e2-11ea-be25-005056a7dc84"
              }
            }
          },
          "node": {
            "name": "node-d",
            "uuid": "1e400aa4-30dd-11ea-adec-005056a7dc84",
            "_links": {
              "self": {
                "href": "/api/cluster/nodes/1e400aa4-30dd-11ea-adec-005056a7dc84"
              }
            }
          },
          "_links": {
            "self": {
              "href": "/api/cluster/metrocluster/nodes/1e400aa4-30dd-11ea-adec-005056a7dc84"
            }
          }
        }
      ],
      "num_records": 4,
      "_links": {
        "self": {
          "href": "/api/cluster/metrocluster/nodes"
        }
      }
    }

### Retrieving MetroCluster status and configuration information

    GET <https://<mgmt-ip>>/api/cluster/metrocluster
    {
        "local": {
            "configuration_state": "configured",
            "periodic_check_enabled": true,
            "mode": "normal",
            "cluster": {
                "name": "cluster1",
                "uuid": "bbc00ca3-8d81-11e9-b5a9-005056826931",
                "_links": {
                    "self": {
                        "href": "/api/cluster/bbc00ca3-8d81-11e9-b5a9-005056826931"
                    }
                }
            }
        },
        "remote": {
            "configuration_state": "configured",
            "periodic_check_enabled": true,
            "mode": "normal",
            "cluster": {
                "name": "cluster3",
                "uuid": "ce2cf803-8d81-11e9-87db-00505682cecf",
                "_links": {
                    "self": {
                        "href": "/api/cluster/ce2cf803-8d81-11e9-87db-00505682cecf"
                    }
                }
            }
        },
        "_links": {
            "self": {
                "href": "/api/cluster/metrocluster"
            }
        }
    }

### Initiating a switchover or switchback command using PATCH

PATCH is used to initiate a variety of operations by specifying one of the following values in the "action" parameter:

- `switchover` - Initiates an Unplanned Switchover (USO).
- `negotiated_switchover` - Indicates that an Negotiated switchover (NSO) is to be performed.
- `negotiated_switchover_simulate` - Provides validation in preparation for NSO but does not perform the operation.
- `switchback` - Indicates that a switchback is to be performed.
- `switchback_simulate` - Provides validation for switchback but does not commit the operation.

#### PATCH Switchover example

    PATCH <https://<mgmt-ip>>/api/cluster/metrocluster?action=switchover
    {
        "job": {
            "uuid": "70e54274-57ee-11e9-aa33-005056820b99",
            "_links": {
                "self": {
                    "href": "/api/cluster/jobs/70e54274-57ee-11e9-aa33-005056820b99"
                }
            }
        }
    }

This returns a job UUID. A subsequent GET for this job should return the following:

    GET <https://<mgmt-ip>>/api/cluster/jobs/70e54274-57ee-11e9-aa33-005056820b99
    {
        "uuid": "70e54274-57ee-11e9-aa33-005056820b99",
        "description": "MetroCluster Switchover Job",
        "state": "success",
        "message": "Complete: Switchover is successful.",
        "code": 0,
        "start_time": "2019-04-05T15:02:02-07:00",
        "end_time": "2019-04-05T15:02:30-07:00",
        "_links": {
            "self": {
                "href": "/api/cluster/jobs/70e54274-57ee-11e9-aa33-005056820b99"
            }
        }
    }

#### PATCH Switchback example:

    PATCH <https://<mgmt-ip>>/api/cluster/metrocluster?action=switchback
    {
        "job": {
            "uuid": "a62714cc-57ec-11e9-aa33-005056820b99",
            "_links": {
                "self": {
                    "href": "/api/cluster/jobs/a62714cc-57ec-11e9-aa33-005056820b99"
                }
            }
        }
    }

This returns a job UUID with a link to the job. A subsequent GET for this job UUID can be used to retrieve the completion status of the operation:

    GET <https://<mgmt-ip>>/api/cluster/jobs/a62714cc-57ec-11e9-aa33-005056820b99
    {
        "uuid": "a62714cc-57ec-11e9-aa33-005056820b99",
        "description": "MetroCluster Switchback Job",
        "state": "success",
        "message": "Complete: Switchback is successful.",
        "code": 0,
        "start_time": "2019-04-05T14:49:12-07:00",
        "end_time": "2019-04-05T14:50:12-07:00",
        "_links": {
            "self": {
                "href": "/api/cluster/jobs/a62714cc-57ec-11e9-aa33-005056820b99"
            }
        }
    }

## Classes

`class Metrocluster (*args, **kwargs)`

  Holds MetroCluster status and configuration parameters for the local and remote clusters. REST: /api/cluster/metrocluster

  Initialize the instance of the resource.

  Any keyword arguments are set on the instance as properties. For example, if the class was named 'MyResource', then this statement would be true:

      MyResource(name='foo').name == 'foo'

  ## Args

  `*args`
    Each positional argument represents a parent key as used in the URL of the object. That is, each value will be used to fill in a segment of the URL which refers to some parent object. The order of these arguments must match the order they are specified in the URL, from left to right.
  `**kwargs`
    each entry will have its key set as an attribute name on the instance and its value will be the value of that attribute.

  ### Ancestors

  - Resource

  ### Methods

  `def get(self, **kwargs) -> NetAppResponse`

    Retrieves MetroCluster status and configuration details.

    ### Related ONTAP commands * `metrocluster show` * `metrocluster node show`

    ### Learn more

    - `DOC /cluster/metrocluster`

    Fetch the details of the object from the host.

    Requires the keys to be set (if any). After returning, new or changed properties from the host will be set on the instance.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def patch(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Initiates a switchover or switchback operation.

    ### Related ONTAP commands * `metrocluster switchover` * `metrocluster switchback`

    ### Learn more

    - `DOC /cluster/metrocluster`

    Send the difference in the object's state to the host as a modification request.

    Calculates the difference in the object's state since the last time we interacted with the host and sends this in the request body.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def post(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Sets up a MetroCluster.

    ### Required properties

    - `partner_cluster.name`
    - `dr_pairs`

    ### Recommended optional properties

    - `mediator.*`

    ### Learn more

    - `DOC /cluster/metrocluster`

    ### Related ONTAP commands

    - `metrocluster configuration-settings dr-group create`
    - `metrocluster configuration-settings interface create`
    - `metrocluster configuration-settings connection connect`
    - `metrocluster configuration-settings mediator add`
    - `storage aggregate create`
    - `storage aggregate mirror`
    - `metrocluster configure`

    Send this object to the host as a creation request.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
`class MetroclusterSchema (*, only: typing.Union = None, exclude: typing.Union = (), many: bool = False, context: typing.Dict = None, load_only: typing.Union = (), dump_only: typing.Union = (), partial: typing.Union = False, unknown: str = None)`

  The fields of the Metrocluster object

  ### Ancestors

  - netapp_ontap.resource.ResourceSchema
  - marshmallow.schema.Schema
  - marshmallow.base.SchemaABC

  ### Class variables

  `dr_pairs POST`

    DR Pairs to create as part of a MetroCluster configure.

  `enabled GET`

    The enabled field of the metrocluster.

  `links GET`

    The links field of the metrocluster.

  `local GET POST PATCH`

    The local field of the metrocluster.

  `mediator POST`

    The mediator field of the metrocluster.

  `partner_cluster POST`

    The partner_cluster field of the metrocluster.

  `remote GET POST PATCH`

    The remote field of the metrocluster.

  `vlans POST`

    List of VLAN IDs and Port pairs.