# Module `netapp_ontap.resources.igroup`

Copyright © 2021 NetApp Inc. All rights reserved.

## Overview

An initiator group (igroup) is a collection of Fibre Channel (FC) world wide port names (WWPNs), and/or iSCSI Qualified Names (IQNs), and/or iSCSI EUIs (Extended Unique Identifiers) that identify host initiators.
Initiator groups are used to control which hosts can access specific LUNs. To grant access to a LUN from one or more hosts, create an initiator group containing the host initiator names, then create a LUN map that associates the initiator group with the LUN.
An initiator group may contain either initiators or other initiator groups, but not both simultaneously. When a parent initiator group is mapped, it inherits all of the initiators of any initiator groups nested below it. If any nested initiator group is modified to contain different initiators, the parent initiator groups inherit the change. A parent can have many nested initiator groups and an initiator group can be nested under multiple parents. Initiators can only be added or removed from the initiator group that directly contains them. The maximum supported depth of nesting is three layers.
Best practice when using nested initiator groups is to match host hierarchies. A single initiator group should correspond to a single host. If a LUN needs to be mapped to multiple hosts, the initiator groups representing those hosts should be aggregated into a parent initiator group and the LUN should be mapped to that initiator group. For multi-ported hosts, initiators have a comment property where the port corresponding to the initiator can be documented.
The initiator group REST API allows you to create, update, delete, and discover initiator groups, and to add and remove initiators that can access the target and associated LUNs.
An initiator can appear in multiple initiator groups. An initiator group can be mapped to multiple LUNs. A specific initiator can be mapped to a specific LUN only once. With the introduction of nestable initiator groups, best practice is to use the hierarchy such that an initiator is only a direct member of a single initiator group, and that initiator group can then be referenced by other initiator groups. This avoid needing to update multiple initiator groups when initiators change.
All initiators or nested initiator groups in an initiator group must be from the same operating system. The initiator group's operating system is specified when the initiator group is created.
When an initiator group is created, the `protocol` property is used to restrict member initiators to Fibre Channel (fcp), iSCSI (iscsi), or both (mixed). Initiator groups within a nested hierarchy may not have conflicting protocols.
Zero or more initiators or nested initiator groups can be supplied when the initiator group is created. After creation, initiators can be added or removed from the initiator group using the `/protocols/san/igroups/{igroup.uuid}/initiators` endpoint. Initiator groups containing other initiator groups report the aggregated list of initiators from all nested initiator groups, but modifications of the initiator list must be performed on the initiator group that directly contains the initiators. See `POST /protocols/san/igroups/{igroup.uuid}/initiators` and `DELETE /protocols/san/igroups/{igroup.uuid}/initiators/{name}` for more details.
An FC WWPN consists of 16 hexadecimal digits grouped as 8 pairs separated by colons. The format for an iSCSI IQN is iqn.yyyy-mm.reverse_domain_name:any. The iSCSI EUI format consists of the eui. prefix followed by 16 hexadecimal characters.

## Examples

### Creating an initiator group with no initiators

The example initiator group used here is for Linux iSCSI initiators only. Note that the `return_records` query parameter is used to obtain the newly created initiator group in the response.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup()
        resource.svm.name = "svm1"
        resource.name = "igroup1"
        resource.os_type = "linux"
        resource.protocol = "iscsi"
        resource.post(hydrate=True)
        print(resource)

Try it out

    Igroup(
        {
            "os_type": "linux",
            "svm": {
                "name": "svm1",
                "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                "_links": {
                    "self": {"href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"}
                },
            },
            "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
            "_links": {
                "self": {
                    "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                }
            },
            "protocol": "iscsi",
            "name": "igroup1",
        }
    )

### Creating an initiator group with initiators

The example initiator group used here is for Windows. FC Protocol and iSCSI initiators are allowed. Note that the `return_records` query parameter is used to obtain the newly created initiator group in the response.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup()
        resource.svm.name = "svm1"
        resource.name = "igroup2"
        resource.os_type = "windows"
        resource.protocol = "mixed"
        resource.initiators = [
            {"name": "20:01:00:50:56:bb:70:72"},
            {"name": "iqn.1991-05.com.ms:host1"},
        ]
        resource.post(hydrate=True)
        print(resource)

