# Module `netapp_ontap.resources.fc_port`

Copyright © 2020 NetApp Inc. All rights reserved.

## Overview

Fibre Channel (FC) ports are the physical ports of FC adapters on ONTAP cluster nodes that can be connected to FC networks to provide FC network connectivity. An FC port defines the location of an FC interface within the ONTAP cluster.
The Fibre Channel port REST API allows you to discover FC ports, obtain status information for FC ports, and configure FC port properties. POST and DELETE requests are not supported. You must physically add and remove FC adapters to ONTAP nodes to create and remove ports from the ONTAP cluster.

## Performance monitoring

Performance of an FC port can be monitored by observing the `metric.*` and `statistics.*` properties. These properties show the performance of an FC port in terms of IOPS, latency, and throughput. The `metric.*` properties denote an average, whereas `statistics.*` properties denote a real-time monotonically increasing value aggregated across all nodes.

## Examples

### Retrieving all FC ports

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcPort

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

Try it out

    [
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b20f8-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b20f8-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0a",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b23f7-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b23f7-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0b",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b25ba-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b25ba-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0c",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b2748-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b2748-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0d",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b28c2-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b28c2-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0e",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b2a7b-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b2a7b-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "0f",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b2e2b-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b2e2b-b047-11e8-9af3-005056bb838e"
                    }
                },
                "name": "1b",
            }
        ),
    ]

### Retrieving all FC ports with state online

The `state` query parameter is used to perform the query.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcPort

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

Try it out

    [
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b20f8-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b20f8-b047-11e8-9af3-005056bb838e"
                    }
                },
                "state": "online",
                "name": "0a",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b23f7-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b23f7-b047-11e8-9af3-005056bb838e"
                    }
                },
                "state": "online",
                "name": "0b",
            }
        ),
        FcPort(
            {
                "node": {
                    "uuid": "3c768e01-1abc-4b3b-b7c0-629ceb62a497",
                    "name": "node1",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/3c768e01-1abc-4b3b-b7c0-629ceb62a497"
                        }
                    },
                },
                "uuid": "931b25ba-b047-11e8-9af3-005056bb838e",
                "_links": {
                    "self": {
                        "href": "/api/network/fc/ports/931b25ba-b047-11e8-9af3-005056bb838e"
                    }
                },
                "state": "online",
                "name": "0c",
            }
        ),
    ]

### Retrieving an FC port

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcPort

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FcPort(uuid="931b20f8-b047-11e8-9af3-005056bb838e")
        resource.get()
        print(resource)

Try it out

    FcPort(
        {
            "wwnn": "50:0a:09:80:bb:83:8e:00",
            "statistics": {
                "status": "ok",
                "iops_raw": {"write": 0, "total": 3, "other": 3, "read": 0},
                "throughput_raw": {"total": 0, "write": 0, "read": 0},
                "timestamp": "2019-04-09T05:50:42+00:00",
                "latency_raw": {"write": 0, "total": 38298, "other": 38298, "read": 0},
            },
            "node": {
                "uuid": "5a534a72-b047-11e8-9af3-005056bb838e",
                "name": "node1",
                "_links": {
                    "self": {
                        "href": "/api/cluster/nodes/5a534a72-b047-11e8-9af3-005056bb838e"
                    }
                },
            },
            "uuid": "931b20f8-b047-11e8-9af3-005056bb838e",
            "enabled": True,
            "_links": {
                "self": {
                    "href": "/api/network/fc/ports/931b20f8-b047-11e8-9af3-005056bb838e"
                }
            },
            "state": "online",
            "name": "0a",
            "wwpn": "50:0a:09:82:bb:83:8e:00",
            "supported_protocols": ["fcp"],
            "fabric": {
                "connected": True,
                "switch_port": "ssan-g620-03:1",
                "connected_speed": 8,
                "name": "55:0e:b1:a0:20:40:80:00",
                "port_address": "52100",
            },
            "transceiver": {
                "part_number": "1000",
                "manufacturer": "ACME",
                "form_factor": "SFP",
                "capabilities": [4, 8],
            },
            "metric": {
                "duration": "PT15S",
                "latency": {"write": 0, "total": 0, "other": 0, "read": 0},
                "status": "ok",
                "throughput": {"total": 0, "write": 0, "read": 0},
                "iops": {"write": 0, "total": 0, "other": 0, "read": 0},
                "timestamp": "2019-04-09T05:50:15+00:00",
            },
            "physical_protocol": "fibre_channel",
            "description": "Fibre Channel Target Adapter 0a (ACME Fibre Channel Adapter, rev. 1.0.0, 8G)",
            "speed": {"configured": "auto", "maximum": "8"},
        }
    )

