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

# Module `netapp_ontap.resources.cluster_peer`

Copyright © 2020 NetApp Inc. All rights reserved.

## Overview

Cluster peering allows administrators of ONTAP systems to establish relationships between two or more independent clusters. When a relationship exists between two clusters, the clusters can exchange user data and configuration information, and coordinate operations. The /cluster/peers endpoint supports create, get, modify, and delete operations using GET, PATCH, POST and DELETE HTTP requests.

## Create a cluster peer

You can set up a new cluster peer relationship by issuing a POST request to /cluster/peers. Parameters in the POST body define the settings of the peering relationship. A successful POST request that succeeds in creating a peer returns HTTP status code "201", along with the details of the created peer, such as peer UUID, name, and authentication information. A failed POST request returns an HTTP error code along with a message indicating the reason for the error. This can include malformed requests and invalid operations.

### Sample request

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClusterPeer()
        resource.authentication.expiry_time = "12/25/2018 12:34:56"
        resource.authentication.generate_passphrase = True
        resource.post(hydrate=True)
        print(resource)

### Examples

    # Create - no params
    body = {}
    # Creating with a peer address and a passphrase
    body =
    {
        "remote":
          {
              "ip_addresses":["1.2.3.4"]
          }
    }
    # Creating with a peer name and a generated passphrase that is true
    body =
    {
        "name":"cp_xyz123",
        "authentication":
          {
              "generate_passphrase":true
          }
    }
    # Creating with a name, a peer address, and a passphrase
    body =
    {
        "name":"cp_xyz123",
        "remote":
          {
              "ip_addresses": ["1.2.3.4"]
          },
        "authentication":
          {
              "passphrase":"xyz12345"
          }
     }
    # Creating with a proposed encryption protocol
    body =
    {
        "encryption":
          {
              "proposed":"tls-psk"
          }
    }

## Create local intercluster LIFs

The local cluster must have an intercluster LIF on each node for the correct operation of cluster peering. If no local intercluster LIFs exist, you can optionally specify LIFs to be created for each node in the local cluster. These local interfaces, if specified, are created on each node before proceeding with the creation of the cluster peering relationship. Cluster peering relationships are not established if there is an error preventing the LIFs from being created. After local interfaces have been created, do not specify them for subsequent cluster peering relationships.

### Local LIF creation fields

- local_network.ip_addresses - List of IP addresses to assign, one per node in the local cluster.
- local_network.netmask - IPv4 mask or subnet mask length.
- local_network.broadcast_domain - Broadcast domain that is in use within the IPspace.
- local_network.gateway - The IPv4 or IPv6 address of the default router.

### Additional information on network routes

When creating LIFs, the network route discovery mechanism might take additional time (1-5 seconds) to become visible in the network outside of the cluster. This delay in publishing the routes might cause an initial cluster peer "create" request to fail. This error disappears with a retry of the same request.

### Example

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClusterPeer()
        resource.local_network.interfaces = [
            {"ip_address": "1.2.3.4"},
            {"ip_address": "1.2.3.5"},
            {"ip_address": "1.2.3.6"},
        ]
        resource.local_network.netmask = "255.255.0.0"
        resource.local_network.broadcast_domain = "Default"
        resource.local_network.gateway = "1.2.0.1"
        resource.remote.ip_addresses = ["1.2.9.9"]
        resource.authentication.passphrase = "xyz12345"
        resource.post(hydrate=True)
        print(resource)

## Note that "" is replaced by the IP address of the cluster management interface, and the body is read from the specified text file containing the fields for the new peering relationship and local interfaces.

## Retrieve a cluster peer

You can retrieve peers in a cluster by issuing a GET request to /cluster/peers. It is also possible to retrieve a specific peer when qualified by its UUID to /cluster/peers/{uuid}. A GET request might have no query parameters or a valid cluster UUID. The former retrieves all records while the latter retrieves the record for the cluster peer with that UUID. The following fields are used for retrieving a cluster peer.

### Required fields

There are no required fields for GET requests.

### Optional fields

The following fields are optional for GET requests

- UUID - UUID of the cluster peer.

### Examples

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

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

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

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

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClusterPeer(uuid="{uuid}")
        resource.get(fields="*")
        print(resource)

## Update a cluster peer

You can update a cluster peer relationship by issuing a PATCH request to /cluster/peers/{uuid}. As in the CLI mode, you can toggle the proposed encryption protocol, update the passphrase, or specify a new set of stable addresses. All PATCH requests take the parameters that are to be updated in the request body. If the generate_passphrase is "true", the passphrase is returned in the PATCH response. This following fields highlight the parameters that control the modification of an existing cluster peering relationship.

### Required fields

