Module netapp_ontap.resources.fpolicy

Copyright © 2020 NetApp Inc. All rights reserved.

Overview

FPolicy is an infrastructure component of ONTAP that enables partner applications to connect to ONTAP in order to monitor and set file access permissions. Every time a client accesses a file from a storage system, based on the configuration of FPolicy, the partner application is notified about file access. This enables partners to set restrictions on files that are created or accessed on the storage system. FPolicy also allows you to create file policies that specify file operation permissions according to file type. For example, you can restrict certain file types, such as .jpeg and .mp3 files, from being stored on the storage system. FPolicy can monitor file access from CIFS and NFS clients.
As part of FPolicy configuration, you can specify an FPolicy engine which defines the external FPolicy server, FPolicy events, which defines the protocol and file operations to monitor and the FPolicy policy that acts as a container for the FPolicy engine and FPolicy events. It provides a way for policy management functions, such as policy enabling and disabling.

Examples

Creating an FPolicy configuration

To create an FPolicy for an SVM use the following API. Note that the return_records=true query parameter is used to obtain the newly created entry in the response.

from netapp_ontap import HostConnection
from netapp_ontap.resources import Fpolicy

with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
    resource = Fpolicy()
    resource.engines = [
        {
            "name": "engine1",
            "port": 9876,
            "primary_servers": ["10.132.145.22", "10.140.101.109"],
            "secondary_servers": ["10.132.145.20", "10.132.145.21"],
            "type": "synchronous",
        }
    ]
    resource.events = [
        {
            "file_operations": {"read": True, "write": True},
            "filters": {"monitor_ads": True},
            "name": "event_cifs",
            "protocol": "cifs",
            "volume_monitoring": True,
        }
    ]
    resource.policies = [
        {
            "engine": {"name": "engine1"},
            "events": [{"name": "event_cifs"}],
            "mandatory": True,
            "name": "pol0",
            "priority": 1,
            "scope": {"include_volumes": ["vol1"]},
        }
    ]
    resource.svm.name = "vs1"
    resource.svm.uuid = "b34f5e3d-01d0-11e9-8f63-0050568ea311"
    resource.post(hydrate=True, return_records="tre")
    print(resource)

Fpolicy(
    {
        "engines": [
            {
                "primary_servers": ["10.132.145.22", "10.140.101.109"],
                "secondary_servers": ["10.132.145.20", "10.132.145.21"],
                "type": "synchronous",
                "port": 9876,
                "name": "engine1",
            }
        ],
        "policies": [
            {
                "events": [{"name": "event_cifs"}],
                "priority": 1,
                "mandatory": True,
                "scope": {"include_volumes": ["vol1"]},
                "engine": {"name": "engine1"},
                "name": "pol0",
            }
        ],
        "svm": {"uuid": "b34f5e3d-01d0-11e9-8f63-0050568ea311", "name": "vs1"},
        "events": [
            {
                "file_operations": {"read": True, "write": True},
                "volume_monitoring": True,
                "filters": {"monitor_ads": True},
                "name": "event_cifs",
                "protocol": "cifs",
            }
        ],
    }
)


Retrieving the FPolicy configuration for all the SVMs in the cluster


from netapp_ontap import HostConnection
from netapp_ontap.resources import Fpolicy

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

[
    Fpolicy(
        {
            "engines": [
                {
                    "primary_servers": ["10.132.145.22", "10.140.101.109"],
                    "secondary_servers": ["10.132.145.20", "10.132.145.21"],
                    "type": "synchronous",
                    "port": 9876,
                    "name": "engine1",
                }
            ],
            "policies": [
                {
                    "enabled": True,
                    "events": [{"name": "event_cifs"}],
                    "priority": 1,
                    "mandatory": True,
                    "scope": {"include_volumes": ["vol1"]},
                    "engine": {"name": "engine1"},
                    "name": "pol0",
                }
            ],
            "svm": {"uuid": "b34f5e3d-01d0-11e9-8f63-0050568ea311", "name": "vs1"},
            "events": [
                {
                    "file_operations": {
                        "rename_dir": False,
                        "delete": False,
                        "lookup": False,
                        "link": False,
                        "rename": False,
                        "getattr": False,
                        "read": True,
                        "open": False,
                        "close": False,
                        "create_dir": False,
                        "symlink": False,
                        "delete_dir": False,
                        "write": True,
                        "setattr": False,
                        "create": False,
                    },
                    "volume_monitoring": True,
                    "filters": {
                        "setattr_with_creation_time_change": False,
                        "setattr_with_modify_time_change": False,
                        "offline_bit": False,
                        "setattr_with_mode_change": False,
                        "first_read": False,
                        "setattr_with_sacl_change": False,
                        "setattr_with_dacl_change": False,
                        "first_write": False,
                        "monitor_ads": True,
                        "close_with_read": False,
                        "close_without_modification": False,
                        "open_with_delete_intent": False,
                        "open_with_write_intent": False,
                        "write_with_size_change": False,
                        "exclude_directory": False,
                        "setattr_with_allocation_size_change": False,
                        "setattr_with_access_time_change": False,
                        "setattr_with_size_change": False,
                        "close_with_modification": False,
                        "setattr_with_group_change": False,
                        "setattr_with_owner_change": False,
                    },
                    "name": "event_cifs",
                    "protocol": "cifs",
                }
            ],
        }
    )
]


Retrieving an FPolicy configuration for a particular SVM


from netapp_ontap import HostConnection
from netapp_ontap.resources import Fpolicy

with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
    resource = Fpolicy(**{"svm.uuid": "b34f5e3d-01d0-11e9-8f63-0050568ea311"})
    resource.get(fields="*", return_timeout=15)
    print(resource)