Try it out

    Igroup(
        {
            "os_type": "windows",
            "svm": {
                "name": "svm1",
                "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                "_links": {
                    "self": {"href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"}
                },
            },
            "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
            "_links": {
                "self": {
                    "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                }
            },
            "initiators": [
                {
                    "_links": {
                        "self": {
                            "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/20:01:00:50:56:bb:70:72"
                        }
                    },
                    "name": "20:01:00:50:56:bb:70:72",
                },
                {
                    "_links": {
                        "self": {
                            "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/iqn.1991-05.com.ms:host1"
                        }
                    },
                    "name": "iqn.1991-05.com.ms:host1",
                },
            ],
            "protocol": "mixed",
            "name": "igroup2",
        }
    )

### Creating an initiator group with nested initiator groups

The example initiator group used here is for Windows. FC Protocol and iSCSI initiators are allowed. Note that the `return_records` query parameter is used to obtain the newly created initiator group in the response. The new initiator group is create so as to contain the initiator group created in the previous example. The initiators list reports all initiators nested below this initiator group, and note that the href link for the initiators refers to the initiator group that directly owns the initiator, not this initiator group.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup()
        resource.svm.name = "svm1"
        resource.name = "igroup3"
        resource.os_type = "windows"
        resource.protocol = "mixed"
        resource.igroups = [{"name": "igroup2"}]
        resource.post(hydrate=True)
        print(resource)

Try it out

    Igroup(
        {
            "os_type": "windows",
            "svm": {
                "name": "svm1",
                "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                "_links": {
                    "self": {"href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"}
                },
            },
            "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7073",
            "igroups": [
                {
                    "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                        }
                    },
                    "name": "igroup2",
                }
            ],
            "_links": {
                "self": {
                    "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7073"
                }
            },
            "initiators": [
                {
                    "_links": {
                        "self": {
                            "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/20:01:00:50:56:bb:70:72"
                        }
                    },
                    "igroup": {
                        "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                            }
                        },
                        "name": "igroup2",
                    },
                    "name": "20:01:00:50:56:bb:70:72",
                },
                {
                    "_links": {
                        "self": {
                            "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/iqn.1991-05.com.ms:host1"
                        }
                    },
                    "igroup": {
                        "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                            }
                        },
                        "name": "igroup2",
                    },
                    "name": "iqn.1991-05.com.ms:host1",
                },
            ],
            "protocol": "mixed",
            "name": "igroup3",
        }
    )

### Retrieving all initiator groups

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

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

Try it out

    [
        Igroup(
            {
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                    }
                },
                "name": "igroup1",
            }
        ),
        Igroup(
            {
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                    }
                },
                "name": "igroup2",
            }
        ),
        Igroup(
            {
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7073",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7073"
                    }
                },
                "name": "igroup3",
            }
        ),
    ]

### Retrieving all properties of all initiator groups

The `fields` query parameter is used to request all initiator group properties. Note that the nested and parent initiator groups are considered expensive properties and will only be returned if explicitly requested.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(Igroup.get_collection(fields="*,igroups,parent_igroups")))

Try it out

    [
        Igroup(
            {
                "os_type": "linux",
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                    }
                },
                "protocol": "iscsi",
                "name": "igroup1",
            }
        ),
        Igroup(
            {
                "os_type": "windows",
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                    }
                },
                "parent_igroups": [
                    {
                        "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7073",
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7073"
                            }
                        },
                        "name": "igroup3",
                    }
                ],
                "initiators": [
                    {
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/20:01:00:50:56:bb:70:72"
                            }
                        },
                        "name": "20:01:00:50:56:bb:70:72",
                    },
                    {
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/iqn.1991-05.com.ms:host1"
                            }
                        },
                        "name": "iqn.1991-05.com.ms:host1",
                    },
                ],
                "protocol": "mixed",
                "name": "igroup2",
            }
        ),
        Igroup(
            {
                "os_type": "windows",
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7073",
                "igroups": [
                    {
                        "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                            }
                        },
                        "name": "igroup2",
                    }
                ],
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7073"
                    }
                },
                "initiators": [
                    {
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/20:01:00:50:56:bb:70:72"
                            }
                        },
                        "igroup": {
                            "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                            "_links": {
                                "self": {
                                    "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                                }
                            },
                            "name": "igroup2",
                        },
                        "name": "20:01:00:50:56:bb:70:72",
                    },
                    {
                        "_links": {
                            "self": {
                                "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072/initiators/iqn.1991-05.com.ms:host1"
                            }
                        },
                        "igroup": {
                            "uuid": "abf9c39d-ab9f-11e8-b8a3-005056bb7072",
                            "_links": {
                                "self": {
                                    "href": "/api/protocols/san/igroups/abf9c39d-ab9f-11e8-b8a3-005056bb7072"
                                }
                            },
                            "name": "igroup2",
                        },
                        "name": "iqn.1991-05.com.ms:host1",
                    },
                ],
                "protocol": "mixed",
                "name": "igroup3",
            }
        ),
    ]