A PATCH request with an empty body has no effect on the cluster peer instance. All other fields and the combinations in which they are valid are indicated below:

- `encryption_proposed` - Toggle the proposed encryption protocol (from "none" to "tls-psk" or otherwise). Authentication must be "true" and a passphrase must be present in body.
- `passphrase`
- `passphrase` or `generate passphrase`
- `remote.ip_addresses`

### Optional fields

- `expiration time` - Set the expiration time of the passphrase.

### Examples

    # Updating with an empty body
    body = {}
    # Updating the proposed encryption protocol from tls-psk to none
    body =
    {
        "authentication":
          {
              "passphrase":"xyz12345",
              "in_use":"ok"
          },
        "encryption":
          {
              "proposed":"none"
          }
    }
    # Updating the passphrase
    body =
    {
        "authentication":
         {
             "passphrase":"xyz12345",
             "in_use":"ok"
         }
    }
    # Setting an auto-generated passphrase
    body =
    {
        "authentication":
         {
             "generate_passphrase": true,
             "in_use":"ok"
         }
    }
    # Updating remote IP addresses
    body =
    {
        "remote":
          {
              "ip_addresses":["10.224.65.30"]
          }
    }

### Sample requests

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClusterPeer(uuid="73123071-d0b9-11e8-a686-005056a7179a")
        resource.authentication.passphrase = "xyz12345"
        resource.authentication.in_use = "ok"
        resource.patch()

## Delete a cluster peer

You can delete a cluster peer using the HTTP DELETE request.

### Required fields

Perform all delete operations on a valid peer UUID. Deleting an invalid peer returns "HTTP 404", which indicates an error.

### Optional fields

The DELETE operation has no optional fields.

### Request format

DELETE "https:///api/cluster/peers/{uuid}"

### Example

The following request deletes a peer with peer UUID "8becc0d4-c12c-11e8-9ceb-005056bbd143".

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import ClusterPeer

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = ClusterPeer(uuid="8becc0d4-c12c-11e8-9ceb-005056bbd143")
        resource.delete()