### Disabling an FC port

If an active FC interface exists on an FC port, the port cannot be disabled.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FcPort

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FcPort(uuid="931b20f8-b047-11e8-9af3-005056bb838e")
        resource.enabled = False
        resource.patch()

## Classes

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

  A Fibre Channel (FC) port is the physical port of an FC adapter on an ONTAP cluster node that can be connected to an FC network to provide FC network connectivity. An FC port defines the location of an FC interface within the ONTAP cluster.

  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 FC ports.

    ### 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. * `fabric.name` * `statistics.*` * `metric.*`

    ### Related ONTAP commands

    - `network fcp adapter show`

    ### Learn more

    - `DOC /network/fc/ports`

    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 find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves FC ports.

    ### 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. * `fabric.name` * `statistics.*` * `metric.*`

    ### Related ONTAP commands

    - `network fcp adapter show`

    ### Learn more

    - `DOC /network/fc/ports`

    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 FC ports.

    ### 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. * `fabric.name` * `statistics.*` * `metric.*`

    ### Related ONTAP commands

    - `network fcp adapter show`

    ### Learn more

    - `DOC /network/fc/ports`

    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 an FC port.

    ### Related ONTAP commands

    - `network fcp adapter modify`

    ### Learn more

    - `DOC /network/fc/ports`

    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 get(self, **kwargs) -> NetAppResponse`

    Retrieves an FC port.

    ### 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. * `fabric.name` * `statistics.*` * `metric.*`

    ### Related ONTAP commands

    - `network fcp adapter show`

    ### Learn more

    - `DOC /network/fc/ports`

    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 an FC port.

    ### Related ONTAP commands

    - `network fcp adapter modify`

    ### Learn more

    - `DOC /network/fc/ports`

    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 FcPortSchema (*, 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 FcPort object

  ### Ancestors

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

  ### Class variables

  `description GET`

    A description of the FC port.

    Example: Fibre Channel Target Adapter 0a (ACME Fibre Channel Adapter, rev. 1.0.0, 8G)

  `enabled GET POST PATCH`

    The administrative state of the FC port. If this property is set to false, all FC connectivity to FC interfaces are blocked. Optional in PATCH.

  `fabric GET POST PATCH`

    The fabric field of the fc_port.

  `links GET`

    The links field of the fc_port.

  `metric GET`

    The metric field of the fc_port.

  `name GET`

    The FC port name.

    Example: 0a

  `node GET POST PATCH`

    The node field of the fc_port.

  `physical_protocol GET`

    The physical network protocol of the FC port.

    Valid choices:

    - fibre_channel
    - ethernet
  `speed GET POST PATCH`

    The speed field of the fc_port.

  `state GET`

    The operational state of the FC port. - startup - The port is booting up. - link_not_connected - The port has finished initialization, but a link with the fabric is not established. - online - The port is initialized and a link with the fabric has been established. - link_disconnected - The link was present at one point on this port but is currently not established. - offlined_by_user - The port is administratively disabled. - offlined_by_system - The port is set to offline by the system. This happens when the port encounters too many errors. - node_offline - The state information for the port cannot be retrieved. The node is offline or inaccessible.

    Valid choices:

    - startup
    - link_not_connected
    - online
    - link_disconnected
    - offlined_by_user
    - offlined_by_system
    - node_offline
    - unknown
  `statistics GET`

    The statistics field of the fc_port.

  `supported_protocols GET`

    The network protocols supported by the FC port.

  `transceiver GET POST PATCH`

    The transceiver field of the fc_port.

  `uuid GET`

    The unique identifier of the FC port.

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

  `wwnn GET`

    The base world wide node name (WWNN) for the FC port.

    Example: 20:00:00:50:56:b4:13:a8

  `wwpn GET`

    The base world wide port name (WWPN) for the FC port.

    Example: 20:00:00:50:56:b4:13:a8