### Retrieving all initiator groups for Linux

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

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

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

Try it out

    [
        Igroup(
            {
                "os_type": "linux",
                "svm": {
                    "name": "svm1",
                    "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"
                        }
                    },
                },
                "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
                "_links": {
                    "self": {
                        "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                    }
                },
                "name": "igroup1",
            }
        )
    ]

### Retrieving a specific initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.get()
        print(resource)

Try it out

    Igroup(
        {
            "os_type": "linux",
            "svm": {
                "name": "svm1",
                "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                "_links": {
                    "self": {"href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"}
                },
            },
            "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
            "_links": {
                "self": {
                    "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                }
            },
            "protocol": "iscsi",
            "name": "igroup1",
        }
    )

### Retrieving LUNs mapped to a specific initiator group

The `fields` parameter is used to specify the desired properties.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.get(fields="lun_maps")
        print(resource)

Try it out

    Igroup(
        {
            "svm": {
                "name": "svm1",
                "uuid": "02b0dfff-aa28-11e8-a653-005056bb7072",
                "_links": {
                    "self": {"href": "/api/svm/svms/02b0dfff-aa28-11e8-a653-005056bb7072"}
                },
            },
            "uuid": "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
            "lun_maps": [
                {
                    "lun": {
                        "node": {
                            "name": "node1",
                            "uuid": "f17182af-223f-4d51-8197-2cb2146d5c4c",
                            "_links": {
                                "self": {
                                    "href": "/api/cluster/nodes/f17182af-223f-4d51-8197-2cb2146d5c4c"
                                }
                            },
                        },
                        "_links": {
                            "self": {
                                "href": "/api/storage/luns/4b33ba57-c4e0-4dbb-bc47-214800d18a71"
                            }
                        },
                        "name": "/vol/vol1/lun1",
                        "uuid": "4b33ba57-c4e0-4dbb-bc47-214800d18a71",
                    },
                    "logical_unit_number": 0,
                }
            ],
            "_links": {
                "self": {
                    "href": "/api/protocols/san/igroups/8f249e7d-ab9f-11e8-b8a3-005056bb7072"
                }
            },
            "name": "igroup1",
        }
    )

### Renaming an initiator group

Note that renaming an initiator group must be done in a PATCH request separate from any other modifications.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.name = "igroup1_newName"
        resource.patch()

### Changing the operating system type of an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.os_type = "aix"
        resource.patch()

### Adding an initiator to an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupInitiator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupInitiator("8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.name = "iqn.1991-05.com.ms:host2"
        resource.post(hydrate=True)
        print(resource)

### Adding multiple initiators to an initiator group

Note the use of the `records` property to add multiple initiators to the initiator group in a single API call.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupInitiator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupInitiator("8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.records = [
            {"name": "iqn.1991-05.com.ms:host3"},
            {"name": "iqn.1991-05.com.ms:host4"},
        ]
        resource.post(hydrate=True)
        print(resource)

### Removing an initiator from an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupInitiator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupInitiator(
            "8f249e7d-ab9f-11e8-b8a3-005056bb7072", name="iqn.1991-05.com.ms:host3"
        )
        resource.delete()

### Removing an initiator from a mapped initiator group

Normally, removing an initiator from an initiator group that is mapped to a LUN is not allowed. The removal can be forced using the `allow_delete_while_mapped` query parameter.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupInitiator

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupInitiator(
            "8f249e7d-ab9f-11e8-b8a3-005056bb7072", name="iqn.1991-05.com.ms:host4"
        )
        resource.delete(allow_delete_while_mapped=True)

### Adding a nested initiator group to an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupNested

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupNested("8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.name = "host2_igroup"
        resource.post(hydrate=True)
        print(resource)

### Adding multiple nested initiator groups to an initiator group

Note the use of the `records` property to add multiple nested initiator groups to the initiator group in a single API call.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupNested

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupNested("8f249e7d-ab9f-11e8-b8a3-005056bb7072")
        resource.records = [
            {"name": "host3_igroup"},
            {"uuid": "c439efc8-0a70-11eb-adc1-0242ac120002"},
        ]
        resource.post(hydrate=True)
        print(resource)

### Removing a nested initiator group from an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupNested

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupNested(
            "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
            uuid="c439efc8-0a70-11eb-adc1-0242ac120002",
        )
        resource.delete()

### Removing a nested initiator group from a mapped initiator group

Normally, removing a nested initiator group from an initiator group that is mapped to a LUN is not allowed. The removal can be forced using the `allow_delete_while_mapped` query parameter.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import IgroupNested

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = IgroupNested(
            "8f249e7d-ab9f-11e8-b8a3-005056bb7072",
            uuid="c439efc8-0a70-11eb-adc1-0242ac120002",
        )
        resource.delete(allow_delete_while_mapped=True)

### Deleting an initiator group

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="abf9c39d-ab9f-11e8-b8a3-005056bb7072")
        resource.delete()