## Classes

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

  Allows interaction with ClusterPeer objects on the host

  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

  ### Static methods

  `def count_collection(*args, connection: HostConnection = None, **kwargs) -> int`

    Retrieves the collection of cluster peers.

    ### Learn more

    - `DOC /cluster/peers`

    Fetch a count of all objects of this type from the host.

    This calls GET on the object to determine the number of records. It is more efficient than calling get_collection() because it will not construct any objects. Query parameters can be passed in as kwargs to determine a count of objects that match some filtered criteria.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the count of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. These query parameters can affect the count. A return_records query param will be ignored.

    ## Returns

    On success, returns an integer count of the objects of this type. On failure, returns -1.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400, or if there is no connection available to use either passed in or on the library.

  `def delete_collection(*args, body: typing.Union = None, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Deletes a cluster peer.

    ### Learn more

    - `DOC /cluster/peers`

    Delete all objects in a collection which match the given query.

    All records on the host which match the query will be deleted.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to delete the collection of bars for a particular foo, the foo.name value should be passed.
    `body`
      The body of the delete request. This could be a Resource instance or a dictionary object.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be patched.

    ## Returns

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

    ## Raises

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

  `def find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves the collection of cluster peers.

    ### Learn more

    - `DOC /cluster/peers`

    Find an instance of an object on the host given a query.

    The host will be queried with the provided key/value pairs to find a matching resource. If 0 are found, None will be returned. If more than 1 is found, an error will be raised or returned. If there is exactly 1 matching record, then it will be returned.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to find a bar for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A `Resource` object containing the details of the object or None if no matches were found.

    ## Raises

    `NetAppRestError`: If the API call returned more than 1 matching resource.

  `def get_collection(*args, connection: HostConnection = None, max_records: int = None, **kwargs) -> typing.Iterable`

    Retrieves the collection of cluster peers.

    ### Learn more

    - `DOC /cluster/peers`

    Fetch a list of all objects of this type from the host.

    This is a lazy fetch, making API calls only as necessary when the result of this call is iterated over. For instance, if max_records is set to 5, then iterating over the collection causes an API call to be sent to the server once for every 5 records. If the client stops iterating before getting to the 6th record, then no additional API calls are made.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `max_records`
      The maximum number of records to return per call
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A list of `Resource` objects

    ## Raises

    `NetAppRestError`: If there is no connection available to use either passed in or on the library. This would be not be raised when get_collection() is called, but rather when the result is iterated.

  `def patch_collection(body: dict, *args, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Updates a cluster peer instance.

    ### Learn more

    - `DOC /cluster/peers`

    Patch all objects in a collection which match the given query.

    All records on the host which match the query will be patched with the provided body.

    ## Args

    `body`
      A dictionary of name/value pairs to set on all matching members of the collection.
    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to patch the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be patched.

    ## Returns

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

    ## Raises

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

  ### Methods

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

    Deletes a cluster peer.

    ### Learn more

    - `DOC /cluster/peers`

    Send a deletion request to the host for this object.

    ## Args

    `body`
      The body of the delete request. This could be a Resource instance or a dictionary 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 be sent as query parameters to the host.

    ## Returns

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

    ## Raises

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

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

    Retrieves a specific cluster peer instance.

    ### Learn more

    - `DOC /cluster/peers`

    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`

    Updates a cluster peer instance.

    ### Learn more

    - `DOC /cluster/peers`

    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`

    Creates a peering relationship and, optionally, the IP interfaces it will use. There are two methods used to create a peering relationship: * Provide a remote IP address - Used when creating a new cluster peer relationship with a specific remote cluster. This requires at least one remote intercluster IP address from the remote cluster. * Do not provide a remote IP address - Used when the remote IP address is not provided and when the storage system is ready to accept peering requests from foreign clusters.

    ### Required properties

    - `remote.ip_addresses` - Addresses of the remote peers. The local peer must be able to reach and connect to these addresses for the request to succeed in creating a peer. Only required when creating a peering relationship by providing a remote IP address.
    - Either set `generate_passphrase` to "true" or provide a passphrase in the body of the request. Only one of these options is required.

    ### Recommended optional properties

    - `name` - Name of the peering relationship or name of the remote peer.
    - `passphrase` - User generated passphrase for use in authentication.
    - `generate_passphrase` (true/false) - When "true", ONTAP automatically generates a passphrase to authenticate cluster peers.
    - `ipspace` - IPspace of the local intercluster LIFs. Assumes Default IPspace if not provided.
    - `initial_allowed_svms` - Local SVMs allowed to peer with the peer cluster's SVMs. Can be modified until the remote cluster accepts this cluster peering relationship.
    - `local_network` - Fields to create a local intercluster LIF.
    - `expiry_time` - Duration in ISO 8601 format for which the user-supplied or auto-generated passphrase is valid. Expiration time must not be greater than seven days into the future. ISO 8601 duration format is "PnDTnHnMnS" or "PnW" where n is a positive integer. The "nD", "nH", "nM" and "nS" fields can be dropped if zero. "P" must always be present and "T" must be present if there are any hours, minutes, or seconds fields.
    - `encryption_proposed` (none/tls-psk) - Encryption mechanism of the communication channel between the two peers.
    - `peer_applications` - SVM peering applications (SnapMirror, FlexCache or both) for which the SVM peering relationship is set up.

    ### Additional information

    As with creating a cluster peer through the CLI, the combinations of options must be valid in order for the create operation to succeed. The following list shows the combinations that will succeed and those that will fail: * A passphrase only (fail) * A peer IP address (fail) * A passphrase with an expiration time > 7 days into the future (fail) * A peer IP address and a passphrase (OK) * generate_passphrase=true (OK) * Any proposed encryption protocol (OK) * An IPspace name or UUID (OK) * A passphrase, peer IP address, and any proposed encryption protocol (OK) * A non empty list of initial allowed SVM peer names or UUIDs. (OK)

    ### Learn more

    - `DOC /cluster/peers`

    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 ClusterPeerSchema (*, 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 ClusterPeer object

  ### Ancestors

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

  ### Class variables

  `authentication GET POST PATCH`

    The authentication field of the cluster_peer.

  `encryption GET POST PATCH`

    The encryption field of the cluster_peer.

  `initial_allowed_svms GET POST PATCH`

    The local SVMs allowed to peer with the peer cluster's SVMs. This list can be modified until the remote cluster accepts this cluster peering relationship.

  `ipspace GET POST PATCH`

    The ipspace field of the cluster_peer.

  `links GET POST PATCH`

    The links field of the cluster_peer.

  `local_network POST`

    The local_network field of the cluster_peer.

  `name GET POST PATCH`

    Optional name for the cluster peer relationship. By default, it is the name of the remote cluster.

    Example: cluster2

  `peer_applications GET POST PATCH`

    Peering applications against which allowed SVMs are configured.

    Example: ["snapmirror","flexcache"]

  `remote GET POST PATCH`

    The remote field of the cluster_peer.

  `status GET POST PATCH`

    The status field of the cluster_peer.

  `uuid GET`

    UUID of the cluster peer relationship. For anonymous cluster peer offers, the UUID will change when the remote cluster accepts the relationship.

    Example: 1cd8a442-86d1-11e0-ae1c-123478563412

  `version GET`

    The version field of the cluster_peer.