# Module `netapp_ontap.resources.autosupport`

Copyright © 2021 NetApp Inc. All rights reserved.

## Overview

AutoSupport is the NetApp call home mechanism. AutoSupport sends configuration details, status details, and error reporting details to NetApp.

This endpoint supports both GET and PATCH calls. GET is used to retrieve AutoSupport configuration details for the cluster and PATCH is used to modify the AutoSupport configuration of the cluster. You can also use GET calls to check AutoSupport connectivity.

## Examples

### Configuring 'to' addresses

The following example configures AutoSupport to send emails to 'to' addresses.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Autosupport

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Autosupport()
        resource.to = ["abc@netapp.com", "xyz@netapp.com"]
        resource.patch()

### Configuring 'SMTP' transport

The following example configures AutoSupport to use 'SMTP' transport. The default transport is 'HTTPS'.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Autosupport

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Autosupport()
        resource.transport = "smtp"
        resource.patch()

### Retrieving the AutoSupport configuration

The following example retrieves AutoSupport configuration for the cluster.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Autosupport

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

Try it out

    Autosupport(
        {
            "enabled": True,
            "transport": "smtp",
            "from": "Postmaster",
            "contact_support": True,
            "proxy_url": "",
            "mail_hosts": ["mailhost"],
            "is_minimal": False,
            "to": ["abc@netapp.com", "xyz@netapp.com"],
        }
    )

### Retrieving AutoSupport connectivity issues

The following example retrieves AutoSupport connectivity issues for the cluster. The `fields=issues` parameter must be specified, for the response to return connectivity issues. The `corrective_action` section might contain commands which needs to be executed on the ONTAP CLI.

Note that the connectivity check can take up to 10 seconds to complete.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Autosupport

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

Try it out

    Autosupport(
        {
            "issues": [
                {
                    "node": {
                        "name": "node3",
                        "uuid": "0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc",
                        "_links": {
                            "self": {
                                "href": "/api/cluster/nodes/0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc"
                            }
                        },
                    },
                    "issue": {
                        "message": "SMTP connectivity check failed for destination: mailhost. Error: Could not resolve host - 'mailhost'",
                        "code": "53149746",
                    },
                    "corrective_action": {
                        "message": "Check the hostname of the SMTP server",
                        "code": "53149746",
                    },
                },
                {
                    "node": {
                        "name": "node3",
                        "uuid": "0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc",
                        "_links": {
                            "self": {
                                "href": "/api/cluster/nodes/0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc"
                            }
                        },
                    },
                    "issue": {
                        "message": 'AutoSupport OnDemand is disabled when "-transport" is not set to "https".',
                        "code": "53149740",
                    },
                    "corrective_action": {
                        "message": 'Run "system node autosupport modify -transport https -node <node name>" to set "-transport" to "https".',
                        "code": "53149740",
                    },
                },
            ]
        }
    )

### Retrieving AutoSupport configuration and connectivity issues

The following example retrieves AutoSupport configuration and connectivity issues on the cluster. Use `fields=*,issues` parameter to return both configuration and connectivity issues.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Autosupport

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

Try it out

    Autosupport(
        {
            "enabled": True,
            "issues": [
                {
                    "node": {
                        "name": "node3",
                        "uuid": "0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc",
                        "_links": {
                            "self": {
                                "href": "/api/cluster/nodes/0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc"
                            }
                        },
                    },
                    "issue": {
                        "message": "SMTP connectivity check failed for destination: mailhost. Error: Could not resolve host - 'mailhost'",
                        "code": "53149746",
                    },
                    "corrective_action": {
                        "message": "Check the hostname of the SMTP server",
                        "code": "53149746",
                    },
                },
                {
                    "node": {
                        "name": "node3",
                        "uuid": "0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc",
                        "_links": {
                            "self": {
                                "href": "/api/cluster/nodes/0ecfd0a6-f1b3-11e8-9d9f-005056bbaadc"
                            }
                        },
                    },
                    "issue": {
                        "message": 'AutoSupport OnDemand is disabled when "-transport" is not set to "https".',
                        "code": "53149740",
                    },
                    "corrective_action": {
                        "message": 'Run "system node autosupport modify -transport https -node <node name>" to set "-transport" to "https".',
                        "code": "53149740",
                    },
                },
            ],
            "transport": "smtp",
            "from": "Postmaster",
            "contact_support": True,
            "proxy_url": "",
            "mail_hosts": ["mailhost"],
            "is_minimal": False,
            "to": ["abc@netapp.com", "xyz@netapp.com"],
        }
    )

## Classes

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

  Allows interaction with Autosupport 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

  ### Methods

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

    Retrieves the AutoSupport configuration of the cluster and if requested, returns connectivity issues with the AutoSupport configuration.

    Important note: * The issues field consists of a list of objects containing details of the node that has a connectivity issue, the issue description, and corrective action you can take to address the issue. When not empty, this indicates a connection issue to the HTTP/S, SMTP, or AutoSupport On Demand server.

    ### Expensive properties

    There is an added cost to retrieving values for these properties. They are not included by default in GET results and must be explicitly requested using the `fields` query parameter. See `Requesting specific fields` to learn more. * `issues`

    ### Related ONTAP commands

    - `system node autosupport show -instance`
    - `system node autosupport check show-details`

    ### Learn more

    - `DOC /support/autosupport`

    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 the AutoSupport configuration for the entire cluster.

    ### Related ONTAP commands

    - `system node autosupport modify`

    ### Learn more

    - `DOC /support/autosupport`

    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

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
`class AutosupportSchema (*, 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 Autosupport object

  ### Ancestors

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

  ### Class variables

  `contact_support GET POST PATCH`

    Specifies whether to send the AutoSupport messages to vendor support.

    Example: true

  `enabled GET POST PATCH`

    Specifies whether the AutoSupport daemon is enabled. When this setting is disabled, delivery of all AutoSupport messages is turned off.

    Example: true

  `from_ GET POST PATCH`

    The e-mail address from which the AutoSupport messages are sent. To generate node-specific 'from' addresses, enable '-node-specific-from' parameter via ONTAP CLI.

    Example: postmaster@example.com

  `is_minimal GET POST PATCH`

    Specifies whether the system information is collected in compliant form, to remove private data or in complete form, to enhance diagnostics.

    Example: true

  `issues GET`

    A list of nodes in the cluster with connectivity issues to HTTP/SMTP/AOD AutoSupport destinations along with the corresponding error descriptions and corrective actions.

  `mail_hosts GET POST PATCH`

    The names of the mail servers used to deliver AutoSupport messages via SMTP.

    Example: ["mailhost1.example.com","mailhost2.example.com"]

  `partner_addresses GET POST PATCH`

    The list of partner addresses.

    Example: ["user1@partner.com","user2@partner.com"]

  `proxy_url GET POST PATCH`

    Proxy server for AutoSupport message delivery via HTTP/S. Optionally specify a username/password for authentication with the proxy server.

    Example: https://proxy.company.com

  `to GET POST PATCH`

    The e-mail addresses to which the AutoSupport messages are sent.

    Example: ["user1@example.com","user2@example.com"]

  `transport GET POST PATCH`

    The name of the transport protocol used to deliver AutoSupport messages.

    Valid choices:

    - smtp
    - http
    - https