### Deleting a mapped initiator group

Normally, deleting an initiator group that is mapped to a LUN is not allowed. The deletion can be forced using the `allow_delete_while_mapped` query parameter.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import Igroup

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = Igroup(uuid="abf9c39d-ab9f-11e8-b8a3-005056bb7072")
        resource.delete(allow_delete_while_mapped=True)

## Classes

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

  An initiator group (igroup) is a collection of Fibre Channel (FC) world wide port names (WWPNs), and/or iSCSI Qualified Names (IQNs), and/or iSCSI EUIs (Extended Unique Identifiers) that identify host initiators.
  Initiator groups are used to control which hosts can access specific LUNs. To grant access to a LUN from one or more hosts, create an initiator group containing the host initiator names, then create a LUN map that associates the initiator group with the LUN.
  An initiator group may contain either initiators or other initiator groups, but not both simultaneously. When a parent initiator group is mapped, it inherits all of the initiators of any initiator groups nested below it. If any nested initiator group is modified to contain different initiators, the parent initiator groups inherit the change. A parent can have many nested initiator groups and an initiator group can be nested under multiple parents. Initiators can only be added or removed from the initiator group that directly contains them. The maximum supported depth of nesting is three layers.
  Best practice when using nested initiator groups is to match host hierarchies. A single initiator group should correspond to a single host. If a LUN needs to be mapped to multiple hosts, the initiator groups representing those hosts should be aggregated into a parent initiator group and the LUN should be mapped to that initiator group. For multi-ported hosts, initiators have a comment property where the port corresponding to the initiator can be documented.
  An initiator can appear in multiple initiator groups. An initiator group can be mapped to multiple LUNs. A specific initiator can be mapped to a specific LUN only once. With the introduction of nestable initiator groups, best practice is to use the hierarchy such that an initiator is only a direct member of a single initiator group, and that initiator group can then be referenced by other initiator groups.
  All initiators or nested initiator groups in an initiator group must be from the same operating system. The initiator group's operating system is specified when the initiator group is created.
  When an initiator group is created, the `protocol` property is used to restrict member initiators to Fibre Channel (fcp), iSCSI (iscsi), or both (mixed). Initiator groups within a nested hierarchy may not have conflicting protocols.
  Zero or more initiators or nested initiator groups can be supplied when the initiator group is created. After creation, initiators can be added or removed from the initiator group using the `/protocols/san/igroups/{igroup.uuid}/initiators` endpoint. Initiator groups containing other initiator groups report the aggregated list of initiators from all nested initiator groups, but modifications of the initiator list must be performed on the initiator group that directly contains the initiators. See `POST /protocols/san/igroups/{igroup.uuid}/initiators` and `DELETE /protocols/san/igroups/{igroup.uuid}/initiators/{name}` for more details.

  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 initiator groups.

    ### 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. * `igroups.*` * `lun_maps.*` * `parent_igroups.*`

    ### Related ONTAP commands

    - `lun igroup show`
    - `lun mapping show`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 an initiator group.

    ### Related ONTAP commands

    - `lun igroup delete`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 deleted.

    ## 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 initiator groups.

    ### 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. * `igroups.*` * `lun_maps.*` * `parent_igroups.*`

    ### Related ONTAP commands

    - `lun igroup show`
    - `lun mapping show`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 initiator groups.

    ### 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. * `igroups.*` * `lun_maps.*` * `parent_igroups.*`

    ### Related ONTAP commands

    - `lun igroup show`
    - `lun mapping show`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 initiator group.

    ### Related ONTAP commands

    - `lun igroup modify`
    - `lun igroup rename`
    - `lun igroup bind`
    - `lun igroup unbind`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 an initiator group.

    ### Related ONTAP commands

    - `lun igroup delete`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 an initiator group.

    ### 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. * `igroups.*` * `lun_maps.*` * `parent_igroups.*`

    ### Related ONTAP commands

    - `lun igroup show`
    - `lun mapping show`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 initiator group.

    ### Related ONTAP commands

    - `lun igroup modify`
    - `lun igroup rename`
    - `lun igroup bind`
    - `lun igroup unbind`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 an initiator group.

    ### Required properties

    - `svm.uuid` or `svm.name` - Existing SVM in which to create the initiator group.
    - `name` - Name of the initiator group.
    - `os_type` - Operating system of the initiator group's initiators.

    ### Recommended optional properties

    - `initiators.name` - Name(s) of initiator group's initiators. This property can be used to create the initiator group and populate it with initiators in a single request.

    ### Default property values

    If not specified in POST, the following default property values are assigned. * `protocol` - mixed - Data protocol of the initiator group's initiators.

    ### Related ONTAP commands

    - `lun igroup create`

    ### Learn more

    - `DOC /protocols/san/igroups`

    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 IgroupSchema (*, 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 Igroup object

  ### Ancestors

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

  ### Class variables

  `comment GET POST PATCH`

    A comment available for use by the administrator. Valid in POST and PATCH.

  `delete_on_unmap GET POST PATCH`

    An option that causes the initiator group to be deleted when the last LUN map associated with it is deleted. Optional in POST and PATCH. This property defaults to false when the initiator group is created.

  `igroups GET POST`

    The initiator groups that are members of the group. Optional in POST.
    This property is mutually exclusive with the initiators property during POST.
    This array contains only the direct children of the initiator group. If the member initiator groups have further nested initiator groups, those are reported in the `igroups` property of the child initiator group.
    Zero or more nested initiator groups can be supplied when the initiator group is created. The initiator group will act as if it contains the aggregatation of all initiators in any nested initiator groups.
    After creation, nested initiator groups can be added or removed from the initiator group using the `/protocols/san/igroups/{igroup.uuid}/igroups` endpoint. See `POST /protocols/san/igroups/{igroup.uuid}/igroups` and `DELETE /protocols/san/igroups/{igroup.uuid}/igroups/{uuid}` for more details.

  `initiators GET POST`

    The initiators that are members of the group or any group nested below this group. Optional in POST.
    This property is mutually exclusive with the igroups property during POST.
    During GET, this array contains initiators that are members of this group or any nested initiator groups below this group. When initiators of nested groups are returned, they include links to the initiator group that directly contains the initiator.
    Zero or more initiators can be supplied when the initiator group is created. After creation, initiators can be added or removed from the initiator group using the `/protocols/san/igroups/{igroup.uuid}/initiators` endpoint. See `POST /protocols/san/igroups/{igroup.uuid}/initiators` and `DELETE /protocols/san/igroups/{igroup.uuid}/initiators/{name}` for more details.

  `links GET`

    The links field of the igroup.

  `lun_maps GET`

    All LUN maps with which the initiator is associated.
    If the requested igroup is part of a remote, non-local, MetroCluster SVM, the LUN maps are not retrieved.
    There is an added cost to retrieving property values for `lun_maps`. They are not populated for either a collection GET or an instance GET unless explicitly requested using the `fields` query parameter. See `Requesting specific fields` to learn more.

  `name GET POST PATCH`

    The name of the initiator group. Required in POST; optional in PATCH.

    Example: igroup1

  `os_type GET POST PATCH`

    The host operating system of the initiator group. All initiators in the group should be hosts of the same operating system. Required in POST; optional in PATCH.

    Valid choices:

    - aix
    - hpux
    - hyper_v
    - linux
    - netware
    - openvms
    - solaris
    - vmware
    - windows
    - xen
  `parent_igroups GET`

    The initiator groups that contain this initiator group as as member.

  `portset GET POST PATCH`

    The portset field of the igroup.

  `protocol GET POST`

    The protocols supported by the initiator group. This restricts the type of initiators that can be added to the initiator group. Optional in POST; if not supplied, this defaults to mixed.
    The protocol of an initiator group cannot be changed after creation of the group.

    Valid choices:

    - fcp
    - iscsi
    - mixed
  `supports_igroups GET`

    An initiator group may contain either initiators or other initiator groups, but not both simultaneously. This property is true when initiator groups can be added to this initiator group. The `initiators.name` property cannot be used to determine this via a query because it reports initiators inherited from nested igroups.

  `svm GET POST`

    The svm field of the igroup.

  `uuid GET`

    The unique identifier of the initiator group.

    Example: 4ea7a442-86d1-11e0-ae1c-123478563412