Fpolicy(
    {
        "engines": [
            {
                "primary_servers": ["10.132.145.22", "10.140.101.109"],
                "secondary_servers": ["10.132.145.20", "10.132.145.21"],
                "type": "synchronous",
                "port": 9876,
                "name": "engine1",
            }
        ],
        "policies": [
            {
                "enabled": True,
                "events": [{"name": "event_cifs"}],
                "priority": 1,
                "mandatory": True,
                "scope": {"include_volumes": ["vol1"]},
                "engine": {"name": "engine1"},
                "name": "pol0",
            }
        ],
        "svm": {"uuid": "b34f5e3d-01d0-11e9-8f63-0050568ea311", "name": "vs1"},
        "events": [
            {
                "file_operations": {
                    "rename_dir": False,
                    "delete": False,
                    "lookup": False,
                    "link": False,
                    "rename": False,
                    "getattr": False,
                    "read": True,
                    "open": False,
                    "close": False,
                    "create_dir": False,
                    "symlink": False,
                    "delete_dir": False,
                    "write": True,
                    "setattr": False,
                    "create": False,
                },
                "volume_monitoring": True,
                "filters": {
                    "setattr_with_creation_time_change": False,
                    "setattr_with_modify_time_change": False,
                    "offline_bit": False,
                    "setattr_with_mode_change": False,
                    "first_read": False,
                    "setattr_with_sacl_change": False,
                    "setattr_with_dacl_change": False,
                    "first_write": False,
                    "monitor_ads": True,
                    "close_with_read": False,
                    "close_without_modification": False,
                    "open_with_delete_intent": False,
                    "open_with_write_intent": False,
                    "write_with_size_change": False,
                    "exclude_directory": False,
                    "setattr_with_allocation_size_change": False,
                    "setattr_with_access_time_change": False,
                    "setattr_with_size_change": False,
                    "close_with_modification": False,
                    "setattr_with_group_change": False,
                    "setattr_with_owner_change": False,
                },
                "name": "event_cifs",
                "protocol": "cifs",
            }
        ],
    }
)


Deleting an FPolicy configuration for a particular SVM


from netapp_ontap import HostConnection
from netapp_ontap.resources import Fpolicy

with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
    resource = Fpolicy(**{"svm.uuid": "b34f5e3d-01d0-11e9-8f63-0050568ea311"})
    resource.delete()


Classes

class Fpolicy (*args, **kwargs)

FPolicy is an infrastructure component of ONTAP that enables partner applications connected to your storage systems to monitor and set file access permissions. Every time a client accesses a file from a storage system, based on the configuration of FPolicy, the partner application is notified about file access.

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

Static methods

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

Retrieves an FPolicy configuration.

  • fpolicy show
  • fpolicy policy show
  • fpolicy policy scope show
  • fpolicy policy event show
  • fpolicy policy external-engine show

Learn more


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 the FPolicy configuration for the specified SVM. Before deleting the FPolicy configuration, ensure that all policies belonging to the SVM are disabled.

  • fpolicy delete
  • fpolicy policy scope delete
  • fpolicy policy delete
  • fpolicy policy event delete
  • fpolicy policy external-engine delete

Learn more


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 an FPolicy configuration.

  • fpolicy show
  • fpolicy policy show
  • fpolicy policy scope show
  • fpolicy policy event show
  • fpolicy policy external-engine show

Learn more


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 an FPolicy configuration.

  • fpolicy show
  • fpolicy policy show
  • fpolicy policy scope show
  • fpolicy policy event show
  • fpolicy policy external-engine show

Learn more


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.

Methods

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

Deletes the FPolicy configuration for the specified SVM. Before deleting the FPolicy configuration, ensure that all policies belonging to the SVM are disabled.

  • fpolicy delete
  • fpolicy policy scope delete
  • fpolicy policy delete
  • fpolicy policy event delete
  • fpolicy policy external-engine delete

Learn more


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

async def fpolicy_create(links: dict = None, engines: dict = None, events: dict = None, policies: dict = None, svm: dict = None) -> netapp_ontap.resource_table.ResourceTable

Create an instance of a Fpolicy resource

Args

links
 
engines
 
events
 
policies
 

svm:

async def fpolicy_delete()

Delete an instance of a Fpolicy resource

Args:

def fpolicy_show(fields: typing.List = None) -> netapp_ontap.resource_table.ResourceTable

Fetch a list of Fpolicy resources

Args:

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

Retrieves an FPolicy configuration of an SVM.

  • fpolicy show
  • fpolicy policy show
  • fpolicy policy scope show
  • fpolicy policy event show
  • fpolicy policy external-engine show

Learn more


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 post(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse

Creates an FPolicy configuration.

Required properties

  • svm.uuid or svm.name - Existing SVM in which to create the FPolicy configuration.
  • engines - External server to which the notifications will be sent.
  • events - File operations to monitor.
  • policies - Policy configuration which acts as a container for FPolicy event and FPolicy engine.
  • scope - Scope of the policy. Can be limited to exports, volumes, shares or file extensions.

Default property values

If not specified in POST, the following default property values are assigned: * engines.type - synchronous * policies.engine - native * policies.mandatory - true * events.volume_monitoring - false * events.file_operations.* - false * events.filters.* - false

  • fpolicy policy event create
  • fpolicy policy external-engine create
  • fpolicy policy create
  • fpolicy policy scope create
  • fpolicy enable

Learn more


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

class FpolicySchema (*, 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 Fpolicy object

Ancestors

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

Class variables

engines GET POST

The engines field of the fpolicy.

events GET POST

The events field of the fpolicy.

The links field of the fpolicy.

policies GET POST

The policies field of the fpolicy.

svm GET POST PATCH

The svm field of the fpolicy.