Module netapp_ontap.resources.cifs_share
Copyright © 2022 NetApp Inc. All rights reserved.
Overview
Before any users or applications can access data on the CIFS server over SMB, a CIFS share must be created with sufficient share permissions. CIFS share is a named access point in a volume which is tied to the CIFS server on the SVM. Before creating a CIFS share make sure that the path is valid within the scope of the SVM and that it is reachable. Permissions can be assigned to this newly created share by specifying the 'acls' field. When a CIFS share is created, ONTAP creates a default ACL for this share with 'Full-Control' permissions for an 'Everyone' user.
Examples
Creating a CIFS share
To create a CIFS share for a CIFS server, use the following API. Note the return_records=true query parameter used to obtain the newly created entry in the response.
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = CifsShare()
resource.access_based_enumeration = False
resource.acls = [
{"permission": "no_access", "type": "unix_user", "user_or_group": "root"}
]
resource.change_notify = True
resource.comment = "HR Department Share"
resource.encryption = False
resource.home_directory = False
resource.name = "TEST"
resource.oplocks = True
resource.no_strict_security = True
resource.path = "/"
resource.svm = {"name": "vs1", "uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a"}
resource.unix_symlink = "local"
resource.show_snapshot = True
resource.continuously_available = False
resource.namespace_caching = True
resource.file_umask = "025"
resource.dir_umask = "026"
resource.offline_files = "documents"
resource.vscan_profile = "standard"
resource.force_group_for_create = "root"
resource.post(hydrate=True)
print(resource)
CifsShare(
{
"dir_umask": 26,
"unix_symlink": "local",
"path": "/",
"vscan_profile": "standard",
"oplocks": True,
"continuously_available": False,
"encryption": False,
"no_strict_security": True,
"force_group_for_create": "root",
"namespace_caching": True,
"comment": "HR Department Share",
"file_umask": 25,
"home_directory": False,
"offline_files": "documents",
"acls": [
{"type": "unix_user", "permission": "no_access", "user_or_group": "root"}
],
"access_based_enumeration": False,
"show_snapshot": True,
"svm": {"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a", "name": "vs1"},
"change_notify": True,
"name": "TEST",
}
)
Retrieving CIFS Shares for all SVMs in the cluster
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
print(list(CifsShare.get_collection(fields="*", return_timeout=15)))
[
CifsShare(
{
"unix_symlink": "local",
"path": "/",
"_links": {
"self": {
"href": "/api/protocols/cifs/shares/6d8e8870-8753-11eb-8d86-0050568ea61a/c%24"
}
},
"vscan_profile": "standard",
"oplocks": True,
"volume": {"uuid": "6f4fb33a-8753-11eb-8d86-0050568ea61a", "name": "vol1"},
"continuously_available": False,
"encryption": False,
"namespace_caching": False,
"home_directory": False,
"acls": [
{
"type": "windows",
"permission": "full_control",
"user_or_group": "BUILTIN\\Administrators",
}
],
"access_based_enumeration": False,
"show_snapshot": False,
"svm": {
"_links": {
"self": {
"href": "/api/svm/svms/6d8e8870-8753-11eb-8d86-0050568ea61a"
}
},
"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a",
"name": "vs1",
},
"change_notify": True,
"name": "c$",
}
),
CifsShare(
{
"path": "/",
"_links": {
"self": {
"href": "/api/protocols/cifs/shares/6d8e8870-8753-11eb-8d86-0050568ea61a/ipc%24"
}
},
"vscan_profile": "standard",
"oplocks": False,
"volume": {"uuid": "6f4fb33a-8753-11eb-8d86-0050568ea61a", "name": "vol1"},
"continuously_available": False,
"encryption": False,
"namespace_caching": False,
"home_directory": False,
"access_based_enumeration": False,
"show_snapshot": False,
"svm": {
"_links": {
"self": {
"href": "/api/svm/svms/6d8e8870-8753-11eb-8d86-0050568ea61a"
}
},
"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a",
"name": "vs1",
},
"change_notify": False,
"name": "ipc$",
}
),
CifsShare(
{
"dir_umask": 26,
"unix_symlink": "local",
"path": "/",
"_links": {
"self": {
"href": "/api/protocols/cifs/shares/6d8e8870-8753-11eb-8d86-0050568ea61a/TEST"
}
},
"vscan_profile": "standard",
"oplocks": True,
"volume": {"uuid": "6f4fb33a-8753-11eb-8d86-0050568ea61a", "name": "vol1"},
"continuously_available": False,
"encryption": False,
"no_strict_security": True,
"force_group_for_create": "root",
"namespace_caching": True,
"comment": "HR Department Share",
"file_umask": 25,
"home_directory": False,
"offline_files": "documents",
"acls": [
{
"type": "windows",
"permission": "full_control",
"user_or_group": "Everyone",
},
{
"type": "unix_user",
"permission": "no_access",
"user_or_group": "root",
},
],
"access_based_enumeration": False,
"show_snapshot": True,
"svm": {
"_links": {
"self": {
"href": "/api/svm/svms/6d8e8870-8753-11eb-8d86-0050568ea61a"
}
},
"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a",
"name": "vs1",
},
"change_notify": True,
"name": "TEST",
}
),
]
Retrieving all CIFS Shares for all SVMs in the cluster for which the acls are configured for a "root" user
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
print(
list(
CifsShare.get_collection(
fields="*", return_timeout=15, **{"acls.user_or_group": "root"}
)
)
)
[
CifsShare(
{
"dir_umask": 26,
"unix_symlink": "local",
"path": "/",
"vscan_profile": "standard",
"oplocks": True,
"volume": {"uuid": "6f4fb33a-8753-11eb-8d86-0050568ea61a", "name": "vol1"},
"continuously_available": False,
"encryption": False,
"no_strict_security": True,
"force_group_for_create": "root",
"namespace_caching": True,
"comment": "HR Department Share",
"file_umask": 25,
"home_directory": False,
"offline_files": "documents",
"acls": [
{
"type": "windows",
"permission": "full_control",
"user_or_group": "Everyone",
},
{
"type": "unix_user",
"permission": "no_access",
"user_or_group": "root",
},
],
"access_based_enumeration": False,
"show_snapshot": True,
"svm": {"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a", "name": "vs1"},
"change_notify": True,
"name": "TEST",
}
)
]
Retrieving a specific CIFS share configuration for an SVM
The configuration being returned is identified by the UUID of its SVM and the name of the share.
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = CifsShare(
name="TEST", **{"svm.uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a"}
)
resource.get()
print(resource)
CifsShare(
{
"dir_umask": 26,
"unix_symlink": "local",
"path": "/",
"vscan_profile": "standard",
"oplocks": True,
"volume": {"uuid": "6f4fb33a-8753-11eb-8d86-0050568ea61a", "name": "vol1"},
"continuously_available": False,
"encryption": False,
"no_strict_security": True,
"force_group_for_create": "root",
"namespace_caching": True,
"comment": "HR Department Share",
"file_umask": 25,
"home_directory": False,
"offline_files": "documents",
"acls": [
{
"type": "windows",
"permission": "full_control",
"user_or_group": "Everyone",
},
{"type": "unix_user", "permission": "no_access", "user_or_group": "root"},
],
"access_based_enumeration": False,
"show_snapshot": True,
"svm": {"uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a", "name": "vs1"},
"change_notify": True,
"name": "TEST",
}
)
Updating a specific CIFS share for an SVM
The CIFS share being modified is identified by the UUID of its SVM and the CIFS share name. The CIFS share ACLs cannot be modified with this API.
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = CifsShare(
name="TEST", **{"svm.uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a"}
)
resource.access_based_enumeration = True
resource.change_notify = True
resource.comment = "HR Department Share"
resource.encryption = False
resource.oplocks = True
resource.no_strict_security = True
resource.path = "/"
resource.unix_symlink = "widelink"
resource.show_snapshot = False
resource.continuously_available = True
resource.namespace_caching = False
resource.file_umask = "022"
resource.dir_umask = "022"
resource.offline_files = "programs"
resource.vscan_profile = "no_scan"
resource.force_group_for_create = "root"
resource.patch()
Removing a specific CIFS share for an SVM
The CIFS share being removed is identified by the UUID of its SVM and the CIFS share name.
from netapp_ontap import HostConnection
from netapp_ontap.resources import CifsShare
with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
resource = CifsShare(
name="test", **{"svm.uuid": "6d8e8870-8753-11eb-8d86-0050568ea61a"}
)
resource.delete()
Classes
-
CIFS share is a named access point in a volume. Before users and applications can access data on the CIFS server over SMB, a CIFS share must be created with sufficient share permission. CIFS shares are tied to the CIFS server on the SVM. When a CIFS share is created, ONTAP creates a default ACL for the share with Full Control permissions for Everyone.
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
-
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. -
Deletes a CIFS share.
Related ONTAP commands
vserver cifs share 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.
records
- Can be provided in place of a query. If so, this list of objects will be deleted from the host.
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.
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 -
Retrieves CIFS shares.
Related ONTAP commands
vserver cifs share show
vserver cifs share properties 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. -
Retrieves CIFS shares.
Related ONTAP commands
vserver cifs share show
vserver cifs share properties 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
objectsRaises
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. -
Updates a CIFS share.
Related ONTAP commands
vserver cifs share modify
vserver cifs share properties add
vserver cifs share properties remove
Learn more
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. The body argument will be ignored if records is provided.
*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.
records
- Can be provided in place of a query. If so, this list of objects will be patched on the host.
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.
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 -
Creates a CIFS share.
Required properties
svm.uuid
orsvm.name
- Existing SVM in which to create the CIFS share.name
- Name of the CIFS share.path
- Path in the owning SVM namespace that is shared through this share.
Recommended optional properties
comment
- Optionally choose to add a text comment of up to 256 characters about the CIFS share.acls
- Optionally choose to add share permissions that users and groups have on the CIFS share.
Default property values
If not specified in POST, the following default property values are assigned: *
home_directory
- false *oplocks
- true *access_based_enumeration
- false *change_notify
- true *encryption
- false *unix_symlink
- localRelated ONTAP commands
vserver cifs share create
vserver cifs share properties add
vserver cifs share access-control create
Learn more
Send this collection of objects to the host as a creation request.
Args
records
- A list of
Resource
objects to send to the server to be created. *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 create a bar for a particular foo, the foo.name value should be passed.
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 each object. When hydrate is set to True, poll must also be set to True.
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.
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 list of
Resource
objects matching the provided type
which
have
been
created
by
the
host
and
returned.
This
is
_not_
the
same
list
that
was
provided
,so
to
continue
using
the
object
,you
should save this list. If poll is set to False, then a
NetAppResponse
object is returned instead.Raises
NetAppRestError
: If the API call returned a status code >= 400
Methods
-
Deletes a CIFS share.
Related ONTAP commands
vserver cifs share 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 -
Retrieves a CIFS share.
Related ONTAP commands
vserver cifs share show
vserver cifs share properties 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 -
Updates a CIFS share.
Related ONTAP commands
vserver cifs share modify
vserver cifs share properties add
vserver cifs share properties remove
Learn more
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 -
Creates a CIFS share.
Required properties
svm.uuid
orsvm.name
- Existing SVM in which to create the CIFS share.name
- Name of the CIFS share.path
- Path in the owning SVM namespace that is shared through this share.
Recommended optional properties
comment
- Optionally choose to add a text comment of up to 256 characters about the CIFS share.acls
- Optionally choose to add share permissions that users and groups have on the CIFS share.
Default property values
If not specified in POST, the following default property values are assigned: *
home_directory
- false *oplocks
- true *access_based_enumeration
- false *change_notify
- true *encryption
- false *unix_symlink
- localRelated ONTAP commands
vserver cifs share create
vserver cifs share properties add
vserver cifs share access-control create
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
-
The fields of the CifsShare object
Ancestors
- netapp_ontap.resource.ResourceSchema
- marshmallow.schema.Schema
- marshmallow.base.SchemaABC
Class variables
-
If enabled, all folders inside this share are visible to a user based on that individual user access right; prevents the display of folders or other shared resources that the user does not have access to.
-
The acls field of the cifs_share.
-
Specifies whether CIFS clients can request for change notifications for directories on this share.
-
Specify the CIFS share descriptions.
Example: HR Department Share
-
Specifies whether or not the clients connecting to this share can open files in a persistent manner. Files opened in this way are protected from disruptive events, such as, failover and giveback.
-
Directory Mode Creation Mask to be viewed as an octal number.
Example: 18
-
Specifies that SMB encryption must be used when accessing this share. Clients that do not support encryption are not able to access this share.
-
File Mode Creation Mask to be viewed as an octal number.
Example: 18
-
Specifies that all files that CIFS users create in a specific share belong to the same group (also called the "force-group"). The "force-group" must be a predefined group in the UNIX group database. This setting has no effect unless the security style of the volume is UNIX or mixed security style.
-
Specifies whether or not the share is a home directory share, where the share and path names are dynamic. ONTAP home directory functionality automatically offer each user a dynamic share to their home directory without creating an individual SMB share for each user. The ONTAP CIFS home directory feature enable us to configure a share that maps to different directories based on the user that connects to it. Instead of creating a separate shares for each user, a single share with a home directory parameters can be created. In a home directory share, ONTAP dynamically generates the share-name and share-path by substituting %w, %u, and %d variables with the corresponding Windows user name, UNIX user name, and domain name, respectively.
-
The links field of the cifs_share.
-
Specifies the name of the CIFS share that you want to create. If this is a home directory share then the share name includes the pattern as %w (Windows user name), %u (UNIX user name) and %d (Windows domain name) variables in any combination with this parameter to generate shares dynamically.
Example: HR_SHARE
-
Specifies whether or not the SMB clients connecting to this share can cache the directory enumeration results returned by the CIFS servers.
-
Specifies whether or not CIFS clients can follow a unix symlinks outside the share boundaries.
-
Offline Files The supported values are:
- none - Clients are not permitted to cache files for offline access.
- manual - Clients may cache files that are explicitly selected by the user for offline access.
- documents - Clients may automatically cache files that are used by the user for offline access.
- programs - Clients may automatically cache files that are used by the user for offline access and may use those files in an offline mode even if the share is available.
Valid choices:
- none
- manual
- documents
- programs
-
Specify whether opportunistic locks are enabled on this share. "Oplocks" allow clients to lock files and cache content locally, which can increase performance for file operations.
-
The fully-qualified pathname in the owning SVM namespace that is shared through this share. If this is a home directory share then the path should be dynamic by specifying the pattern %w (Windows user name), %u (UNIX user name), or %d (domain name) variables in any combination. ONTAP generates the path dynamically for the connected user and this path is appended to each search path to find the full Home Directory path.
Example: /volume_1/eng_vol/
-
Specifies whether or not the Snapshot copies can be viewed and traversed by clients.
-
The svm field of the cifs_share.
-
Controls the access of UNIX symbolic links to CIFS clients. The supported values are:
* local - Enables only local symbolic links which is within the same CIFS share. * widelink - Enables both local symlinks and widelinks. * disable - Disables local symlinks and widelinks.
Valid choices:
- local
- widelink
- disable
-
The volume field of the cifs_share.
-
Vscan File-Operations Profile The supported values are:
- no_scan - Virus scans are never triggered for accesses to this share.
- standard - Virus scans can be triggered by open, close, and rename operations.
- strict - Virus scans can be triggered by open, read, close, and rename operations.
- writes_only - Virus scans can be triggered only when a file that has been modified is closed.
Valid choices:
- no_scan
- standard
- strict
- writes_only