Init: mediaserver

This commit is contained in:
2023-02-08 12:13:28 +01:00
parent 848bc9739c
commit f7c23d4ba9
31914 changed files with 6175775 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
===========================
Dellemc.Unity Change Log
===========================
.. contents:: Topics
v1.5.0
======
Minor Changes
-------------
- Updated modules to adhere with ansible community guidelines.
v1.4.1
======
Minor Changes
-------------
- Updated the execution environment related files.
v1.4.0
======
Minor Changes
-------------
- Added cifsserver module to support create, list and delete CIFS server.
- Added execution environment manifest file to support building an execution environment with ansible-builder.
- Added interface module to support create, list and delete interface.
- Added nfsserver module to support create, list and delete NFS server.
- Check mode is supported for Info.
- Enhance nfs module to support advanced host management option.
- Enhanced filesystem module to support create, modify and delete of filesystem replication.
- Enhanced info module to list cifs server, nfs servers, ethernet port and file interface.
- Enhanced nas server module to support create, modify and delete of nas server replication.
New Modules
-----------
- dellemc.unity.cifsserver - Manage CIFS server on Unity storage system
- dellemc.unity.interface - Manage Interfaces on Unity storage system
- dellemc.unity.nfsserver - Manage NFS server on Unity storage system
v1.3.0
======
Minor Changes
-------------
- Added rotating file handler for logging.
- Bugfix in volume module to retrieve details of non-thin volumes.
- Enhance host module to support add/remove network address to/from a host.
- Enhanced Info module to list disk groups.
- Enhanced Storage Pool module to support listing of drive details of a pool
- Enhanced Storage pool module to support creation of storage pool
- Enhanced consistency group module to support enable/disable replication in consistency group
- Enhanced host module to support both mapping and un-mapping of non-logged-in initiators to host.
- Enhanced host module to support listing of network addresses, FC initiators, ISCSI initiators and allocated volumes of a host
- Removed dellemc.unity prefix from module names.
- Renamed gatherfacts module to info module
v1.2.1
======
Minor Changes
-------------
- Added dual licensing
- Documentation updates
- Fixed typo in galaxy.yml
- Updated few samples in modules
v1.2.0
======
Minor Changes
-------------
- Added CRUD operations support for Quota tree.
- Added CRUD operations support for User Quota on Filesystem/Quota tree.
- Added support for Application tagging.
- Consistency group module is enhanced to map/unmap hosts to/from a new or existing consistency group.
- Filesystem module is enhanced to associate/dissociate snapshot schedule to/from a Filesystem.
- Filesystem module is enhanced to update default quota configuration during create operation.
- Gather facts module is enhanced to list User Quota and Quota tree components.
- Volume module is enhanced to support map/unmap multiple hosts from a volume.
New Modules
-----------
- dellemc.unity.tree_quota - Manage quota tree on the Unity storage system
- dellemc.unity.user_quota - Manage user quota on the Unity storage system
v1.1.0
======
Minor Changes
-------------
- Added CRUD operations support for Filesystem snapshot.
- Added CRUD operations support for Filesystem.
- Added CRUD operations support for NFS export.
- Added CRUD operations support for SMB share.
- Added support to get/modify operations on NAS server.
- Gather facts module is enhanced to list Filesystem snapshots, NAS servers, File systems, NFS exports, SMB shares.
New Modules
-----------
- dellemc.unity.filesystem - Manage filesystem on Unity storage system
- dellemc.unity.filesystem_snapshot - Manage filesystem snapshot on the Unity storage system
- dellemc.unity.nasserver - Manage NAS servers on Unity storage system
- dellemc.unity.nfs - Manage NFS export on Unity storage system
- dellemc.unity.smbshare - Manage SMB shares on Unity storage system
v1.0.0
======
Major Changes
-------------
- Added CRUD operations support for Consistency group.
- Added CRUD operations support for Volume.
- Added CRUD operations support for a snapshot schedule.
- Added support for CRUD operations on a host with FC/iSCSI initiators.
- Added support for CRUD operations on a snapshot of a volume.
- Added support for adding/removing volumes to/from a consistency group.
- Added support to add/remove FC/iSCSI initiators to/from a host.
- Added support to create a snapshot for a consistency group.
- Added support to get/modify operations on storage pool.
- Added support to map/unmap a host to/from a snapshot.
- Gather facts module is enhanced to list volumes, consistency groups, FC initiators, iSCSI initiators, hosts, snapshot schedules.
New Modules
-----------
- dellemc.unity.consistencygroup - Manage consistency groups on Unity storage system
- dellemc.unity.host - Manage Host operations on Unity
- dellemc.unity.info - Gathering information about Unity
- dellemc.unity.snapshot - Manage snapshots on the Unity storage system
- dellemc.unity.snapshotschedule - Manage snapshot schedules on Unity storage system
- dellemc.unity.storagepool - Manage storage pool on Unity
- dellemc.unity.volume - Manage volume on Unity storage system

View File

@@ -0,0 +1,600 @@
{
"files": [
{
"name": ".",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "CHANGELOG.rst",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "3b41c9ab9380851e938601886d427d61ffc094ebe4af44119bad6aa8ecc04c09",
"format": 1
},
{
"name": "LICENSE",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "8b1ba204bb69a0ade2bfcf65ef294a920f6bb361b317dba43c7ef29d96332b9b",
"format": 1
},
{
"name": "MODULE-LICENSE",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
"format": 1
},
{
"name": "README.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "4aa53d1139ef2b275ab3fbe08e79a4cbbcec76931cb07e1602783327e39d4ed0",
"format": 1
},
{
"name": "changelogs",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "changelogs/.plugin-cache.yaml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "a53a52d256a06ea2e1f309ba3ef542977f54ef173269c6f639ca35daa570849f",
"format": 1
},
{
"name": "changelogs/changelog.yaml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "eee0999f4405cf7aa065ce031b998060099308434b6199b6e5947fe645fa2402",
"format": 1
},
{
"name": "changelogs/config.yaml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0ad32bcb3927f6676bb3f1501ad872b55c87129d2266412051e57847a65508b1",
"format": 1
},
{
"name": "docs",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "docs/ADOPTERS.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "c81933a41503275063d789f0685472e1603e4614376f3918b42c4bfb210a2c01",
"format": 1
},
{
"name": "docs/BRANCHING.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "ae716ec9cdebdf9f24166ba485eba474de335db37bcf51e50d65dad5a6fdde85",
"format": 1
},
{
"name": "docs/CODE_OF_CONDUCT.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "1d47343b6cae5e147a16cc1c312461d175f29d89c8c6094e024d6cb885f5cc36",
"format": 1
},
{
"name": "docs/CONTRIBUTING.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "d07b61db5f2a7bb85d630242e70c23bf3d20a8272d8b42ac2113dfeed418ae60",
"format": 1
},
{
"name": "docs/INSTALLATION.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "d9a7a8e350f0dd552b51fe63cfdf2fe00ad2d69b34aef902156af23b2869bde1",
"format": 1
},
{
"name": "docs/ISSUE_TRIAGE.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "ffc4402bfc8e68fff1db9aeff684948f4486a3f8cb5d58eebf0da3534747bcf3",
"format": 1
},
{
"name": "docs/MAINTAINER_GUIDE.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "86318bae1344674e30c98ddd4ed0e8b55db6ae5f39edf376274d81d13eb96db5",
"format": 1
},
{
"name": "docs/Product Guide.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "62295b1840e59bf555810686fef04553762475507d9ea5fb1cb56e72cdeb84c2",
"format": 1
},
{
"name": "docs/Release Notes.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "16d85dd9544284e9a1602862c114798243a4e7ed5317869b68428e8087a977c4",
"format": 1
},
{
"name": "docs/SECURITY.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "2f97dbe35e85c9d0af79c9cf3229baa56f8f84c383ce43e9708329af68112391",
"format": 1
},
{
"name": "docs/SUPPORT.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "dc16b1e742969c2c208f6ea60211b637878f6278212f2a123b333b6448288733",
"format": 1
},
{
"name": "docs/MAINTAINERS.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "e748fd39a38ac2a61aa6f48eac2179dffcc5a3e8f261f54042946d969bbfadf6",
"format": 1
},
{
"name": "docs/COMMITTER_GUIDE.md",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "b41b38fe09cfcbfb4499c39ed4822a9f8c3f5d562e68dad45b5f2389f18053b5",
"format": 1
},
{
"name": "meta",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "meta/execution-environment.yml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "6fecf89b56560e79560dba9f860201828a8df82323d02c3a6a4e5fbfaa0aed3a",
"format": 1
},
{
"name": "meta/runtime.yml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "1ad0fa1a5cceaac69ea46df66d57fe6f290544c8efa6fabd2a2982296e428536",
"format": 1
},
{
"name": "plugins",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/doc_fragments",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/doc_fragments/unity.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "59baa9afd0063cf6ccc64d0be2f93bcdac944d2d53d9a9808654d5715173eab2",
"format": 1
},
{
"name": "plugins/module_utils",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/module_utils/storage",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/module_utils/storage/dell",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/module_utils/storage/dell/__init__.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"format": 1
},
{
"name": "plugins/module_utils/storage/dell/logging_handler.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "a940654af74df1d2ed5d35691ee46a542190227e414d87d68c471c3210202750",
"format": 1
},
{
"name": "plugins/module_utils/storage/dell/utils.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "7fec20103cba14b247e99885a64d5f447876743d1a2c1aabfa41344fa3b5811a",
"format": 1
},
{
"name": "plugins/modules",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "plugins/modules/cifsserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "e5557cf556c549d471c3a8f900598932edb116f83fe001aca27d20aeaabe8674",
"format": 1
},
{
"name": "plugins/modules/consistencygroup.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "4ef364861ab2603180a7025724892f168c8c5e3740795e3dc70f12d5d496154f",
"format": 1
},
{
"name": "plugins/modules/filesystem.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "b0c366bb29c733eb6a320a535c4d8271d0f0d027ae641b87186a317877358fd3",
"format": 1
},
{
"name": "plugins/modules/filesystem_snapshot.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "9dfcad8f1b83a848e82e15a29764bdb2831670467d097bb7d3f4860008c048b0",
"format": 1
},
{
"name": "plugins/modules/host.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "6f46cdb51124e9ffda1653ff5ffc2f20ddcae7fa1221423d46dcb7588d0b6baa",
"format": 1
},
{
"name": "plugins/modules/info.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "5da6a19f981ed6cb95050cb05b46cbe46ce7678de45ba8ed0437e3a717a1e13c",
"format": 1
},
{
"name": "plugins/modules/interface.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0eb4ab5d3132eaed48d560495e10d8a90e28a1e6cc457854c1d02294d205c2c0",
"format": 1
},
{
"name": "plugins/modules/nasserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "cab2356f33d72c9080323dd4bde8d74ce7e85645075f4b34376cb8fe22a655bd",
"format": 1
},
{
"name": "plugins/modules/nfs.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "1bb77b56cdbd086ce949f04f62977af609e0c6cba159c651a1adc734fea015bc",
"format": 1
},
{
"name": "plugins/modules/nfsserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "86e4b7c3383457ac04a53844b15a1bec8ef3e7991a2cc39cf2ff0d38df0cd8a2",
"format": 1
},
{
"name": "plugins/modules/smbshare.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "84ebf06a630cf8057cd4d380c98f2dac00cfbffb53ff179e7144c2ba18339fc1",
"format": 1
},
{
"name": "plugins/modules/snapshot.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "e186f0ce63a0b4c223341677372f7c1c500073e62dfa6fc63be80352d10b5f1e",
"format": 1
},
{
"name": "plugins/modules/snapshotschedule.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "af48985493c845285965ffcad9a85820d3300a17c527cb356ff2fedd3b9403c0",
"format": 1
},
{
"name": "plugins/modules/storagepool.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "04e838a1151368436f2b10291084d14d42890d7d6102c30a536389a391e7ddea",
"format": 1
},
{
"name": "plugins/modules/tree_quota.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "ecdacddb2495e2bd561140796fdc802d9d33a75b9acf3301e9169c9f8e5d98c3",
"format": 1
},
{
"name": "plugins/modules/user_quota.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "afcf7a3e5ff72c444866bd80a4d93071428d39614b9d78eeccc19cc7713931fe",
"format": 1
},
{
"name": "plugins/modules/volume.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "a57a4ba37e699650ea05927c348b9e029e3db0f0be1f52df562e8f2209fbe0e6",
"format": 1
},
{
"name": "requirements.yml",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "60355bcbb93016c5bff4bc3a5d1eb99d26cd74d0da681517e2a20545b71501d4",
"format": 1
},
{
"name": "tests",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/sanity",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/sanity/ignore-2.12.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0744d235664baa2ba82f601e70b4cdf68a2224dc8b71bb4c1d2c7989893b03e8",
"format": 1
},
{
"name": "tests/sanity/ignore-2.13.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0320ab54e2eff89b32cff7ed9256208968ae59a75bcc2fe4493dc9a58bd62ade",
"format": 1
},
{
"name": "tests/sanity/ignore-2.14.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0320ab54e2eff89b32cff7ed9256208968ae59a75bcc2fe4493dc9a58bd62ade",
"format": 1
},
{
"name": "tests/unit",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/unit/plugins",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/unit/plugins/module_utils",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_api_exception.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "a7a0fa0bda40ed6b6bbd4193bb68a8c8402864506aa9031f655fc102ca49bfb6",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_cifsserver_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "b864ceef5c5db21f3282a76094c8d9226186dadebf9851432fff4fb57e59cfad",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_consistencygroup_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "6df144fe81cfe2a4d59f7ff5c4d0f22925b0c9b9d6fadf56fee25f3b046efe47",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_filesystem_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "171c7ad10cbe32e041c124a91fc1c34fa6c80585da66afe7938c6133031e8202",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_host_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "5d7e6f5d137f6977389d84485ddffd09099d13b756256a8190b506b86089db1a",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_interface_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "6c8de82b6b7311a2ec191fc510d0bc06cde5e0627f74e83711de69c629e826fc",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_nasserver_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "e5f8e78abd2a70ecb4d42b4384b872f2075c9bc91bdca683a42787a0f5ce9851",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_nfs_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "3cea065ef9996c1ea912f4772c6a420d097db695863dcc06158e838f450f8f4c",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_nfsserver_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "03b34a46b5c55696c4741dbd3749b1a654cf401e29e79443908145ef87ff5994",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_sdk_response.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0813900fa591ec50510b41bfca7960791baf5ed9f08c2b41a09483b7011c21b4",
"format": 1
},
{
"name": "tests/unit/plugins/module_utils/mock_storagepool_api.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "bb7fd67ca3924ba62b179b93f879ff07f16a1ada51742c12cd947e48e0aad26f",
"format": 1
},
{
"name": "tests/unit/plugins/modules",
"ftype": "dir",
"chksum_type": null,
"chksum_sha256": null,
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_cifsserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "7031be0fee19af368f61e6f07404c941ec64139f066514eeca48a5f3c9224749",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_consistencygroup.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "684935db745c549cae4c337b85fede00ab0f95dea56c129c158abfb006cba901",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_filesystem.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "4c56c28cf9a4e3b50a4d7031863eb127fda8795da574024e2fc4351e5c002907",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_host.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "cbc6464fdcbc66df43da1ef26cbf64d86b77406f28ded032dc7c7c4da6034cd0",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_interface.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "10476e71c1542a43c01b1c9622dbc54b32ae3512fd1cd3ecd2dbec61b06b373b",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_nasserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "09ef2b39687911942250b40ba350920a496e00dc864f05b8b46d2a79958769b1",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_nfs.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "d87b5b2a61917c4057561c51921e493d4f4ad7936bbd80b4d8920af1b843fd02",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_nfsserver.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "fd07766bb20d3eacf1bf1823ecc019e081893ffc0195d5611103a0c62a713628",
"format": 1
},
{
"name": "tests/unit/plugins/modules/test_storagepool.py",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "63dafda1a4e630b23a637affabacfefd5c14a3231a0fae02d3886b0bf7656525",
"format": 1
},
{
"name": "tests/requirements.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "65e6091d1c8d88a703555bd13590bb95248fb0b7376d3ed1d660e2b9d65581c8",
"format": 1
},
{
"name": "requirements.txt",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "ea96c62d419724d448e0ed0b2099f5242e6a9cc26abca64844f1ed99c082e844",
"format": 1
}
],
"format": 1
}

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -0,0 +1,41 @@
{
"collection_info": {
"namespace": "dellemc",
"name": "unity",
"version": "1.5.0",
"authors": [
"Akash Shendge <ansible.team@dell.com>",
"Ambuj Dubey <ansible.team@dell.com>",
"Arindam Datta <ansible.team@dell.com>",
"P Srinivas Rao <ansible.team@dell.com>",
"Rajshree Khare <ansible.team@dell.com>",
"Vivek Soni <ansible.team@dell.com>",
"Spandita Panigrahi <ansible.team@dell.com>",
"Ananthu S Kuttattu <ansible.team@dell.com>",
"Pavan Mudunuri <ansible.team@dell.com>"
],
"readme": "README.md",
"tags": [
"storage"
],
"description": "Ansible modules for Unity",
"license": [
"GPL-3.0-or-later",
"Apache-2.0"
],
"license_file": null,
"dependencies": {},
"repository": "https://github.com/dell/ansible-unity/tree/1.5.0",
"documentation": "https://github.com/dell/ansible-unity/tree/1.5.0/docs",
"homepage": "https://github.com/dell/ansible-unity/tree/1.5.0",
"issues": "https://www.dell.com/community/Automation/bd-p/Automation"
},
"file_manifest_file": {
"name": "FILES.json",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "9b3628f9c11980e54957b66a4d52d99347ee35903e617762232cfb01288da811",
"format": 1
},
"format": 1
}

View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,71 @@
# Ansible Modules for Dell Technologies Unity
The Ansible Modules for Dell Technologies (Dell) Unity allow Data Center and IT administrators to use RedHat Ansible to automate and orchestrate the configuration and management of Dell Unity arrays.
The capabilities of the Ansible modules are managing consistency groups, filesystem, filesystem snapshots, CIFS server, NAS server, NFS server, NFS export, SMB share, interface, hosts, snapshots, snapshot schedules, storage pools, user quotas, quota trees and volumes. Capabilities also include gathering facts from the array. The options available for each are list, show, create, modify and delete. These tasks can be executed by running simple playbooks written in yaml syntax. The modules are written so that all the operations are idempotent, so making multiple identical requests has the same effect as making a single request.
## Table of contents
* [Code of conduct](https://github.com/dell/ansible-unity/blob/1.5.0/docs/CODE_OF_CONDUCT.md)
* [Maintainer guide](https://github.com/dell/ansible-unity/blob/1.5.0/docs/MAINTAINER_GUIDE.md)
* [Committer guide](https://github.com/dell/ansible-unity/blob/1.5.0/docs/COMMITTER_GUIDE.md)
* [Contributing guide](https://github.com/dell/ansible-unity/blob/1.5.0/docs/CONTRIBUTING.md)
* [Branching strategy](https://github.com/dell/ansible-unity/blob/1.5.0/docs/BRANCHING.md)
* [List of adopters](https://github.com/dell/ansible-unity/blob/1.5.0/docs/ADOPTERS.md)
* [Maintainers](https://github.com/dell/ansible-unity/blob/1.5.0/docs/MAINTAINERS.md)
* [Support](https://github.com/dell/ansible-unity/blob/1.5.0/docs/SUPPORT.md)
* [License](#license)
* [Security](https://github.com/dell/ansible-unity/blob/1.5.0/docs/SECURITY.md)
* [Prerequisites](#prerequisites)
* [List of Ansible modules for Dell Unity](#list-of-ansible-modules-for-dell-unity)
* [Installation and execution of Ansible modules for Dell Unity](#installation-and-execution-of-ansible-modules-for-dell-unity)
* [Releasing, Maintenance and Deprecation](#releasing-maintenance-and-deprecation)
## License
The Ansible collection for Unity is released and licensed under the GPL-3.0 license. See [LICENSE](https://github.com/dell/ansible-unity/blob/1.5.0/LICENSE) for the full terms. Ansible modules and module utilities that are part of the Ansible collection for Unity are released and licensed under the Apache 2.0 license. See [MODULE-LICENSE](https://github.com/dell/ansible-unity/blob/1.5.0/MODULE-LICENSE) for the full terms.
## Supported Platforms
* Dell Unity Arrays version 5.1, 5.2
## Prerequisites
This table provides information about the software prerequisites for the Ansible Modules for Dell Unity.
| **Ansible Modules** | **Python version** | **Storops - Python SDK version** | **Ansible** |
|---------------------|--------------------|----------------------------------|-------------|
| v1.5.0 | 3.9 <br> 3.10 <br> 3.11 | 1.2.11 | 2.12 <br> 2.13 <br> 2.14|
## Idempotency
The modules are written in such a way that all requests are idempotent and hence fault-tolerant. It essentially means that the result of a successfully performed request is independent of the number of times it is executed.
## List of Ansible Modules for Dell Unity
* [Consistency group module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#consistency-group-module)
* [Filesystem module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#filesystem-module)
* [Filesystem snapshot module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#filesystem-snapshot-module)
* [Info module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#info-module)
* [Host module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#host-module)
* [CIFS server module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#cifs-server-module)
* [NAS server module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#nas-server-module)
* [NFS server module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#nfs-server-module)
* [NFS export module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md##nfs-module)
* [SMB share module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#smb-share-module)
* [Interface module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#interface-module)
* [Snapshot module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#snapshot-module)
* [Snapshot schedule module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#snapshot-schedule-module)
* [Storage pool module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#storage-pool-module)
* [User quota module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#user-quota-module)
* [Quota tree module ](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#quota-tree-module)
* [Volume module](https://github.com/dell/ansible-unity/blob/1.5.0/docs/Product%20Guide.md#volume-module)
## Installation and execution of Ansible modules for Dell Unity
The installation and execution steps of Ansible modules for Dell Unity can be found [here](https://github.com/dell/ansible-unity/blob/1.5.0/docs/INSTALLATION.md).
## Releasing, Maintenance and Deprecation
Ansible Modules for Dell Technnologies Unity follows [Semantic Versioning](https://semver.org/).
New version will be release regularly if significant changes (bug fix or new feature) are made in the collection.
Released code versions are located on "release" branches with names of the form "release-x.y.z" where x.y.z corresponds to the version number. More information on branching strategy followed can be found [here](https://github.com/dell/ansible-unity/blob/1.5.0/docs/BRANCHING.md).
Ansible Modules for Dell Technologies Unity deprecation cycle is aligned with that of [Ansible](https://docs.ansible.com/ansible/latest/dev_guide/module_lifecycle.html).

View File

@@ -0,0 +1,102 @@
objects:
role: {}
plugins:
become: {}
cache: {}
callback: {}
cliconf: {}
connection: {}
httpapi: {}
inventory: {}
lookup: {}
module:
cifsserver:
description: Manage CIFS server on Unity storage system
name: cifsserver
namespace: ''
version_added: 1.4.0
consistencygroup:
description: Manage consistency groups on Unity storage system
name: consistencygroup
namespace: ''
version_added: 1.1.0
filesystem:
description: Manage filesystem on Unity storage system
name: filesystem
namespace: ''
version_added: 1.1.0
filesystem_snapshot:
description: Manage filesystem snapshot on the Unity storage system
name: filesystem_snapshot
namespace: ''
version_added: 1.1.0
host:
description: Manage Host operations on Unity
name: host
namespace: ''
version_added: 1.1.0
info:
description: Gathering information about Unity
name: info
namespace: ''
version_added: 1.1.0
interface:
description: Manage Interfaces on Unity storage system
name: interface
namespace: ''
version_added: 1.4.0
nasserver:
description: Manage NAS servers on Unity storage system
name: nasserver
namespace: ''
version_added: 1.1.0
nfs:
description: Manage NFS export on Unity storage system
name: nfs
namespace: ''
version_added: 1.1.0
nfsserver:
description: Manage NFS server on Unity storage system
name: nfsserver
namespace: ''
version_added: 1.4.0
smbshare:
description: Manage SMB shares on Unity storage system
name: smbshare
namespace: ''
version_added: 1.1.0
snapshot:
description: Manage snapshots on the Unity storage system
name: snapshot
namespace: ''
version_added: 1.1.0
snapshotschedule:
description: Manage snapshot schedules on Unity storage system
name: snapshotschedule
namespace: ''
version_added: 1.1.0
storagepool:
description: Manage storage pool on Unity
name: storagepool
namespace: ''
version_added: 1.1.0
tree_quota:
description: Manage quota tree on the Unity storage system
name: tree_quota
namespace: ''
version_added: 1.2.0
user_quota:
description: Manage user quota on the Unity storage system
name: user_quota
namespace: ''
version_added: 1.2.0
volume:
description: Manage volume on Unity storage system
name: volume
namespace: ''
version_added: 1.1.0
netconf: {}
shell: {}
strategy: {}
vars: {}
version: 1.5.0

View File

@@ -0,0 +1,152 @@
ancestor: null
releases:
1.0.0:
changes:
major_changes:
- Added CRUD operations support for Consistency group.
- Added CRUD operations support for Volume.
- Added CRUD operations support for a snapshot schedule.
- Added support for CRUD operations on a host with FC/iSCSI initiators.
- Added support for CRUD operations on a snapshot of a volume.
- Added support for adding/removing volumes to/from a consistency group.
- Added support to add/remove FC/iSCSI initiators to/from a host.
- Added support to create a snapshot for a consistency group.
- Added support to get/modify operations on storage pool.
- Added support to map/unmap a host to/from a snapshot.
- Gather facts module is enhanced to list volumes, consistency groups, FC initiators,
iSCSI initiators, hosts, snapshot schedules.
modules:
- description: Manage consistency groups on Unity storage system
name: consistencygroup
namespace: ''
- description: Manage Host operations on Unity
name: host
namespace: ''
- description: Gathering information about Unity
name: info
namespace: ''
- description: Manage snapshots on the Unity storage system
name: snapshot
namespace: ''
- description: Manage snapshot schedules on Unity storage system
name: snapshotschedule
namespace: ''
- description: Manage storage pool on Unity
name: storagepool
namespace: ''
- description: Manage volume on Unity storage system
name: volume
namespace: ''
release_date: '2020-06-20'
1.1.0:
changes:
minor_changes:
- Added CRUD operations support for Filesystem snapshot.
- Added CRUD operations support for Filesystem.
- Added CRUD operations support for NFS export.
- Added CRUD operations support for SMB share.
- Added support to get/modify operations on NAS server.
- Gather facts module is enhanced to list Filesystem snapshots, NAS servers,
File systems, NFS exports, SMB shares.
modules:
- description: Manage filesystem on Unity storage system
name: filesystem
namespace: ''
- description: Manage filesystem snapshot on the Unity storage system
name: filesystem_snapshot
namespace: ''
- description: Manage NAS servers on Unity storage system
name: nasserver
namespace: ''
- description: Manage NFS export on Unity storage system
name: nfs
namespace: ''
- description: Manage SMB shares on Unity storage system
name: smbshare
namespace: ''
release_date: '2020-12-02'
1.2.0:
changes:
minor_changes:
- Added CRUD operations support for Quota tree.
- Added CRUD operations support for User Quota on Filesystem/Quota tree.
- Added support for Application tagging.
- Consistency group module is enhanced to map/unmap hosts to/from a new or existing
consistency group.
- Filesystem module is enhanced to associate/dissociate snapshot schedule to/from
a Filesystem.
- Filesystem module is enhanced to update default quota configuration during
create operation.
- Gather facts module is enhanced to list User Quota and Quota tree components.
- Volume module is enhanced to support map/unmap multiple hosts from a volume.
modules:
- description: Manage quota tree on the Unity storage system
name: tree_quota
namespace: ''
- description: Manage user quota on the Unity storage system
name: user_quota
namespace: ''
release_date: '2021-06-25'
1.2.1:
changes:
minor_changes:
- Added dual licensing
- Documentation updates
- Fixed typo in galaxy.yml
- Updated few samples in modules
release_date: '2021-09-28'
1.3.0:
changes:
minor_changes:
- Added rotating file handler for logging.
- Bugfix in volume module to retrieve details of non-thin volumes.
- Enhance host module to support add/remove network address to/from a host.
- Enhanced Info module to list disk groups.
- Enhanced Storage Pool module to support listing of drive details of a pool
- Enhanced Storage pool module to support creation of storage pool
- Enhanced consistency group module to support enable/disable replication in
consistency group
- Enhanced host module to support both mapping and un-mapping of non-logged-in
initiators to host.
- Enhanced host module to support listing of network addresses, FC initiators,
ISCSI initiators and allocated volumes of a host
- Removed dellemc.unity prefix from module names.
- Renamed gatherfacts module to info module
release_date: '2022-03-25'
1.4.0:
changes:
minor_changes:
- Added cifsserver module to support create, list and delete CIFS server.
- Added execution environment manifest file to support building an execution
environment with ansible-builder.
- Added interface module to support create, list and delete interface.
- Added nfsserver module to support create, list and delete NFS server.
- Check mode is supported for Info.
- Enhance nfs module to support advanced host management option.
- Enhanced filesystem module to support create, modify and delete of filesystem
replication.
- Enhanced info module to list cifs server, nfs servers, ethernet port and file
interface.
- Enhanced nas server module to support create, modify and delete of nas server
replication.
modules:
- description: Manage CIFS server on Unity storage system
name: cifsserver
namespace: ''
- description: Manage Interfaces on Unity storage system
name: interface
namespace: ''
- description: Manage NFS server on Unity storage system
name: nfsserver
namespace: ''
release_date: '2022-06-28'
1.4.1:
changes:
minor_changes:
- Updated the execution environment related files.
release_date: '2022-09-27'
1.5.0:
changes:
minor_changes:
- Updated modules to adhere with ansible community guidelines.
release_date: '2022-12-20'

View File

@@ -0,0 +1,33 @@
---
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
changes_format: combined
ignore_other_fragment_extensions: true
keep_fragments: false
mention_ancestor: true
new_plugins_after_name: removed_features
notesdir: fragments
prelude_section_name: release_summary
prelude_section_title: Release Summary
sanitize_changelog: true
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
title: Dellemc.Unity
trivial_section_name: trivial
use_fqcn: true

View File

@@ -0,0 +1,5 @@
---
version: 1
dependencies:
galaxy: requirements.yml
python: requirements.txt

View File

@@ -0,0 +1,79 @@
---
requires_ansible: ">=2.12"
plugin_routing:
modules:
dellemc_unity_info:
redirect: dellemc.unity.info
deprecation:
removal_date: "2024-03-31"
warning_text: Use info instead.
dellemc_unity_gatherfacts:
redirect: dellemc.unity.info
deprecation:
removal_date: "2024-03-31"
warning_text: Use info instead.
dellemc_unity_consistencygroup:
redirect: dellemc.unity.consistencygroup
deprecation:
removal_date: "2024-03-31"
warning_text: Use consistencygroup instead.
dellemc_unity_filesystem_snapshot:
redirect: dellemc.unity.filesystem_snapshot
deprecation:
removal_date: "2024-03-31"
warning_text: Use filesystem_snapshot instead.
dellemc_unity_filesystem:
redirect: dellemc.unity.filesystem
deprecation:
removal_date: "2024-03-31"
warning_text: Use filesystem instead.
dellemc_unity_host:
redirect: dellemc.unity.host
deprecation:
removal_date: "2024-03-31"
warning_text: Use host instead.
dellemc_unity_nasserver:
redirect: dellemc.unity.nasserver
deprecation:
removal_date: "2024-03-31"
warning_text: Use nasserver instead.
dellemc_unity_nfs:
redirect: dellemc.unity.nfs
deprecation:
removal_date: "2024-03-31"
warning_text: Use nfs instead.
dellemc_unity_smbshare:
redirect: dellemc.unity.smbshare
deprecation:
removal_date: "2024-03-31"
warning_text: Use smbshare instead.
dellemc_unity_snapshot:
redirect: dellemc.unity.snapshot
deprecation:
removal_date: "2024-03-31"
warning_text: Use snapshot instead.
dellemc_unity_snapshotschedule:
redirect: dellemc.unity.snapshotschedule
deprecation:
removal_date: "2024-03-31"
warning_text: Use snapshotschedule instead.
dellemc_unity_storagepool:
redirect: dellemc.unity.storagepool
deprecation:
removal_date: "2024-03-31"
warning_text: Use storagepool instead.
dellemc_unity_tree_quota:
redirect: dellemc.unity.tree_quota
deprecation:
removal_date: "2024-03-31"
warning_text: Use tree_quota instead.
dellemc_unity_user_quota:
redirect: dellemc.unity.user_quota
deprecation:
removal_date: "2024-03-31"
warning_text: Use user_quota instead.
dellemc_unity_volume:
redirect: dellemc.unity.volume
deprecation:
removal_date: "2024-03-31"
warning_text: Use volume instead.

View File

@@ -0,0 +1,53 @@
# Copyright: (c) 2020, Dell Technologies.
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
class ModuleDocFragment(object):
# Documentation fragment for Unity (unity)
DOCUMENTATION = r'''
options:
unispherehost:
required: true
description:
- IP or FQDN of the Unity management server.
type: str
username:
type: str
required: true
description:
- The username of the Unity management server.
password:
type: str
required: true
description:
- The password of the Unity management server.
validate_certs:
type: bool
default: true
aliases:
- verifycert
description:
- Boolean variable to specify whether or not to validate SSL
certificate.
- C(true) - Indicates that the SSL certificate should be verified.
- C(false) - Indicates that the SSL certificate should not be
verified.
port:
description:
- Port number through which communication happens with Unity
management server.
type: int
default: 443
requirements:
- A Dell Unity Storage device version 5.1 or later.
- Ansible-core 2.12 or later.
- Python 3.9, 3.10 or 3.11.
- Storops Python SDK 1.2.11.
notes:
- The modules present in this collection named as 'dellemc.unity'
are built to support the Dell Unity storage platform.
'''

View File

@@ -0,0 +1,25 @@
# Copyright: (c) 2022, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Custom rotating file handler for Unity"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from datetime import datetime
from logging.handlers import RotatingFileHandler
class CustomRotatingFileHandler(RotatingFileHandler):
def rotation_filename(self, default_name):
"""
Modify the filename of a log file when rotating.
:param default_name: The default name of the log file.
"""
src_file_name = default_name.split('.')
dest_file_name = "{0}_{1}.{2}.{3}".format(
src_file_name[0], '{0:%Y%m%d}'.format(datetime.now()),
src_file_name[1], src_file_name[2]
)
return dest_file_name

View File

@@ -0,0 +1,254 @@
# Copyright: (c) 2020, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import logging
from decimal import Decimal
import re
import traceback
import math
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell.logging_handler \
import CustomRotatingFileHandler
from ansible.module_utils.basic import missing_required_lib
try:
import urllib3
urllib3.disable_warnings()
HAS_URLLIB3, URLLIB3_IMP_ERR = True, None
except ImportError:
HAS_URLLIB3, URLLIB3_IMP_ERR = False, traceback.format_exc()
try:
from storops import UnitySystem
from storops.unity.client import UnityClient
from storops.unity.resource import host, cg, snap_schedule, snap, \
cifs_share, nas_server
from storops.unity.resource.lun import UnityLun
from storops.unity.resource.pool import UnityPool, UnityPoolList, RaidGroupParameter
from storops.unity.resource.filesystem import UnityFileSystem, \
UnityFileSystemList
from storops.unity.resource.nas_server import UnityNasServer
from storops.unity.resource.nfs_share import UnityNfsShare, \
UnityNfsShareList
from storops.unity.resource.snap_schedule import UnitySnapScheduleList, \
UnitySnapSchedule
from storops.unity.resource.replication_session import UnityReplicationSession
from storops.unity.enums import HostInitiatorTypeEnum, \
TieringPolicyEnum, ScheduleTypeEnum, DayOfWeekEnum, NodeEnum, \
HostLUNAccessEnum, HostTypeEnum, AccessPolicyEnum, \
FilesystemTypeEnum, FSSupportedProtocolEnum, FSFormatEnum, \
NFSTypeEnum, NFSShareDefaultAccessEnum, NFSShareSecurityEnum, \
FilesystemSnapAccessTypeEnum, FSLockingPolicyEnum, \
CifsShareOfflineAvailabilityEnum, NasServerUnixDirectoryServiceEnum, \
KdcTypeEnum, NodeEnum, FileInterfaceRoleEnum
from storops.exception import UnityResourceNotFoundError, \
StoropsConnectTimeoutError, UnityNfsShareNameExistedError
from storops.connection.exceptions import HttpError, HTTPClientError
from storops.unity.resource.user_quota import UnityUserQuota, \
UnityUserQuotaList
from storops.unity.resource.tree_quota import UnityTreeQuota, \
UnityTreeQuotaList
from storops.unity.resource.quota_config import UnityQuotaConfig, \
UnityQuotaConfigList
from storops.unity.resource.storage_resource import UnityStorageResource
from storops.unity.enums import QuotaPolicyEnum, RaidTypeEnum, \
RaidStripeWidthEnum, StoragePoolTypeEnum
from storops.unity.resource.disk import UnityDisk, \
UnityDiskList, UnityDiskGroup, UnityDiskGroupList
from storops.unity.resource.cifs_server import UnityCifsServer
from storops.unity.resource.nfs_server import UnityNfsServer
from storops.unity.resource.interface import UnityFileInterface
HAS_UNITY_SDK, STOROPS_IMP_ERR = True, None
except ImportError:
HAS_UNITY_SDK, STOROPS_IMP_ERR = False, traceback.format_exc()
try:
from pkg_resources import parse_version
import pkg_resources
HAS_PKG_RESOURCE, PKG_RESOURCE_IMP_ERR = True, None
except ImportError:
HAS_PKG_RESOURCE, PKG_RESOURCE_IMP_ERR = False, traceback.format_exc()
def ensure_required_libs(module):
"""Check required libraries"""
if not HAS_UNITY_SDK:
module.fail_json(msg=missing_required_lib("storops"),
exception=STOROPS_IMP_ERR)
if not HAS_PKG_RESOURCE:
module.fail_json(msg=missing_required_lib("pkg_resources"),
exception=PKG_RESOURCE_IMP_ERR)
if not HAS_URLLIB3:
module.fail_json(msg=missing_required_lib("urllib3"),
exception=URLLIB3_IMP_ERR)
min_ver = '1.2.11'
try:
curr_version = pkg_resources.require("storops")[0].version
except Exception as err:
module.fail_json(msg="Failed to get Storops SDK version - "
"{0}".format(str(err)))
if parse_version(curr_version) < parse_version(min_ver):
module.fail_json(msg="Storops {0} is not supported. "
"Required minimum version is "
"{1}".format(curr_version, min_ver))
def get_unity_management_host_parameters():
"""Provides common access parameters required for the
ansible modules on Unity StorageSystem"""
return dict(
unispherehost=dict(type='str', required=True, no_log=True),
username=dict(type='str', required=True),
password=dict(type='str', required=True, no_log=True),
validate_certs=dict(type='bool', required=False,
aliases=['verifycert'], default=True),
port=dict(type='int', required=False, default=443, no_log=True)
)
def get_unity_unisphere_connection(module_params, application_type=None):
"""Establishes connection with Unity array using storops SDK"""
if HAS_UNITY_SDK:
conn = UnitySystem(host=module_params['unispherehost'],
port=module_params['port'],
verify=module_params['validate_certs'],
username=module_params['username'],
password=module_params['password'],
application_type=application_type)
return conn
def get_logger(module_name, log_file_name='ansible_unity.log',
log_devel=logging.INFO):
"""Intializes and returns the logger object
:param module_name: Name of module to be part of log message
:param log_file_name: Name of file in which the log messages get appended
:param log_devel: Log level
"""
FORMAT = '%(asctime)-15s %(filename)s %(levelname)s : %(message)s'
max_bytes = 5 * 1024 * 1024
logging.basicConfig(filename=log_file_name, format=FORMAT)
LOG = logging.getLogger(module_name)
LOG.setLevel(log_devel)
handler = CustomRotatingFileHandler(log_file_name,
maxBytes=max_bytes,
backupCount=5)
formatter = logging.Formatter(FORMAT)
handler.setFormatter(formatter)
LOG.addHandler(handler)
LOG.propagate = False
return LOG
KB_IN_BYTES = 1024
MB_IN_BYTES = 1024 * 1024
GB_IN_BYTES = 1024 * 1024 * 1024
TB_IN_BYTES = 1024 * 1024 * 1024 * 1024
def get_size_bytes(size, cap_units):
"""Convert the given size to bytes"""
if size is not None and size > 0:
if cap_units in ('kb', 'KB'):
return size * KB_IN_BYTES
elif cap_units in ('mb', 'MB'):
return size * MB_IN_BYTES
elif cap_units in ('gb', 'GB'):
return size * GB_IN_BYTES
elif cap_units in ('tb', 'TB'):
return size * TB_IN_BYTES
else:
return size
else:
return 0
def convert_size_with_unit(size_bytes):
"""Convert size in byte with actual unit like KB,MB,GB,TB,PB etc."""
if not isinstance(size_bytes, int):
raise ValueError('This method takes Integer type argument only')
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size_bytes, 1024)))
p = math.pow(1024, i)
s = round(size_bytes / p, 2)
return "%s %s" % (s, size_name[i])
def get_size_in_gb(size, cap_units):
"""Convert the given size to size in GB, size is restricted to 2 decimal places"""
size_in_bytes = get_size_bytes(size, cap_units)
size = Decimal(size_in_bytes / GB_IN_BYTES)
size_in_gb = round(size)
return size_in_gb
def is_input_empty(item):
"""Check whether input string is empty"""
if item == "" or item.isspace():
return True
else:
return False
def is_size_negative(size):
"""Check whether size is negative"""
if size and size < 0:
return True
else:
return False
def has_special_char(value):
"""Check whether the string has any special character.
It allows '_' character"""
regex = re.compile(r'[@!#$%^&*()<>?/\|}{~:]')
if regex.search(value) is None:
return False
else:
return True
def is_initiator_valid(value):
"""Validate format of the FC or iSCSI initiator"""
if value.startswith('iqn') or re.match(r"([A-Fa-f0-9]{2}:){15}[A-Fa-f0-9]{2}", value, re.I) is not None:
return True
else:
return False
def is_valid_netmask(netmask):
"""Validates if ip is valid subnet mask"""
if netmask:
regexp = re.compile(r'^((128|192|224|240|248|252|254)\.0\.0\.0)|'
r'(255\.(((0|128|192|224|240|248|252|254)\.0\.0)|'
r'(255\.(((0|128|192|224|240|248|252|254)\.0)|'
r'255\.(0|128|192|224|240|248|252|254)))))$')
if not regexp.search(netmask):
return False
return True

View File

@@ -0,0 +1,629 @@
#!/usr/bin/python
# Copyright: (c) 2022, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Ansible module for managing CIFS server on Unity"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
module: cifsserver
version_added: '1.4.0'
short_description: Manage CIFS server on Unity storage system
description:
- Managing the CIFS server on the Unity storage system includes creating CIFS server, getting CIFS server details
and deleting CIFS server.
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Akash Shendge (@shenda1) <ansible.team@dell.com>
options:
nas_server_name:
description:
- Name of the NAS server on which CIFS server will be hosted.
type: str
nas_server_id:
description:
- ID of the NAS server on which CIFS server will be hosted.
type: str
netbios_name:
description:
- The computer name of the SMB server in Windows network.
type: str
workgroup:
description:
- Standalone SMB server workgroup.
type: str
local_password:
description:
- Standalone SMB server administrator password.
type: str
domain:
description:
- The domain name where the SMB server is registered in Active Directory.
type: str
domain_username:
description:
- Active Directory domain user name.
type: str
domain_password:
description:
- Active Directory domain password.
type: str
cifs_server_name:
description:
- The name of the CIFS server.
type: str
cifs_server_id:
description:
- The ID of the CIFS server.
type: str
interfaces:
description:
- List of file IP interfaces that service CIFS protocol of SMB server.
type: list
elements: str
unjoin_cifs_server_account:
description:
- Keep SMB server account unjoined in Active Directory after deletion.
- C(false) specifies keep SMB server account joined after deletion.
- C(true) specifies unjoin SMB server account from Active Directory before deletion.
type: bool
state:
description:
- Define whether the CIFS server should exist or not.
choices: [absent, present]
required: true
type: str
notes:
- The I(check_mode) is supported.
'''
EXAMPLES = r'''
- name: Create CIFS server belonging to Active Directory
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "test_nas1"
cifs_server_name: "test_cifs"
domain: "ad_domain"
domain_username: "domain_username"
domain_password: "domain_password"
state: "present"
- name: Get CIFS server details using CIFS server ID
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
cifs_server_id: "cifs_37"
state: "present"
- name: Get CIFS server details using NAS server name
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "test_nas1"
state: "present"
- name: Delete CIFS server
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
cifs_server_id: "cifs_37"
unjoin_cifs_server_account: True
domain_username: "domain_username"
domain_password: "domain_password"
state: "absent"
- name: Create standalone CIFS server
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
netbios_name: "ANSIBLE_CIFS"
workgroup: "ansible"
local_password: "Password123!"
nas_server_name: "test_nas1"
state: "present"
- name: Get CIFS server details using netbios name
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
netbios_name: "ANSIBLE_CIFS"
state: "present"
- name: Delete standalone CIFS server
dellemc.unity.cifsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
cifs_server_id: "cifs_40"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: true
cifs_server_details:
description: Details of the CIFS server.
returned: When CIFS server exists
type: dict
contains:
id:
description: Unique identifier of the CIFS server instance.
type: str
name:
description: User-specified name for the SMB server.
type: str
netbios_name:
description: Computer Name of the SMB server in windows network.
type: str
description:
description: Description of the SMB server.
type: str
domain:
description: Domain name where SMB server is registered in Active Directory.
type: str
workgroup:
description: Windows network workgroup for the SMB server.
type: str
is_standalone:
description: Indicates whether the SMB server is standalone.
type: bool
nasServer:
description: Information about the NAS server in the storage system.
type: dict
contains:
UnityNasServer:
description: Information about the NAS server in the storage system.
type: dict
contains:
id:
description: Unique identifier of the NAS server instance.
type: str
file_interfaces:
description: The file interfaces associated with the NAS server.
type: dict
contains:
UnityFileInterfaceList:
description: List of file interfaces associated with the NAS server.
type: list
contains:
UnityFileInterface:
description: Details of file interface associated with the NAS server.
type: dict
contains:
id:
description: Unique identifier of the file interface.
type: str
smb_multi_channel_supported:
description: Indicates whether the SMB 3.0+ multichannel feature is supported.
type: bool
smb_protocol_versions:
description: Supported SMB protocols, such as 1.0, 2.0, 2.1, 3.0, and so on.
type: list
smbca_supported:
description: Indicates whether the SMB server supports continuous availability.
type: bool
sample: {
"description": null,
"domain": "xxx.xxx.xxx.com",
"existed": true,
"file_interfaces": {
"UnityFileInterfaceList": [
{
"UnityFileInterface": {
"hash": -9223363258905013637,
"id": "if_43"
}
}
]
},
"hash": -9223363258905010379,
"health": {
"UnityHealth": {
"hash": 8777949765559
}
},
"id": "cifs_40",
"is_standalone": false,
"last_used_organizational_unit": "ou=Computers,ou=Dell NAS servers",
"name": "ansible_cifs",
"nas_server": {
"UnityNasServer": {
"hash": 8777949765531,
"id": "nas_18"
}
},
"netbios_name": "ANSIBLE_CIFS",
"smb_multi_channel_supported": true,
"smb_protocol_versions": [
"1.0",
"2.0",
"2.1",
"3.0"
],
"smbca_supported": true,
"workgroup": null
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell import utils
LOG = utils.get_logger('cifsserver')
application_type = "Ansible/1.5.0"
class CIFSServer(object):
"""Class with CIFS server operations"""
def __init__(self):
"""Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_cifs_server_parameters())
mutually_exclusive = [['nas_server_name', 'nas_server_id'], ['cifs_server_id', 'cifs_server_name'],
['cifs_server_id', 'netbios_name']]
required_one_of = [['cifs_server_id', 'cifs_server_name', 'netbios_name', 'nas_server_name', 'nas_server_id']]
# initialize the Ansible module
self.module = AnsibleModule(
argument_spec=self.module_params,
supports_check_mode=True,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of
)
utils.ensure_required_libs(self.module)
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
LOG.info('Check Mode Flag %s', self.module.check_mode)
def get_details(self, cifs_server_id=None, cifs_server_name=None, netbios_name=None, nas_server_id=None):
"""Get CIFS server details.
:param: cifs_server_id: The ID of the CIFS server
:param: cifs_server_name: The name of the CIFS server
:param: netbios_name: Name of the SMB server in windows network
:param: nas_server_id: The ID of the NAS server
:return: Dict containing CIFS server details if exists
"""
LOG.info("Getting CIFS server details")
id_or_name = get_id_name(cifs_server_id, cifs_server_name, netbios_name, nas_server_id)
try:
if cifs_server_id:
cifs_server_details = self.unity_conn.get_cifs_server(_id=cifs_server_id)
return process_response(cifs_server_details)
if cifs_server_name:
cifs_server_details = self.unity_conn.get_cifs_server(name=cifs_server_name)
return process_response(cifs_server_details)
if netbios_name:
cifs_server_details = self.unity_conn.get_cifs_server(netbios_name=netbios_name)
if len(cifs_server_details) > 0:
return process_dict(cifs_server_details._get_properties())
if nas_server_id:
cifs_server_details = self.unity_conn.get_cifs_server(nas_server=nas_server_id)
if len(cifs_server_details) > 0:
return process_dict(cifs_server_details._get_properties())
return None
except utils.HttpError as e:
if e.http_status == 401:
msg = "Failed to get CIFS server: %s due to incorrect " \
"username/password error: %s" % (id_or_name, str(e))
else:
msg = "Failed to get CIFS server: %s with error: %s" % (id_or_name, str(e))
except utils.UnityResourceNotFoundError:
msg = "CIFS server with ID %s not found" % cifs_server_id
LOG.info(msg)
return None
except utils.StoropsConnectTimeoutError as e:
msg = "Failed to get CIFS server: %s with error: %s. Please check unispherehost IP: %s" % (
id_or_name, str(e), self.module.params['unispherehost'])
except Exception as e:
msg = "Failed to get details of CIFS server: %s with error: %s" % (id_or_name, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def get_cifs_server_instance(self, cifs_server_id):
"""Get CIFS server instance.
:param: cifs_server_id: The ID of the CIFS server
:return: Return CIFS server instance if exists
"""
try:
cifs_server_obj = utils.UnityCifsServer.get(cli=self.unity_conn._cli, _id=cifs_server_id)
return cifs_server_obj
except Exception as e:
error_msg = "Failed to get the CIFS server %s instance" \
" with error %s" % (cifs_server_id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def delete_cifs_server(self, cifs_server_id, skip_unjoin=None, domain_username=None, domain_password=None):
"""Delete CIFS server.
:param: cifs_server_id: The ID of the CIFS server
:param: skip_unjoin: Flag indicating whether to unjoin SMB server account from AD before deletion
:param: domain_username: The domain username
:param: domain_password: The domain password
:return: Return True if CIFS server is deleted
"""
LOG.info("Deleting CIFS server")
try:
if not self.module.check_mode:
cifs_obj = self.get_cifs_server_instance(cifs_server_id=cifs_server_id)
cifs_obj.delete(skip_domain_unjoin=skip_unjoin, username=domain_username, password=domain_password)
return True
except Exception as e:
msg = "Failed to delete CIFS server: %s with error: %s" % (cifs_server_id, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def get_nas_server_id(self, nas_server_name):
"""Get NAS server ID.
:param: nas_server_name: The name of NAS server
:return: Return NAS server ID if exists
"""
LOG.info("Getting NAS server ID")
try:
obj_nas = self.unity_conn.get_nas_server(name=nas_server_name)
return obj_nas.get_id()
except Exception as e:
msg = "Failed to get details of NAS server: %s with error: %s" % (nas_server_name, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def is_modify_interfaces(self, cifs_server_details):
"""Check if modification is required in existing interfaces
:param: cifs_server_details: CIFS server details
:return: Flag indicating if modification is required
"""
existing_interfaces = []
if cifs_server_details['file_interfaces']['UnityFileInterfaceList']:
for interface in cifs_server_details['file_interfaces']['UnityFileInterfaceList']:
existing_interfaces.append(interface['UnityFileInterface']['id'])
for interface in self.module.params['interfaces']:
if interface not in existing_interfaces:
return True
return False
def is_modification_required(self, cifs_server_details):
"""Check if modification is required in existing CIFS server
:param: cifs_server_details: CIFS server details
:return: Flag indicating if modification is required
"""
LOG.info("Checking if any modification is required")
param_list = ['netbios_name', 'workgroup']
for param in param_list:
if self.module.params[param] is not None and cifs_server_details[param] is not None and \
self.module.params[param].upper() != cifs_server_details[param]:
return True
# Check for domain
if self.module.params['domain'] is not None and cifs_server_details['domain'] is not None and \
self.module.params['domain'] != cifs_server_details['domain']:
return True
# Check file interfaces
if self.module.params['interfaces'] is not None:
return self.is_modify_interfaces(cifs_server_details)
return False
def create_cifs_server(self, nas_server_id, interfaces=None, netbios_name=None, cifs_server_name=None, domain=None,
domain_username=None, domain_password=None, workgroup=None, local_password=None):
"""Create CIFS server.
:param: nas_server_id: The ID of NAS server
:param: interfaces: List of file interfaces
:param: netbios_name: Name of the SMB server in windows network
:param: cifs_server_name: Name of the CIFS server
:param: domain: The domain name where the SMB server is registered in Active Directory
:param: domain_username: The domain username
:param: domain_password: The domain password
:param: workgroup: Standalone SMB server workgroup
:param: local_password: Standalone SMB server admin password
:return: Return True if CIFS server is created
"""
LOG.info("Creating CIFS server")
try:
if not self.module.check_mode:
utils.UnityCifsServer.create(cli=self.unity_conn._cli, nas_server=nas_server_id, interfaces=interfaces,
netbios_name=netbios_name, name=cifs_server_name, domain=domain,
domain_username=domain_username, domain_password=domain_password,
workgroup=workgroup, local_password=local_password)
return True
except Exception as e:
msg = "Failed to create CIFS server with error: %s" % (str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def validate_params(self):
"""Validate the parameters
"""
param_list = ['nas_server_id', 'nas_server_name', 'domain', 'cifs_server_id', 'cifs_server_name',
'local_password', 'netbios_name', 'workgroup', 'domain_username', 'domain_password']
msg = "Please provide valid {0}"
for param in param_list:
if self.module.params[param] is not None and len(self.module.params[param].strip()) == 0:
errmsg = msg.format(param)
self.module.fail_json(msg=errmsg)
def perform_module_operation(self):
"""
Perform different actions on CIFS server module based on parameters
passed in the playbook
"""
cifs_server_id = self.module.params['cifs_server_id']
cifs_server_name = self.module.params['cifs_server_name']
nas_server_id = self.module.params['nas_server_id']
nas_server_name = self.module.params['nas_server_name']
netbios_name = self.module.params['netbios_name']
workgroup = self.module.params['workgroup']
local_password = self.module.params['local_password']
domain = self.module.params['domain']
domain_username = self.module.params['domain_username']
domain_password = self.module.params['domain_password']
interfaces = self.module.params['interfaces']
unjoin_cifs_server_account = self.module.params['unjoin_cifs_server_account']
state = self.module.params['state']
# result is a dictionary that contains changed status and CIFS server details
result = dict(
changed=False,
cifs_server_details={}
)
# Validate the parameters
self.validate_params()
if nas_server_name is not None:
nas_server_id = self.get_nas_server_id(nas_server_name)
cifs_server_details = self.get_details(cifs_server_id=cifs_server_id, cifs_server_name=cifs_server_name,
netbios_name=netbios_name, nas_server_id=nas_server_id)
# Check if modification is required
if cifs_server_details:
if cifs_server_id is None:
cifs_server_id = cifs_server_details['id']
modify_flag = self.is_modification_required(cifs_server_details)
if modify_flag:
self.module.fail_json(msg="Modification is not supported through Ansible module")
if not cifs_server_details and state == 'present':
if not nas_server_id:
self.module.fail_json(msg="Please provide nas server id/name to create CIFS server.")
if any([netbios_name, workgroup, local_password]):
if not all([netbios_name, workgroup, local_password]):
msg = "netbios_name, workgroup and local_password" \
" are required to create standalone CIFS server."
LOG.error(msg)
self.module.fail_json(msg=msg)
result['changed'] = self.create_cifs_server(nas_server_id, interfaces, netbios_name,
cifs_server_name, domain, domain_username, domain_password,
workgroup, local_password)
if state == 'absent' and cifs_server_details:
skip_unjoin = None
if unjoin_cifs_server_account is not None:
skip_unjoin = not unjoin_cifs_server_account
result['changed'] = self.delete_cifs_server(cifs_server_id, skip_unjoin, domain_username,
domain_password)
if state == 'present':
result['cifs_server_details'] = self.get_details(cifs_server_id=cifs_server_id,
cifs_server_name=cifs_server_name,
netbios_name=netbios_name,
nas_server_id=nas_server_id)
LOG.info("Process Dict: %s", result['cifs_server_details'])
self.module.exit_json(**result)
def get_id_name(cifs_server_id=None, cifs_server_name=None, netbios_name=None, nas_server_id=None):
"""Get the id_or_name.
:param: cifs_server_id: The ID of CIFS server
:param: cifs_server_name: The name of CIFS server
:param: netbios_name: Name of the SMB server in windows network
:param: nas_server_id: The ID of NAS server
:return: Return id_or_name
"""
if cifs_server_id:
id_or_name = cifs_server_id
elif cifs_server_name:
id_or_name = cifs_server_name
elif netbios_name:
id_or_name = netbios_name
else:
id_or_name = nas_server_id
return id_or_name
def process_response(cifs_server_details):
"""Process CIFS server details.
:param: cifs_server_details: Dict containing CIFS server details
:return: Processed dict containing CIFS server details
"""
if cifs_server_details.existed:
return cifs_server_details._get_properties()
def process_dict(cifs_server_details):
"""Process CIFS server details.
:param: cifs_server_details: Dict containing CIFS server details
:return: Processed dict containing CIFS server details
"""
param_list = ['description', 'domain', 'file_interfaces', 'health', 'id', 'is_standalone', 'name', 'nas_server'
'netbios_name', 'smb_multi_channel_supported', 'smb_protocol_versions', 'smbca_supported',
'workgroup', 'netbios_name']
for param in param_list:
if param in cifs_server_details:
cifs_server_details[param] = cifs_server_details[param][0]
return cifs_server_details
def get_cifs_server_parameters():
"""This method provide parameters required for the ansible
CIFS server module on Unity"""
return dict(
cifs_server_id=dict(), cifs_server_name=dict(),
netbios_name=dict(), workgroup=dict(),
local_password=dict(no_log=True), domain=dict(),
domain_username=dict(), domain_password=dict(no_log=True),
nas_server_name=dict(), nas_server_id=dict(),
interfaces=dict(type='list', elements='str'),
unjoin_cifs_server_account=dict(type='bool'),
state=dict(required=True, type='str', choices=['present', 'absent']),
)
def main():
"""Create Unity CIFS server object and perform action on it
based on user input from playbook"""
obj = CIFSServer()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,772 @@
#!/usr/bin/python
# Copyright: (c) 2020, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
""" Ansible module for managing Filesystem Snapshots on Unity"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r'''
---
module: filesystem_snapshot
short_description: Manage filesystem snapshot on the Unity storage system
description:
- Managing Filesystem Snapshot on the Unity storage system includes
create filesystem snapshot, get filesystem snapshot, modify filesystem
snapshot and delete filesystem snapshot.
version_added: '1.1.0'
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Rajshree Khare (@kharer5) <ansible.team@dell.com>
options:
snapshot_name:
description:
- The name of the filesystem snapshot.
- Mandatory parameter for creating a filesystem snapshot.
- For all other operations either I(snapshot_name) or I(snapshot_id)
is required.
type: str
snapshot_id:
description:
- During creation snapshot_id is auto generated.
- For all other operations either I(snapshot_id) or I(snapshot_name)
is required.
type: str
filesystem_name:
description:
- The name of the Filesystem for which snapshot is created.
- For creation of filesystem snapshot either I(filesystem_name) or
I(filesystem_id) is required.
- Not required for other operations.
type: str
filesystem_id:
description:
- The ID of the Filesystem for which snapshot is created.
- For creation of filesystem snapshot either I(filesystem_id) or
I(filesystem_name) is required.
- Not required for other operations.
type: str
nas_server_name:
description:
- The name of the NAS server in which the Filesystem is created.
- For creation of filesystem snapshot either I(nas_server_name) or
I(nas_server_id) is required.
- Not required for other operations.
type: str
nas_server_id:
description:
- The ID of the NAS server in which the Filesystem is created.
- For creation of filesystem snapshot either I(filesystem_id) or
I(filesystem_name) is required.
- Not required for other operations.
type: str
auto_delete:
description:
- This option specifies whether or not the filesystem snapshot will be
automatically deleted.
- If set to C(true), the filesystem snapshot will expire based on the pool
auto deletion policy.
- If set to C(false), the filesystem snapshot will not be auto deleted
based on the pool auto deletion policy.
- Option I(auto_delete) can not be set to C(true), if I(expiry_time) is specified.
- If during creation neither I(auto_delete) nor I(expiry_time) is mentioned
then the filesystem snapshot will be created keeping I(auto_delete) as
C(true).
- Once the I(expiry_time) is set, then the filesystem snapshot cannot be
assigned to the auto delete policy.
type: bool
expiry_time:
description:
- This option is for specifying the date and time after which the
filesystem snapshot will expire.
- The time is to be mentioned in UTC timezone.
- The format is "MM/DD/YYYY HH:MM". Year must be in 4 digits.
type: str
description:
description:
- The additional information about the filesystem snapshot can be
provided using this option.
- The description can be removed by passing an empty string.
type: str
fs_access_type:
description:
- Access type of the filesystem snapshot.
- Required only during creation of filesystem snapshot.
- If not given, snapshot's access type will be C(Checkpoint).
type: str
choices: ['Checkpoint' , 'Protocol']
state:
description:
- The state option is used to mention the existence of the filesystem
snapshot.
type: str
required: true
choices: ['absent', 'present']
notes:
- Filesystem snapshot cannot be deleted, if it has nfs or smb share.
- The I(check_mode) is not supported.
'''
EXAMPLES = r'''
- name: Create Filesystem Snapshot
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "ansible_test_FS_snap"
filesystem_name: "ansible_test_FS"
nas_server_name: "lglad069"
description: "Created using playbook"
auto_delete: True
fs_access_type: "Protocol"
state: "present"
- name: Create Filesystem Snapshot with expiry time
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "ansible_test_FS_snap_1"
filesystem_name: "ansible_test_FS_1"
nas_server_name: "lglad069"
description: "Created using playbook"
expiry_time: "04/15/2021 2:30"
fs_access_type: "Protocol"
state: "present"
- name: Get Filesystem Snapshot Details using Name
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "ansible_test_FS_snap"
state: "present"
- name: Get Filesystem Snapshot Details using ID
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_id: "10008000403"
state: "present"
- name: Update Filesystem Snapshot attributes
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "ansible_test_FS_snap"
description: "Description updated"
auto_delete: False
expiry_time: "04/15/2021 5:30"
state: "present"
- name: Update Filesystem Snapshot attributes using ID
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_id: "10008000403"
expiry_time: "04/18/2021 8:30"
state: "present"
- name: Delete Filesystem Snapshot using Name
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "ansible_test_FS_snap"
state: "absent"
- name: Delete Filesystem Snapshot using ID
dellemc.unity.filesystem_snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_id: "10008000403"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: true
filesystem_snapshot_details:
description: Details of the filesystem snapshot.
returned: When filesystem snapshot exists
type: dict
contains:
access_type:
description: Access type of filesystem snapshot.
type: str
attached_wwn:
description: Attached WWN details.
type: str
creation_time:
description: Creation time of filesystem snapshot.
type: str
creator_schedule:
description: Creator schedule of filesystem snapshot.
type: str
creator_type:
description: Creator type for filesystem snapshot.
type: str
creator_user:
description: Creator user for filesystem snapshot.
type: str
description:
description: Description of the filesystem snapshot.
type: str
expiration_time:
description: Date and time after which the filesystem snapshot
will expire.
type: str
is_auto_delete:
description: Is the filesystem snapshot is auto deleted or not.
type: bool
id:
description: Unique identifier of the filesystem snapshot
instance.
type: str
name:
description: The name of the filesystem snapshot.
type: str
size:
description: Size of the filesystem snapshot.
type: int
filesystem_name:
description: Name of the filesystem for which the snapshot exists.
type: str
filesystem_id:
description: Id of the filesystem for which the snapshot exists.
type: str
nas_server_name:
description: Name of the NAS server on which filesystem exists.
type: str
nas_server_id:
description: Id of the NAS server on which filesystem exists.
type: str
sample: {
"access_type": "FilesystemSnapAccessTypeEnum.CHECKPOINT",
"attached_wwn": null,
"creation_time": "2022-10-21 04:42:53.951000+00:00",
"creator_schedule": null,
"creator_type": "SnapCreatorTypeEnum.USER_CUSTOM",
"creator_user": {
"id": "user_admin"
},
"description": "Created using playbook",
"existed": true,
"expiration_time": null,
"filesystem_id": "fs_137",
"filesystem_name": "test",
"hash": 8739894572587,
"host_access": null,
"id": "171798721695",
"io_limit_policy": null,
"is_auto_delete": true,
"is_modifiable": false,
"is_modified": false,
"is_read_only": true,
"is_system_snap": false,
"last_writable_time": null,
"lun": null,
"name": "test_FS_snap_1",
"nas_server_id": "nas_1",
"nas_server_name": "lglad072",
"parent_snap": null,
"size": 107374182400,
"snap_group": null,
"state": "SnapStateEnum.READY"
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
from datetime import datetime
LOG = utils.get_logger('filesystem_snapshot')
application_type = "Ansible/1.5.0"
class FilesystemSnapshot(object):
"""Class with Filesystem Snapshot operations"""
def __init__(self):
""" Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_snapshot_parameters())
mutually_exclusive = [['snapshot_name', 'snapshot_id'],
['filesystem_name', 'filesystem_id'],
['nas_server_name', 'nas_server_id']]
required_one_of = [['snapshot_name', 'snapshot_id']]
# initialize the ansible module
self.module = AnsibleModule(argument_spec=self.module_params,
supports_check_mode=False,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of)
utils.ensure_required_libs(self.module)
# result is a dictionary that contains changed status and
# filesystem snapshot details
self.result = {"changed": False,
'filesystem_snapshot_details': {}}
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
self.snap_obj = utils.snap.UnitySnap(self.unity_conn)
LOG.info('Connection established with the Unity Array')
def validate_expiry_time(self, expiry_time):
"""Validates the specified expiry_time"""
try:
datetime.strptime(expiry_time, '%m/%d/%Y %H:%M')
except ValueError:
error_msg = ("expiry_time: %s, not in MM/DD/YYYY HH:MM format." %
expiry_time)
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def to_update(self, fs_snapshot, description=None, auto_del=None,
expiry_time=None, fs_access_type=None):
"""Determines whether to update the snapshot or not"""
snap_modify_dict = dict()
if fs_access_type and fs_access_type != fs_snapshot.access_type:
error_message = "Modification of access type is not allowed."
LOG.error(error_message)
self.module.fail_json(msg=error_message)
if expiry_time:
# If the snapshot has is_auto_delete True,
# Check if auto_delete in the input is either None or True
if fs_snapshot.is_auto_delete and (auto_del is None or auto_del):
self.module.fail_json(msg="expiry_time can be assigned when"
" auto delete is False.")
if auto_del is not None:
if fs_snapshot.expiration_time:
error_msg = "expiry_time for filesystem snapshot is set." \
" Once it is set then snapshot cannot" \
" be assigned to auto_delete policy."
self.module.fail_json(msg=error_msg)
if auto_del != fs_snapshot.is_auto_delete:
snap_modify_dict['is_auto_delete'] = auto_del
if description is not None and description != fs_snapshot.description:
snap_modify_dict['description'] = description
if to_update_expiry_time(fs_snapshot, expiry_time):
snap_modify_dict['expiry_time'] = expiry_time
LOG.info("Snapshot modification details: %s", snap_modify_dict)
return snap_modify_dict
def update_filesystem_snapshot(self, fs_snapshot, snap_modify_dict):
try:
duration = None
if 'expiry_time' in snap_modify_dict \
and snap_modify_dict['expiry_time']:
duration = convert_timestamp_to_sec(
snap_modify_dict['expiry_time'],
self.unity_conn.system_time)
if duration and duration <= 0:
self.module.fail_json(msg="expiry_time should be after"
" the current system time.")
if 'is_auto_delete' in snap_modify_dict \
and snap_modify_dict['is_auto_delete'] is not None:
auto_delete = snap_modify_dict['is_auto_delete']
else:
auto_delete = None
if 'description' in snap_modify_dict \
and (snap_modify_dict['description']
or len(snap_modify_dict['description']) == 0):
description = snap_modify_dict['description']
else:
description = None
fs_snapshot.modify(retentionDuration=duration,
isAutoDelete=auto_delete,
description=description)
fs_snapshot.update()
except Exception as e:
error_msg = "Failed to modify filesystem snapshot" \
" [name: %s , id: %s] with error %s."\
% (fs_snapshot.name, fs_snapshot.id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def create_filesystem_snapshot(self, snap_name, storage_id,
description=None, auto_del=None,
expiry_time=None, fs_access_type=None):
try:
duration = None
if expiry_time:
duration = convert_timestamp_to_sec(
expiry_time, self.unity_conn.system_time)
if duration <= 0:
self.module.fail_json(msg="expiry_time should be after"
" the current system time.")
fs_snapshot = self.snap_obj.create(
cli=self.unity_conn._cli, storage_resource=storage_id,
name=snap_name, description=description,
is_auto_delete=auto_del, retention_duration=duration,
fs_access_type=fs_access_type)
return fs_snapshot
except Exception as e:
error_msg = "Failed to create filesystem snapshot" \
" %s with error %s" % (snap_name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def is_snap_has_share(self, fs_snap):
try:
obj = self.unity_conn.get_nfs_share(snap=fs_snap) or \
self.unity_conn.get_cifs_share(snap=fs_snap)
if len(obj) > 0:
LOG.info("Snapshot has %s nfs/smb share/s", len(obj))
return True
except Exception as e:
msg = "Failed to get nfs/smb share from filesystem snapshot. " \
"error: %s" % str(e)
LOG.error(msg)
self.module.fail_json(msg=msg)
return False
def delete_fs_snapshot(self, fs_snapshot):
try:
# Checking whether nfs/smb share created from fs_snapshot
if self.is_snap_has_share(fs_snapshot):
msg = "Filesystem snapshot cannot be deleted because it has " \
"nfs/smb share"
LOG.error(msg)
self.module.fail_json(msg=msg)
fs_snapshot.delete()
return None
except Exception as e:
error_msg = "Failed to delete filesystem snapshot" \
" [name: %s, id: %s] with error %s." \
% (fs_snapshot.name, fs_snapshot.id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_fs_snapshot_obj(self, name=None, id=None):
fs_snapshot = id if id else name
msg = "Failed to get details of filesystem snapshot %s with error %s."
try:
fs_snap_obj = self.unity_conn.get_snap(name=name, _id=id)
if fs_snap_obj and fs_snap_obj.existed:
LOG.info("Successfully got the filesystem snapshot object "
"%s.", fs_snap_obj)
else:
fs_snap_obj = None
return fs_snap_obj
except utils.HttpError as e:
if e.http_status == 401:
cred_err = ("Incorrect username or password , %s" % e.message)
self.module.fail_json(msg=cred_err)
else:
err_msg = msg % (fs_snapshot, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
except utils.UnityResourceNotFoundError as e:
err_msg = msg % (fs_snapshot, str(e))
LOG.error(err_msg)
return None
except Exception as e:
err_msg = msg % (fs_snapshot, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def get_filesystem_obj(self, nas_server=None, name=None, id=None):
filesystem = id if id else name
try:
obj_fs = None
if name:
if not nas_server:
err_msg = "NAS Server is required to get the FileSystem."
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
obj_fs = self.unity_conn.get_filesystem(name=name,
nas_server=nas_server)
if obj_fs and obj_fs.existed:
LOG.info("Successfully got the filesystem object %s.",
obj_fs)
return obj_fs
if id:
if nas_server:
obj_fs = self.unity_conn\
.get_filesystem(id=id, nas_server=nas_server)
else:
obj_fs = self.unity_conn.get_filesystem(id=id)
if obj_fs and obj_fs.existed:
LOG.info("Successfully got the filesystem object %s.",
obj_fs)
return obj_fs
except Exception as e:
error_msg = "Failed to get filesystem %s with error %s."\
% (filesystem, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_nas_server_obj(self, name=None, id=None):
nas_server = id if id else name
error_msg = ("Failed to get NAS server %s." % nas_server)
try:
obj_nas = self.unity_conn.get_nas_server(_id=id, name=name)
if name and obj_nas.existed:
LOG.info("Successfully got the NAS server object %s.",
obj_nas)
return obj_nas
elif id and obj_nas.existed:
LOG.info("Successfully got the NAS server object %s.",
obj_nas)
return obj_nas
else:
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
except Exception as e:
error_msg = "Failed to get NAS server %s with error %s."\
% (nas_server, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def create_fs_snapshot_details_dict(self, fs_snapshot):
""" Add name and id of storage resource to filesystem snapshot
details """
snapshot_dict = fs_snapshot._get_properties()
del snapshot_dict['storage_resource']
snapshot_dict['filesystem_name'] = fs_snapshot.storage_resource.name
snapshot_dict['filesystem_id'] = fs_snapshot.storage_resource.filesystem.id
obj_fs = self.unity_conn.\
get_filesystem(id=fs_snapshot.storage_resource.filesystem.id)
if obj_fs and obj_fs.existed:
snapshot_dict['nas_server_name'] = obj_fs.nas_server[0].name
snapshot_dict['nas_server_id'] = obj_fs.nas_server[0].id
return snapshot_dict
def perform_module_operation(self):
"""
Perform different actions on snapshot module based on parameters
chosen in playbook
"""
snapshot_name = self.module.params['snapshot_name']
snapshot_id = self.module.params['snapshot_id']
filesystem_name = self.module.params['filesystem_name']
filesystem_id = self.module.params['filesystem_id']
nas_server_name = self.module.params['nas_server_name']
nas_server_id = self.module.params['nas_server_id']
auto_delete = self.module.params['auto_delete']
expiry_time = self.module.params['expiry_time']
description = self.module.params['description']
fs_access_type = self.module.params['fs_access_type']
state = self.module.params['state']
nas_server_resource = None
filesystem_resource = None
changed = False
LOG.info("Getting Filesystem Snapshot details.")
fs_snapshot = self.get_fs_snapshot_obj(name=snapshot_name,
id=snapshot_id)
msg = "Filesystem Snapshot details: %s." % str(fs_snapshot)
LOG.info(msg)
# Get NAS server Object
if nas_server_name is not None:
if nas_server_name == "" or nas_server_name.isspace():
self.module.fail_json(msg="Invalid nas_server_name given,"
" Please provide a valid name.")
nas_server_resource = self\
.get_nas_server_obj(name=nas_server_name)
elif nas_server_id is not None:
if nas_server_id == "" or nas_server_id.isspace():
self.module.fail_json(msg="Invalid nas_server_id given,"
" Please provide a valid ID.")
nas_server_resource = self.get_nas_server_obj(id=nas_server_id)
# Get Filesystem Object
if filesystem_name is not None:
if filesystem_name == "" or filesystem_name.isspace():
self.module.fail_json(msg="Invalid filesystem_name given,"
" Please provide a valid name.")
filesystem_resource = self\
.get_filesystem_obj(nas_server=nas_server_resource,
name=filesystem_name)
fs_res_id = filesystem_resource.storage_resource.id
elif filesystem_id is not None:
if filesystem_id == "" or filesystem_id.isspace():
self.module.fail_json(msg="Invalid filesystem_id given,"
" Please provide a valid ID.")
filesystem_resource = self\
.get_filesystem_obj(id=filesystem_id)
fs_res_id = filesystem_resource[0].storage_resource.id
# Check for error, if user tries to create a filesystem snapshot
# with the same name.
if fs_snapshot and filesystem_resource and \
(fs_snapshot.storage_resource.id
!= fs_res_id):
self.module.fail_json(
msg="Snapshot %s is of %s storage resource. Cannot create new"
" snapshot with same name for %s storage resource."
% (fs_snapshot.name, fs_snapshot.storage_resource.name,
filesystem_resource.storage_resource.name))
# check for valid expiry_time
if expiry_time is not None and \
(expiry_time == "" or expiry_time.isspace()):
self.module.fail_json(msg="Please provide valid expiry_time,"
" empty expiry_time given.")
if expiry_time:
self.validate_expiry_time(expiry_time)
# Check if in input auto_delete is True and expiry_time is not None
if expiry_time and auto_delete:
error_msg = "Cannot set expiry_time if auto_delete given as True."
LOG.info(error_msg)
self.module.fail_json(msg=error_msg)
# check for fs_access_type
if fs_access_type is not None:
if (fs_access_type == "" or fs_access_type.isspace()):
self.module.fail_json(msg="Please provide valid "
"fs_access_type, empty "
"fs_access_type given.")
if fs_access_type == "Checkpoint":
fs_access_type = utils.FilesystemSnapAccessTypeEnum.CHECKPOINT
elif fs_access_type == "Protocol":
fs_access_type = utils.FilesystemSnapAccessTypeEnum.PROTOCOL
# Check whether to modify the filesystem snapshot or not
fs_snap_modify_dict = dict()
if state == 'present' and fs_snapshot:
fs_snap_modify_dict = self\
.to_update(fs_snapshot, description=description,
auto_del=auto_delete, expiry_time=expiry_time,
fs_access_type=fs_access_type)
# Create Filesystem Snapshot
if not fs_snapshot and state == "present":
LOG.info("Creating the filesystem snapshot.")
if snapshot_id:
self.module.fail_json(msg="Creation of Filesystem Snapshot is"
" allowed using snapshot_name only,"
" snapshot_id given.")
if snapshot_name == "" or snapshot_name.isspace():
self.module.fail_json(msg="snapshot_name is required for"
" creation of the filesystem"
" snapshot, empty snapshot_name"
" given.")
if not filesystem_resource:
self.module.fail_json(msg="filesystem_name or filesystem_id"
" required to create a snapshot.")
fs_snapshot = self.create_filesystem_snapshot(
snapshot_name,
fs_res_id,
description,
auto_delete,
expiry_time,
fs_access_type)
changed = True
# Update the Snapshot
if fs_snapshot and state == "present" and fs_snap_modify_dict:
LOG.info("Updating the Filesystem Snapshot.")
self.update_filesystem_snapshot(fs_snapshot, fs_snap_modify_dict)
changed = True
# Delete the Filesystem Snapshot
if state == "absent" and fs_snapshot:
fs_snapshot = self.delete_fs_snapshot(fs_snapshot)
changed = True
# Add filesystem snapshot details to the result.
if fs_snapshot:
fs_snapshot.update()
self.result["filesystem_snapshot_details"] = \
self.create_fs_snapshot_details_dict(fs_snapshot)
else:
self.result["filesystem_snapshot_details"] = {}
self.result["changed"] = changed
self.module.exit_json(**self.result)
def to_update_expiry_time(fs_snapshot, expiry_time=None):
""" Check whether to update expiry_time or not"""
if not expiry_time:
return False
if fs_snapshot.expiration_time is None:
return True
if convert_timestamp_to_sec(expiry_time, fs_snapshot.expiration_time)\
!= 0:
return True
return False
def convert_timestamp_to_sec(expiry_time, snap_time):
"""Converts the time difference to seconds"""
snap_time_str = snap_time.strftime('%m/%d/%Y %H:%M')
snap_timestamp = datetime.strptime(snap_time_str, '%m/%d/%Y %H:%M')
expiry_timestamp = datetime.strptime(expiry_time, "%m/%d/%Y %H:%M")
return int((expiry_timestamp - snap_timestamp).total_seconds())
def get_snapshot_parameters():
"""This method provide parameter required for the ansible filesystem
snapshot module on Unity"""
return dict(
snapshot_name=dict(required=False, type='str'),
snapshot_id=dict(required=False, type='str'),
filesystem_name=dict(required=False, type='str'),
filesystem_id=dict(required=False, type='str'),
nas_server_name=dict(required=False, type='str'),
nas_server_id=dict(required=False, type='str'),
auto_delete=dict(required=False, type='bool'),
expiry_time=dict(required=False, type='str'),
description=dict(required=False, type='str'),
fs_access_type=dict(required=False, type='str',
choices=['Checkpoint', 'Protocol']),
state=dict(required=True, type='str', choices=['present', 'absent'])
)
def main():
""" Create Unity Filesystem Snapshot object and perform actions on it
based on user input from playbook"""
obj = FilesystemSnapshot()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,521 @@
#!/usr/bin/python
# Copyright: (c) 2022, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Ansible module for managing Interfaces on Unity"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
module: interface
version_added: '1.4.0'
short_description: Manage Interfaces on Unity storage system
description:
- Managing the Interfaces on the Unity storage system includes adding Interfaces to NAS Server, getting
details of interface and deleting configured interfaces.
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Meenakshi Dembi (@dembim) <ansible.team@dell.com>
options:
nas_server_name:
description:
- Name of the NAS server for which interface will be configured.
type: str
nas_server_id:
description:
- ID of the NAS server for which interface will be configured.
type: str
ethernet_port_name:
description:
- Name of the ethernet port.
type: str
ethernet_port_id:
description:
- ID of the ethernet port.
type: str
role:
description:
- Indicates whether interface is configured as production or backup.
choices: [PRODUCTION, BACKUP]
type: str
interface_ip:
description:
- IP of network interface.
required: true
type: str
netmask:
description:
- Netmask of network interface.
type: str
prefix_length:
description:
- Prefix length is mutually exclusive with I(netmask).
type: int
gateway:
description:
- Gateway of network interface.
type: str
vlan_id:
description:
- Vlan id of the interface.
type: int
state:
description:
- Define whether the interface should exist or not.
choices: [present, absent]
required: true
type: str
notes:
- The I(check_mode) is supported.
- Modify operation for interface is not supported.
'''
EXAMPLES = r'''
- name: Add Interface as Backup to NAS Server
dellemc.unity.interface:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
ethernet_port_name: "SP A 4-Port Card Ethernet Port 0"
role: "BACKUP"
interface_ip: "xx.xx.xx.xx"
netmask: "xx.xx.xx.xx"
gateway: "xx.xx.xx.xx"
vlan_id: 324
state: "present"
- name: Add Interface as Production to NAS Server
dellemc.unity.interface:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
ethernet_port_name: "SP A 4-Port Card Ethernet Port 0"
role: "PRODUCTION"
interface_ip: "xx.xx.xx.xx"
netmask: "xx.xx.xx.xx"
gateway: "xx.xx.xx.xx"
vlan_id: 324
state: "present"
- name: Get interface details
dellemc.unity.interface:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
interface_ip: "xx.xx.xx.xx"
state: "present"
- name: Delete Interface
dellemc.unity.interface:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
interface_ip: "xx.xx.xx.xx"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: true
interface_details:
description: Details of the interface.
returned: When interface is configured for NAS Server.
type: dict
contains:
existed:
description: Indicates if interface exists.
type: bool
gateway:
description: Gateway of network interface.
type: str
id:
description: Unique identifier interface.
type: str
ip_address:
description: IP address of interface.
type: str
ip_port:
description: Port on which network interface is configured.
type: dict
contains:
id:
description: ID of ip_port.
type: str
ip_protocol_version:
description: IP protocol version.
type: str
is_disabled:
description: Indicates whether interface is disabled.
type: bool
is_preferred:
description: Indicates whether interface is preferred.
type: bool
mac_address:
description: Mac address of ip_port.
type: bool
name:
description: System configured name of interface.
type: bool
nas_server:
description: Details of NAS server where interface is configured.
type: dict
contains:
id:
description: ID of NAS Server.
type: str
sample: {
"existed": true,
"gateway": "xx.xx.xx.xx",
"hash": 8785300560421,
"health": {
"UnityHealth": {
"hash": 8785300565468
}
},
"id": "if_69",
"ip_address": "10.10.10.10",
"ip_port": {
"UnityIpPort": {
"hash": 8785300565300,
"id": "spb_ocp_0_eth0"
}
},
"ip_protocol_version": "IpProtocolVersionEnum.IPv4",
"is_disabled": false,
"is_preferred": true,
"mac_address": "0C:48:C6:9F:57:BF",
"name": "36_APM00213404194",
"nas_server": {
"UnityNasServer": {
"hash": 8785300565417,
"id": "nas_10"
}
},
"netmask": "10.10.10.10",
"replication_policy": null,
"role": "FileInterfaceRoleEnum.PRODUCTION",
"source_parameters": null,
"v6_prefix_length": null,
"vlan_id": 324
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
import ipaddress
from ipaddress import ip_network
LOG = utils.get_logger('interface')
application_type = "Ansible/1.5.0"
class Interface(object):
"""Class with Interface operations"""
def __init__(self):
"""Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_interface_parameters())
mutually_exclusive = [['nas_server_name', 'nas_server_id'], ['ethernet_port_id', 'ethernet_port_name'], ['netmask', 'prefix_length']]
required_one_of = [['nas_server_name', 'nas_server_id']]
# initialize the Ansible module
self.module = AnsibleModule(
argument_spec=self.module_params,
supports_check_mode=True,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of
)
utils.ensure_required_libs(self.module)
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
LOG.info('Check Mode Flag %s', self.module.check_mode)
def get_interface_details(self, nas_server_obj):
"""Get interface details.
:param: nas_server_obj: NAS server object.
:return: Returns interface details configured on NAS server.
"""
try:
nas_server_obj_properties = nas_server_obj._get_properties()
if nas_server_obj_properties['file_interface']:
for item in nas_server_obj_properties['file_interface']['UnityFileInterfaceList']:
interface_id = self.unity_conn.get_file_interface(_id=item['UnityFileInterface']['id'])
if interface_id.ip_address == self.module.params['interface_ip']:
return interface_id
return None
except Exception as e:
error_msg = "Getting Interface details failed" \
" with error %s" % (str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_nas_server_obj(self, nas_server_name, nas_server_id):
"""Get NAS server ID.
:param: nas_server_name: The name of NAS server
:param: nas_server_id: ID of NAS server
:return: Return NAS server object if exists
"""
LOG.info("Getting NAS server object")
try:
if nas_server_name:
obj_nas = self.unity_conn.get_nas_server(name=nas_server_name)
return obj_nas
elif nas_server_id:
obj_nas = self.unity_conn.get_nas_server(_id=nas_server_id)
if obj_nas._get_properties()['existed']:
return obj_nas
else:
msg = "NAS server with id %s does not exist" % (nas_server_id)
LOG.error(msg)
self.module.fail_json(msg=msg)
except Exception as e:
msg = "Failed to get details of NAS server with error: %s" % (str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def add_interface(self, nas_server_obj, ethernet_port_id=None, ethernet_port_name=None, role=None, interface_ip=None,
netmask=None, prefix_length=None, gateway=None, vlan_id=None):
"""Adding interface to NAS server.
:param: nas_server_obj: The NAS server object.
:param: ethernet_port_id: ID of ethernet port.
:param: ethernet_port_name: Name of ethernet port.
:param: role: Role of the interface.
:param: interface_ip: IP of interface.
:param: netmask: Netmask for interface.
:param: prefix_length: Prefix length.
:param: gateway: Gateway for interface.
:param: vlan_id: vlan_id for interface.
:return: Return True if interface is configured successfully.
"""
LOG.info("Adding interface to NAS Server")
try:
nas_server_obj_properties = nas_server_obj._get_properties()
if nas_server_obj_properties['file_interface']:
for item in nas_server_obj_properties['file_interface']['UnityFileInterfaceList']:
interface_id = self.unity_conn.get_file_interface(_id=item['UnityFileInterface']['id'])
if interface_id._get_properties()['ip_address'] == self.module.params['interface_ip']:
return False
if role:
role_value = get_role_enum(role)
if ethernet_port_name:
ethernet_port_info = self.unity_conn.get_ethernet_port(name=ethernet_port_name)
ethernet_port_id = ethernet_port_info.id
if not self.module.check_mode:
utils.UnityFileInterface.create(cli=self.unity_conn._cli, nas_server=nas_server_obj.get_id(), ip_port=ethernet_port_id,
role=role_value, ip=interface_ip, netmask=netmask, v6_prefix_length=prefix_length,
gateway=gateway, vlan_id=vlan_id)
return True
except Exception as e:
msg = "Failed to add interface to NAS Server with error: %s" % (str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def is_modification_required(self, interface_details):
"""Check if modification is required in existing interface/s configured for NAS Server
:param: interface_details: Existing interface details
:return: True if modification is required
"""
key_list = ['vlan_id', 'gateway', 'netmask']
for item in key_list:
if self.module.params[item] and self.module.params[item] != interface_details[item]:
return True
return False
def delete_interface(self, interface_obj):
"""Delete NFS server.
:param: interface_obj: Interface object.
:return: Return True if interface is deleted.
"""
LOG.info("Deleting interface")
try:
if not self.module.check_mode:
interface_obj.delete()
return True
except Exception as e:
msg = "Failed to delete interface with error: %s" % (str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def validate_input_params(self):
"""Validates input parameters"""
param_list = ["nas_server_id", "nas_server_name", "ethernet_port_name", "ethernet_port_id", "role", "interface_ip",
"netmask", "gateway"]
for param in param_list:
msg = "Please provide valid value for: %s" % param
if self.module.params[param] is not None and len(self.module.params[param].strip()) == 0:
errmsg = msg.format(param)
self.module.fail_json(msg=errmsg)
if self.module.params['vlan_id'] is not None:
if self.module.params['vlan_id'] <= 3 or self.module.params['vlan_id'] >= 4094:
self.module.fail_json(msg='vlan_id should be in the range of 3 to 4094')
if self.module.params['interface_ip'] and \
not is_valid_ip(self.module.params['interface_ip']):
self.module.fail_json(msg='The value for interface ip is invalid')
if self.module.params['gateway'] and \
not is_valid_ip(self.module.params['gateway']):
self.module.fail_json(msg='The value for gateway is invalid')
if self.module.params['netmask'] and not \
utils.is_valid_netmask(self.module.params['netmask']):
self.module.fail_json(msg='Invalid IPV4 address specified for netmask')
if self.module.params['interface_ip'] and (get_ip_version(self.module.params['interface_ip']) == 6):
self.module.fail_json(msg='IPv6 format is not supported')
def validate_create_params(self):
"""Validates input parameters for adding interface"""
if self.module.params['role'] is None:
self.module.fail_json(msg='Role is a mandatory parameter for adding interface to NAS Server.')
if self.module.params['ethernet_port_name'] is None and self.module.params['ethernet_port_id'] is None:
self.module.fail_json(msg='ethernet_port_name/ethernet_port_id is mandatory parameter for adding interface to NAS Server.')
def perform_module_operation(self):
"""
Perform different actions on Interface module based on parameters
passed in the playbook
"""
nas_server_id = self.module.params['nas_server_id']
nas_server_name = self.module.params['nas_server_name']
ethernet_port_name = self.module.params['ethernet_port_name']
ethernet_port_id = self.module.params['ethernet_port_id']
role = self.module.params['role']
interface_ip = self.module.params['interface_ip']
netmask = self.module.params['netmask']
prefix_length = self.module.params['prefix_length']
gateway = self.module.params['gateway']
vlan_id = self.module.params['vlan_id']
state = self.module.params['state']
# result is a dictionary that contains changed status and Interface details
result = dict(
changed=False,
interface_details={}
)
modify_flag = False
self.validate_input_params()
interface_details = None
nas_server_obj = self.get_nas_server_obj(nas_server_name, nas_server_id)
interface_obj = self.get_interface_details(nas_server_obj)
if interface_obj and state == 'present':
interface_details = interface_obj._get_properties()
modify_flag = self.is_modification_required(interface_details)
if modify_flag:
self.module.fail_json(msg="Modification of Interfaces for NAS server is not supported through Ansible module")
if not interface_obj and state == 'present':
self.validate_create_params()
result['changed'] = self.add_interface(nas_server_obj, ethernet_port_id, ethernet_port_name, role,
interface_ip, netmask, prefix_length, gateway, vlan_id)
if interface_obj and state == 'absent':
result['changed'] = self.delete_interface(interface_obj)
if result['changed']:
nas_server_obj = self.get_nas_server_obj(nas_server_name, nas_server_id)
interface_obj = self.get_interface_details(nas_server_obj)
if interface_obj:
interface_details = interface_obj._get_properties()
result['interface_details'] = interface_details
self.module.exit_json(**result)
def get_interface_parameters():
"""This method provide parameters required for the ansible
Interface module on Unity"""
return dict(
nas_server_id=dict(type='str'),
nas_server_name=dict(type='str'),
ethernet_port_name=dict(type='str'),
ethernet_port_id=dict(type='str'),
role=dict(type='str', choices=['PRODUCTION', 'BACKUP']),
interface_ip=dict(required=True, type='str'),
netmask=dict(type='str'),
prefix_length=dict(type='int'),
gateway=dict(type='str'),
vlan_id=dict(type='int'),
state=dict(required=True, type='str', choices=['present', 'absent'])
)
def get_role_enum(role):
"""Getting correct enum values for role
:param: role: Indicates role of interface.
:return: enum value for role.
"""
if utils.FileInterfaceRoleEnum[role]:
role = utils.FileInterfaceRoleEnum[role]
return role
def is_valid_ip(address):
"""Validating IP address format
:param: address: IP address to be validated for format.
"""
try:
ipaddress.ip_address(address)
return True
except ValueError:
return False
def get_ip_version(val):
"""Returns IP address version
:param: val: IP address to be validated for version.
"""
try:
val = u'{0}'.format(val)
ip = ip_network(val, strict=False)
return ip.version
except ValueError:
return 0
def main():
"""Create Unity Interface object and perform action on it
based on user input from playbook"""
obj = Interface()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,494 @@
#!/usr/bin/python
# Copyright: (c) 2022, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Ansible module for managing NFS server on Unity"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
module: nfsserver
version_added: '1.4.0'
short_description: Manage NFS server on Unity storage system
description:
- Managing the NFS server on the Unity storage system includes creating NFS server, getting NFS server details
and deleting NFS server attributes.
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Meenakshi Dembi (@dembim) <ansible.team@dell.com>
options:
nas_server_name:
description:
- Name of the NAS server on which NFS server will be hosted.
type: str
nas_server_id:
description:
- ID of the NAS server on which NFS server will be hosted.
type: str
nfs_server_id:
description:
- ID of the NFS server.
type: str
host_name:
description:
- Host name of the NFS server.
type: str
nfs_v4_enabled:
description:
- Indicates whether the NFSv4 is enabled on the NAS server.
type: bool
is_secure_enabled:
description:
- Indicates whether the secure NFS is enabled.
type: bool
kerberos_domain_controller_type:
description:
- Type of Kerberos Domain Controller used for secure NFS service.
choices: [CUSTOM, UNIX, WINDOWS]
type: str
kerberos_domain_controller_username:
description:
- Kerberos Domain Controller administrator username.
type: str
kerberos_domain_controller_password:
description:
- Kerberos Domain Controller administrator password.
type: str
is_extended_credentials_enabled:
description:
- Indicates whether support for more than 16 unix groups in a Unix credential.
type: bool
remove_spn_from_kerberos:
description:
- Indicates whether to remove the SPN from Kerberos Domain Controller.
default: true
type: bool
state:
description:
- Define whether the NFS server should exist or not.
choices: [absent, present]
required: true
type: str
notes:
- The I(check_mode) is supported.
- Modify operation for NFS Server is not supported.
- When I(kerberos_domain_controller_type) is C(UNIX), I(kdc_type) in I(nfs_server_details) output is displayed as C(null).
'''
EXAMPLES = r'''
- name: Create NFS server with kdctype as Windows
dellemc.unity.nfsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
host_name: "dummy_nas23"
is_secure_enabled: True
kerberos_domain_controller_type: "WINDOWS"
kerberos_domain_controller_username: "administrator"
kerberos_domain_controller_password: "Password123!"
is_extended_credentials_enabled: True
nfs_v4_enabled: True
state: "present"
- name: Create NFS server with kdctype as Unix
dellemc.unity.nfsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
host_name: "dummy_nas23"
is_secure_enabled: True
kerberos_domain_controller_type: "UNIX"
is_extended_credentials_enabled: True
nfs_v4_enabled: True
state: "present"
- name: Get NFS server details
dellemc.unity.nfsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
state: "present"
- name: Delete NFS server
dellemc.unity.nfsserver:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
nas_server_name: "dummy_nas"
kerberos_domain_controller_username: "administrator"
kerberos_domain_controller_password: "Password123!"
unjoin_server_account: False
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: true
nfs_server_details:
description: Details of the NFS server.
returned: When NFS server exists
type: dict
contains:
credentials_cache_ttl:
description: Credential cache refresh timeout. Resolution is in minutes. Default value is 15 minutes.
type: str
existed:
description: Indicates if NFS Server exists.
type: bool
host_name:
description: Host name of the NFS server.
type: str
id:
description: Unique identifier of the NFS Server instance.
type: str
is_extended_credentials_enabled:
description: Indicates whether the NFS server supports more than 16 Unix groups in a Unix credential.
type: bool
is_secure_enabled:
description: Indicates whether secure NFS is enabled on the NFS server.
type: bool
kdc_type:
description: Type of Kerberos Domain Controller used for secure NFS service.
type: str
nfs_v4_enabled:
description: Indicates whether NFSv4 is enabled on the NAS server.
type: bool
servicee_principal_name:
description: The Service Principal Name (SPN) for the NFS Server.
type: str
sample: {
"credentials_cache_ttl": "0:15:00",
"existed": true,
"file_interfaces": {
"UnityFileInterfaceList": [
{
"UnityFileInterface": {
"hash": 8778980109421,
"id": "if_37"
}
}
]
},
"hash": 8778980109388,
"host_name": "dummy_nas23.pie.lab.emc.com",
"id": "nfs_51",
"is_extended_credentials_enabled": true,
"is_secure_enabled": true,
"kdc_type": "KdcTypeEnum.WINDOWS",
"nas_server": {
"UnityNasServer": {
"hash": 8778980109412
}
},
"nfs_v4_enabled": true,
"servicee_principal_name": null
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
LOG = utils.get_logger('nfsserver')
application_type = "Ansible/1.5.0"
class NFSServer(object):
"""Class with NFS server operations"""
def __init__(self):
"""Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_nfs_server_parameters())
mutually_exclusive = [['nas_server_name', 'nas_server_id']]
required_one_of = [['nfs_server_id', 'nas_server_name', 'nas_server_id']]
# initialize the Ansible module
self.module = AnsibleModule(
argument_spec=self.module_params,
supports_check_mode=True,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of
)
utils.ensure_required_libs(self.module)
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
LOG.info('Check Mode Flag %s', self.module.check_mode)
def get_nfs_server_details(self, nfs_server_id=None, nas_server_id=None):
"""Get NFS server details.
:param: nfs_server_id: The ID of the NFS server
:param: nas_server_id: The name of the NAS server
:return: Dict containing NFS server details if exists
"""
LOG.info("Getting NFS server details")
try:
if nfs_server_id:
nfs_server_details = self.unity_conn.get_nfs_server(_id=nfs_server_id)
return nfs_server_details._get_properties()
elif nas_server_id:
nfs_server_details = self.unity_conn.get_nfs_server(nas_server=nas_server_id)
if len(nfs_server_details) > 0:
return process_dict(nfs_server_details._get_properties())
return None
except utils.HttpError as e:
if e.http_status == 401:
msg = 'Incorrect username or password provided.'
LOG.error(msg)
self.module.fail_json(msg=msg)
else:
err_msg = "Failed to get details of NFS Server" \
" with error {0}".format(str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
except utils.UnityResourceNotFoundError as e:
err_msg = "Failed to get details of NFS Server" \
" with error {0}".format(str(e))
LOG.error(err_msg)
return None
def get_nfs_server_instance(self, nfs_server_id):
"""Get NFS server instance.
:param: nfs_server_id: The ID of the NFS server
:return: Return NFS server instance if exists
"""
try:
nfs_server_obj = self.unity_conn.get_nfs_server(_id=nfs_server_id)
return nfs_server_obj
except Exception as e:
error_msg = "Failed to get the NFS server %s instance" \
" with error %s" % (nfs_server_id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def delete_nfs_server(self, nfs_server_id, skip_unjoin=None, domain_username=None, domain_password=None):
"""Delete NFS server.
:param: nfs_server_id: The ID of the NFS server
:param: skip_unjoin: Flag indicating whether to unjoin SMB server account from AD before deletion
:param: domain_username: The domain username
:param: domain_password: The domain password
:return: Return True if NFS server is deleted
"""
LOG.info("Deleting NFS server")
try:
if not self.module.check_mode:
nfs_obj = self.get_nfs_server_instance(nfs_server_id=nfs_server_id)
nfs_obj.delete(skip_kdc_unjoin=skip_unjoin, username=domain_username, password=domain_password)
return True
except Exception as e:
msg = "Failed to delete NFS server: %s with error: %s" % (nfs_server_id, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def get_nas_server_id(self, nas_server_name):
"""Get NAS server ID.
:param: nas_server_name: The name of NAS server
:return: Return NAS server ID if exists
"""
LOG.info("Getting NAS server ID")
try:
obj_nas = self.unity_conn.get_nas_server(name=nas_server_name)
return obj_nas.get_id()
except Exception as e:
msg = "Failed to get details of NAS server: %s with error: %s" % (nas_server_name, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def is_modification_required(self, is_extended_credentials_enabled, nfs_server_details):
"""Check if modification is required in existing NFS server
:param: is_extended_credentials_enabled: Indicates whether the NFS server supports more than 16 Unix groups in a Unix credential.
:param: nfs_server_details: NFS server details
:return: True if modification is required
"""
LOG.info("Checking if any modification is required")
# Check for Extend Credential
if is_extended_credentials_enabled is not None and \
is_extended_credentials_enabled != nfs_server_details['is_extended_credentials_enabled']:
return True
def create_nfs_server(self, nas_server_id, host_name=None, nfs_v4_enabled=None, is_secure_enabled=None,
kerberos_domain_controller_type=None, kerberos_domain_controller_username=None,
kerberos_domain_controller_password=None, is_extended_credentials_enabled=None):
"""Create NFS server.
:param: nas_server_id: The ID of NAS server.
:param: host_name: Name of NFS Server.
:param: nfs_v4_enabled: Indicates whether the NFSv4 is enabled on the NAS server.
:param: is_secure_enabled: Indicates whether the secure NFS is enabled.
:param: kerberos_domain_controller_type: Type of Kerberos Domain Controller used for secure NFS service.
:param: kerberos_domain_controller_username: Kerberos Domain Controller administrator username.
:param: kerberos_domain_controller_password: Kerberos Domain Controller administrator password.
:param: is_extended_credentials_enabled: Indicates whether support for more than 16 unix groups in a Unix credential.
"""
LOG.info("Creating NFS server")
try:
if not self.module.check_mode:
kdc_enum_type = get_enum_kdctype(kerberos_domain_controller_type)
if kerberos_domain_controller_type == "UNIX":
is_extended_credentials_enabled = None
is_secure_enabled = None
utils.UnityNfsServer.create(cli=self.unity_conn._cli, nas_server=nas_server_id, host_name=host_name,
nfs_v4_enabled=nfs_v4_enabled,
is_secure_enabled=is_secure_enabled, kdc_type=kdc_enum_type,
kdc_username=kerberos_domain_controller_username,
kdc_password=kerberos_domain_controller_password,
is_extended_credentials_enabled=is_extended_credentials_enabled)
return True
except Exception as e:
msg = "Failed to create NFS server with on NAS Server %s with error: %s" % (nas_server_id, str(e))
LOG.error(msg)
self.module.fail_json(msg=msg)
def validate_input_params(self):
param_list = ["nfs_server_id", "nas_server_id", "nas_server_name", "host_name", "kerberos_domain_controller_username",
"kerberos_domain_controller_password"]
for param in param_list:
msg = "Please provide valid value for: %s" % param
if self.module.params[param] is not None and len(self.module.params[param].strip()) == 0:
errmsg = msg.format(param)
self.module.fail_json(msg=errmsg)
def perform_module_operation(self):
"""
Perform different actions on NFS server module based on parameters
passed in the playbook
"""
nfs_server_id = self.module.params['nfs_server_id']
nas_server_id = self.module.params['nas_server_id']
nas_server_name = self.module.params['nas_server_name']
host_name = self.module.params['host_name']
nfs_v4_enabled = self.module.params['nfs_v4_enabled']
is_secure_enabled = self.module.params['is_secure_enabled']
kerberos_domain_controller_type = self.module.params['kerberos_domain_controller_type']
kerberos_domain_controller_username = self.module.params['kerberos_domain_controller_username']
kerberos_domain_controller_password = self.module.params['kerberos_domain_controller_password']
is_extended_credentials_enabled = self.module.params['is_extended_credentials_enabled']
remove_spn_from_kerberos = self.module.params['remove_spn_from_kerberos']
state = self.module.params['state']
# result is a dictionary that contains changed status and NFS server details
result = dict(
changed=False,
nfs_server_details={}
)
modify_flag = False
self.validate_input_params()
if nas_server_name:
nas_server_id = self.get_nas_server_id(nas_server_name)
nfs_server_details = self.get_nfs_server_details(nfs_server_id=nfs_server_id,
nas_server_id=nas_server_id)
# Check if modification is required
if nfs_server_details and state == 'present':
modify_flag = self.is_modification_required(is_extended_credentials_enabled, nfs_server_details)
if modify_flag:
self.module.fail_json(msg="Modification of NFS Server parameters is not supported through Ansible module")
if not nfs_server_details and state == 'present':
if not nas_server_id:
self.module.fail_json(msg="Please provide nas server id/name to create NFS server.")
result['changed'] = self.create_nfs_server(nas_server_id, host_name, nfs_v4_enabled,
is_secure_enabled, kerberos_domain_controller_type,
kerberos_domain_controller_username,
kerberos_domain_controller_password,
is_extended_credentials_enabled)
if state == 'absent' and nfs_server_details:
skip_unjoin = not remove_spn_from_kerberos
result['changed'] = self.delete_nfs_server(nfs_server_details["id"], skip_unjoin,
kerberos_domain_controller_username,
kerberos_domain_controller_password)
if state == 'present':
result['nfs_server_details'] = self.get_nfs_server_details(nfs_server_id=nfs_server_id,
nas_server_id=nas_server_id)
self.module.exit_json(**result)
def get_nfs_server_parameters():
"""This method provide parameters required for the ansible
NFS server module on Unity"""
return dict(
nfs_server_id=dict(type='str'),
host_name=dict(type='str'),
nfs_v4_enabled=dict(type='bool'),
is_secure_enabled=dict(type='bool'),
kerberos_domain_controller_type=dict(type='str', choices=['UNIX', 'WINDOWS', 'CUSTOM']),
kerberos_domain_controller_username=dict(type='str'),
kerberos_domain_controller_password=dict(type='str', no_log=True),
nas_server_name=dict(type='str'),
nas_server_id=dict(type='str'),
is_extended_credentials_enabled=dict(type='bool'),
remove_spn_from_kerberos=dict(default=True, type='bool'),
state=dict(required=True, type='str', choices=['present', 'absent']),
)
def get_enum_kdctype(kerberos_domain_controller_type):
"""Getting correct enum values for kerberos_domain_controller_type
:param: kerberos_domain_controller_type: Type of Kerberos Domain Controller used for secure NFS service.
:return: enum value for kerberos_domain_controller_type.
"""
if utils.KdcTypeEnum[kerberos_domain_controller_type]:
kerberos_domain_controller_type = utils.KdcTypeEnum[kerberos_domain_controller_type]
return kerberos_domain_controller_type
def process_dict(nfs_server_details):
"""Process NFS server details.
:param: nfs_server_details: Dict containing NFS server details
:return: Processed dict containing NFS server details
"""
param_list = ['credentials_cache_ttl', 'file_interfaces', 'host_name', 'id', 'kdc_type', 'nas_server', 'is_secure_enabled',
'is_extended_credentials_enabled', 'nfs_v4_enabled', 'servicee_principal_name']
for param in param_list:
if param in nfs_server_details and param == 'credentials_cache_ttl':
nfs_server_details[param] = str(nfs_server_details[param][0])
else:
nfs_server_details[param] = nfs_server_details[param][0]
return nfs_server_details
def main():
"""Create Unity NFS server object and perform action on it
based on user input from playbook"""
obj = NFSServer()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,877 @@
#!/usr/bin/python
# Copyright: (c) 2020, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r'''
---
module: smbshare
version_added: '1.1.0'
short_description: Manage SMB shares on Unity storage system
extends_documentation_fragment:
- dellemc.unity.unity
author:
- P Srinivas Rao (@srinivas-rao5) <ansible.team@dell.com>
description:
- Managing SMB Shares on Unity storage system includes create, get,
modify, and delete the smb shares.
options:
share_name:
description:
- Name of the SMB share.
- Required during creation of the SMB share.
- For all other operations either I(share_name) or I(share_id) is required.
type: str
share_id:
description:
- ID of the SMB share.
- Should not be specified during creation. Id is auto generated.
- For all other operations either I(share_name) or I(share_id) is required.
- If I(share_id) is used then no need to pass nas_server/filesystem/snapshot/path.
type: str
path:
description:
- Local path to the file system/Snapshot or any existing sub-folder of
the file system/Snapshot that is shared over the network.
- Path is relative to the root of the filesystem.
- Required for creation of the SMB share.
type: str
filesystem_id:
description:
- The ID of the File System.
- Either I(filesystem_name) or I(filesystem_id) is required for creation of the SMB share for filesystem.
- If I(filesystem_name) is specified, then I(nas_server_name)/I(nas_server_id) is required to
uniquely identify the filesystem.
- Options I(filesystem_name) and I(filesystem_id) are mutually exclusive parameters.
type: str
snapshot_id:
description:
- The ID of the Filesystem Snapshot.
- Either I(snapshot_name) or I(snapshot_id) is required for creation of the SMB share for a snapshot.
- If I(snapshot_name) is specified, then I(nas_server_name)/I(nas_server_id) is required to
uniquely identify the snapshot.
- Options I(snapshot_name) and I(snapshot_id) are mutually exclusive parameters.
type: str
nas_server_id:
description:
- The ID of the NAS Server.
- It is not required if I(share_id) is used.
type: str
filesystem_name:
description:
- The Name of the File System.
- Either I(filesystem_name) or I(filesystem_id) is required for creation of the SMB share for filesystem.
- If I(filesystem_name) is specified, then I(nas_server_name)/I(nas_server_id) is required to
uniquely identify the filesystem.
- Options I(filesystem_name) and I(filesytem_id) are mutually exclusive parameters.
type: str
snapshot_name:
description:
- The Name of the Filesystem Snapshot.
- Either I(snapshot_name) or I(snapshot_id) is required for creation of the SMB share for a snapshot.
- If I(snapshot_name) is specified, then I(nas_server_name)/I(nas_server_id) is required to
uniquely identify the snapshot.
- Options I(snapshot_name) and I(snapshot_id) are mutually exclusive parameters.
type: str
nas_server_name:
description:
- The Name of the NAS Server.
- It is not required if I(share_id) is used.
- Options I(nas_server_name) and I(nas_server_id) are mutually exclusive parameters.
type: str
description:
description:
- Description for the SMB share.
- Optional parameter when creating a share.
- To modify, pass the new value in description field.
type: str
is_abe_enabled:
description:
- Indicates whether Access-based Enumeration (ABE) for SMB share is enabled.
- During creation, if not mentioned then default is C(false).
type: bool
is_branch_cache_enabled:
description:
- Indicates whether Branch Cache optimization for SMB share is enabled.
- During creation, if not mentioned then default is C(false).
type: bool
is_continuous_availability_enabled:
description:
- Indicates whether continuous availability for SMB 3.0 is enabled.
- During creation, if not mentioned then default is C(false).
type: bool
is_encryption_enabled:
description:
- Indicates whether encryption for SMB 3.0 is enabled at the shared folder level.
- During creation, if not mentioned then default is C(false).
type: bool
offline_availability:
description:
- Defines valid states of Offline Availability.
- C(MANUAL)- Only specified files will be available offline.
- C(DOCUMENTS)- All files that users open will be available offline.
- C(PROGRAMS)- Program will preferably run from the offline cache even when
connected to the network. All files that users open will be available offline.
- C(NONE)- Prevents clients from storing documents and programs in offline cache.
type: str
choices: ["MANUAL","DOCUMENTS","PROGRAMS","NONE"]
umask:
description:
- The default UNIX umask for new files created on the SMB Share.
type: str
state:
description:
- Define whether the SMB share should exist or not.
- Value C(present) indicates that the share should exist on the system.
- Value C(absent) indicates that the share should not exist on the system.
type: str
required: true
choices: ['absent', 'present']
notes:
- When ID/Name of the filesystem/snapshot is passed then I(nas_server) is not required.
If passed, then filesystem/snapshot should exist for the mentioned I(nas_server),
else the task will fail.
- The I(check_mode) is not supported.
'''
EXAMPLES = r'''
- name: Create SMB share for a filesystem
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_name: "sample_smb_share"
filesystem_name: "sample_fs"
nas_server_id: "NAS_11"
path: "/sample_fs"
description: "Sample SMB share created"
is_abe_enabled: True
is_branch_cache_enabled: True
offline_availability: "DOCUMENTS"
is_continuous_availability_enabled: True
is_encryption_enabled: True
umask: "777"
state: "present"
- name: Modify Attributes of SMB share for a filesystem
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_name: "sample_smb_share"
nas_server_name: "sample_nas_server"
description: "Sample SMB share attributes updated"
is_abe_enabled: False
is_branch_cache_enabled: False
offline_availability: "MANUAL"
is_continuous_availability_enabled: "False"
is_encryption_enabled: "False"
umask: "022"
state: "present"
- name: Create SMB share for a snapshot
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_name: "sample_snap_smb_share"
snapshot_name: "sample_snapshot"
nas_server_id: "NAS_11"
path: "/sample_snapshot"
description: "Sample SMB share created for snapshot"
is_abe_enabled: True
is_branch_cache_enabled: True
is_continuous_availability_enabled: True
is_encryption_enabled: True
umask: "777"
state: "present"
- name: Modify Attributes of SMB share for a snapshot
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_name: "sample_snap_smb_share"
snapshot_name: "sample_snapshot"
description: "Sample SMB share attributes updated for snapshot"
is_abe_enabled: False
is_branch_cache_enabled: False
offline_availability: "MANUAL"
is_continuous_availability_enabled: "False"
is_encryption_enabled: "False"
umask: "022"
state: "present"
- name: Get details of SMB share
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_id: "{{smb_share_id}}"
state: "present"
- name: Delete SMB share
dellemc.unity.smbshare:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
share_id: "{{smb_share_id}}"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: True
smb_share_details:
description: The SMB share details.
type: dict
returned: When share exists.
contains:
id:
description: The ID of the SMB share.
type: str
name:
description: Name of the SMB share.
type: str
sample: "sample_smb_share"
filesystem_id:
description: The ID of the Filesystem.
type: str
filesystem_name:
description: The Name of the filesystem
type: str
snapshot_id:
description: The ID of the Snapshot.
type: str
snapshot_name:
description: The Name of the Snapshot.
type: str
nas_server_id:
description: The ID of the nas_server.
type: str
nas_server_name:
description: The Name of the nas_server.
type: str
description:
description: Additional information about the share.
type: str
sample: This share is created for demo purpose only.
is_abe_enabled:
description: Whether Access Based enumeration is enforced or not.
type: bool
sample: false
is_branch_cache_enabled:
description: Whether branch cache is enabled or not.
type: bool
sample: false
is_continuous_availability_enabled:
description: Whether the share will be available continuously or not.
type: bool
sample: false
is_encryption_enabled:
description: Whether encryption is enabled or not.
type: bool
sample: false
umask:
description: Unix mask for the SMB share.
type: str
sample: {
"creation_time": "2022-03-17 11:56:54.867000+00:00",
"description": "",
"existed": true,
"export_paths": [
"\\\\multi-prot-pie.extreme1.com\\multi-prot-hui",
"\\\\10.230.24.26\\multi-prot-hui"
],
"filesystem": {
"UnityFileSystem": {
"hash": 8748426746492
}
},
"filesystem_id": "fs_140",
"filesystem_name": "multi-prot-hui",
"hash": 8748426746588,
"id": "SMBShare_20",
"is_abe_enabled": false,
"is_ace_enabled": false,
"is_branch_cache_enabled": false,
"is_continuous_availability_enabled": false,
"is_dfs_enabled": false,
"is_encryption_enabled": false,
"is_read_only": null,
"modified_time": "2022-03-17 11:56:54.867000+00:00",
"name": "multi-prot-hui",
"nas_server_id": "nas_5",
"nas_server_name": "multi-prot",
"offline_availability": "CifsShareOfflineAvailabilityEnum.NONE",
"path": "/",
"snap": null,
"type": "CIFSTypeEnum.CIFS_SHARE",
"umask": "022"
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
LOG = utils.get_logger('smbshare')
application_type = "Ansible/1.5.0"
class SMBShare(object):
"""Class with SMB Share operations"""
def __init__(self):
""" Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_smb_share_parameters())
# initialize the ansible module
mut_ex_args = [['share_name', 'share_id'],
['nas_server_name', 'nas_server_id'],
['filesystem_name', 'snapshot_name',
'filesystem_id', 'snapshot_id'],
['share_id', 'nas_server_name'],
['share_id', 'nas_server_id'],
['share_id', 'filesystem_name'],
['share_id', 'filesystem_id'],
['share_id', 'path'],
['share_id', 'snapshot_name'],
['share_id', 'snapshot_id']]
required_one_of = [['share_id', 'share_name']]
self.module = AnsibleModule(
argument_spec=self.module_params,
supports_check_mode=False,
mutually_exclusive=mut_ex_args,
required_one_of=required_one_of
)
utils.ensure_required_libs(self.module)
# result is a dictionary that contains changed status and
# snapshot details
self.result = {"changed": False,
'smb_share_details': {}}
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
self.smb_share_conn_obj = utils.cifs_share.UnityCifsShare(
self.unity_conn)
LOG.info('Connection established with the Unity Array')
def get_offline_availability_enum(self, offline_availability):
"""
Get the enum of the Offline Availability parameter.
:param offline_availability: The offline_availability string
:return: offline_availability enum
"""
if offline_availability in \
utils.CifsShareOfflineAvailabilityEnum.__members__:
return utils.CifsShareOfflineAvailabilityEnum[
offline_availability]
else:
error_msg = "Invalid value {0} for offline availability" \
" provided".format(offline_availability)
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_smb_share_obj(self, share_id=None, share_name=None,
filesystem_obj=None, snap_obj=None, nas_obj=None):
"""Get SMB share details"""
msg = "Failed to get details of SMB Share {0} with error {1} "
smb_share = share_name if share_name else share_id
try:
if share_id:
obj_smb = self.unity_conn.get_cifs_share(_id=share_id)
if obj_smb and obj_smb.existed:
LOG.info("Successfully got the SMB share "
"object %s ", obj_smb)
return obj_smb
elif share_name is not None and filesystem_obj:
# There might be a case where SMB share with same name exists
# for different nas server. Hence, filesystem_obj is passed
# along with share name to get a unique resource.
return self.unity_conn.get_cifs_share(
name=share_name, filesystem=filesystem_obj)
elif share_name is not None and snap_obj:
# There might be a case where SMB share with same name exists
# for different nas server. Hence, snap_obj is passed
# along with share name to get a unique resource.
return self.unity_conn.get_cifs_share(
name=share_name, snap=snap_obj)
# This elif is addressing scenario where nas server details is
# passed and neither filesystem nor snapshot details are passed.
elif share_name is not None and nas_obj:
# Multiple smb shares can be received, as only name is passed
smb_share_obj = self.unity_conn.get_cifs_share(
name=share_name)
# Checking if instance or list of instance is returned.
if isinstance(smb_share_obj,
utils.cifs_share.UnityCifsShareList):
LOG.info("Multiple SMB share with same name found.")
smb_share_obj_list = smb_share_obj
for smb_share in smb_share_obj_list:
if smb_share.filesystem.nas_server == nas_obj:
return smb_share
msg = "No SMB share found with the given NAS Server." \
" Please provide correct share name and" \
" nas server details."
return None
# Below statements will execute when there is only single
# smb share returned.
if smb_share_obj.filesystem.nas_server == nas_obj:
return smb_share_obj
msg = "No SMB share found with the given NAS Server." \
" Please provide correct share name and" \
" nas server details."
return None
else:
self.module.fail_json(
msg="Share Name is Passed. Please enter Filesystem/"
"Snapshot/NAS Server Resource along with share_name"
" to get the details of the SMB share")
except utils.HttpError as e:
if e.http_status == 401:
cred_err = "Incorrect username or password , {0}".format(
e.message)
self.module.fail_json(msg=cred_err)
else:
err_msg = msg.format(smb_share, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
except utils.UnityResourceNotFoundError as e:
err_msg = msg.format(smb_share, str(e))
LOG.error(err_msg)
return None
except Exception as e:
err_msg = msg.format(smb_share, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def create_smb_share(self, share_name, path, filesystem_obj=None,
snapshot_obj=None, description=None,
is_abe_enabled=None, is_branch_cache_enabled=None,
is_continuous_availability_enabled=None,
is_encryption_enabled=None,
offline_availability=None, umask=None):
"""
Create SMB Share
:return: SMB Share Object if successful, else error.
"""
if path is None or path == "":
self.module.fail_json(msg="Please enter a valid path."
" Empty string or None provided.")
if not filesystem_obj and not snapshot_obj:
self.module.fail_json(msg="Either Filesystem or Snapshot "
"Resource's Name/ID is required to"
" Create a SMB share")
try:
if filesystem_obj:
return self.smb_share_conn_obj.create(
cli=self.unity_conn._cli, name=share_name,
fs=filesystem_obj, path=path,
is_encryption_enabled=is_encryption_enabled,
is_con_avail_enabled=is_continuous_availability_enabled,
is_abe_enabled=is_abe_enabled,
is_branch_cache_enabled=is_branch_cache_enabled,
umask=umask, description=description,
offline_availability=offline_availability)
else:
return self.smb_share_conn_obj.create_from_snap(
cli=self.unity_conn._cli, name=share_name,
snap=snapshot_obj, path=path,
is_encryption_enabled=is_encryption_enabled,
is_con_avail_enabled=is_continuous_availability_enabled,
is_abe_enabled=is_abe_enabled,
is_branch_cache_enabled=is_branch_cache_enabled,
umask=umask, description=description,
offline_availability=offline_availability)
except Exception as e:
error_msg = "Failed to create SMB share" \
" %s with error %s" % (share_name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_filesystem(self, filesystem_id=None, filesystem_name=None,
nas_server_obj=None):
"""
Get the Filesystem Object.
:param filesystem_id: ID of the Filesystem.
:param filesystem_name: Name of the filesystem.
:param nas_server_obj: NAS Server object.
:return: Object of the filesystem.
"""
try:
if filesystem_id:
obj_fs = self.unity_conn.get_filesystem(_id=filesystem_id)
if obj_fs and obj_fs.existed:
LOG.info("Successfully got the filesystem "
"object %s ", obj_fs)
return obj_fs
else:
return self.unity_conn.get_filesystem(
name=filesystem_name, nas_server=nas_server_obj)
return None
except Exception as e:
filesystem = filesystem_name if filesystem_name \
else filesystem_id
err_msg = "Failed to get filesystem details {0} with" \
" error {1}".format(filesystem, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def get_snapshot(self, snapshot_name, snapshot_id):
"""
Get the Snapshot Object.
:param snapshot_id: ID of the Snapshot.
:param snapshot_name: Name of the Snapshot
:return: Object of the filesystem.
"""
try:
obj_snap = self.unity_conn.get_snap(_id=snapshot_id,
name=snapshot_name)
if snapshot_id and obj_snap and not obj_snap.existed:
LOG.info("Snapshot object does not exist %s ", obj_snap)
return None
return obj_snap
except Exception as e:
snapshot = snapshot_name if snapshot_name else snapshot_id
err_msg = "Failed to get filesystem snapshots details {0} with" \
" error {1}".format(snapshot, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def get_nas_server(self, nas_server_name, nas_server_id):
"""
Get the NAS Server Object using NAME/ID of the NAS Server.
:param nas_server_name: Name of the NAS Server
:param nas_server_id: ID of the NAS Server
:return: NAS Server object.
"""
nas_server = nas_server_name if nas_server_name else nas_server_id
try:
obj_nas = self.unity_conn.get_nas_server(_id=nas_server_id,
name=nas_server_name)
if nas_server_id and obj_nas and not obj_nas.existed:
LOG.info("NAS Server object does not exist %s ", obj_nas)
return None
return obj_nas
except utils.HttpError as e:
if e.http_status == 401:
cred_err = "Incorrect username or password , {0}".format(
e.message)
self.module.fail_json(msg=cred_err)
else:
err_msg = "Failed to get details of NAS Server" \
" {0} with error {1}".format(nas_server, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
except Exception as e:
nas_server = nas_server_name if nas_server_name \
else nas_server_id
err_msg = "Failed to get nas server details {0} with" \
" error {1}".format(nas_server, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def delete_smb_share(self, smb_share_obj):
"""
Delete SMB share if exists, else thrown error.
"""
try:
smb_share_obj.delete()
except Exception as e:
error_msg = "Failed to Delete SMB share" \
" %s with error %s" % (smb_share_obj.name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def to_update(self, smb_share_obj):
LOG.info("Checking Whether the parameters are modified or not.")
offline_availability = self.module.params['offline_availability']
# Get the enum for the corresponding offline_availability
if offline_availability:
offline_availability = \
self.get_offline_availability_enum(offline_availability)
if offline_availability is not None and \
offline_availability != smb_share_obj.offline_availability:
return True
smb_share_dict = smb_share_obj._get_properties()
params_list = ['is_abe_enabled', 'is_branch_cache_enabled',
'is_continuous_availability_enabled',
'is_encryption_enabled', 'description', 'umask']
for param in params_list:
if self.module.params[param] is not None and \
self.module.params[param] != smb_share_dict[param]:
return True
return False
def update_smb_share(self, smb_share_obj, is_encryption_enabled=None,
is_continuous_availability_enabled=None,
is_abe_enabled=None,
is_branch_cache_enabled=None,
umask=None, description=None,
offline_availability=None):
"""
The Details of the SMB share will be updated in the function.
"""
try:
smb_share_obj.modify(
is_encryption_enabled=is_encryption_enabled,
is_con_avail_enabled=is_continuous_availability_enabled,
is_abe_enabled=is_abe_enabled,
is_branch_cache_enabled=is_branch_cache_enabled,
umask=umask, description=description,
offline_availability=offline_availability)
except Exception as e:
error_msg = "Failed to Update parameters of SMB share" \
" %s with error %s" % (smb_share_obj.name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def perform_module_operation(self):
"""
Perform different actions on SMB share based on user parameters
chosen in playbook
"""
state = self.module.params['state']
share_name = self.module.params['share_name']
filesystem_name = self.module.params['filesystem_name']
snapshot_name = self.module.params['snapshot_name']
nas_server_name = self.module.params['nas_server_name']
share_id = self.module.params['share_id']
filesystem_id = self.module.params['filesystem_id']
snapshot_id = self.module.params['snapshot_id']
nas_server_id = self.module.params['nas_server_id']
path = self.module.params['path']
description = self.module.params['description']
is_branch_cache_enabled = \
self.module.params['is_branch_cache_enabled']
is_continuous_availability_enabled = \
self.module.params['is_continuous_availability_enabled']
is_encryption_enabled = self.module.params['is_encryption_enabled']
is_abe_enabled = self.module.params['is_abe_enabled']
umask = self.module.params['umask']
offline_availability = self.module.params['offline_availability']
# Get the enum for the corresponding offline_availability
if offline_availability:
offline_availability = \
self.get_offline_availability_enum(offline_availability)
changed = False
'''
Validate parameters.
'''
if share_id is not None and \
(share_id == "" or len(share_id.split()) == 0):
self.module.fail_json(msg="Invalid share id provided."
" Please enter a valid share ID.")
'''
Get details of NAS Server, if entered.
'''
nas_server_obj = None
if nas_server_name or nas_server_id:
nas_server_obj = self.get_nas_server(nas_server_name,
nas_server_id)
if nas_server_obj:
msg = "NAS Server Object:" \
" {0}".format(nas_server_obj._get_properties())
LOG.info(msg)
else:
msg = "NAS Server Resource not fetched."
LOG.info(msg)
'''
Get details of Filesystem, if entered.
'''
filesystem_obj = None
if filesystem_id:
filesystem_obj = self.get_filesystem(filesystem_id)
if filesystem_name:
# nas_server_obj is required to uniquely identify filesystem
# resource. If neither nas_server_name nor nas_server_id
# is passed along with filesystem_name then error is thrown.
if not nas_server_obj:
self.module.fail_json(msg="nas_server_id/nas_server_name is "
"required when filesystem_name is "
"passed")
filesystem_obj = self.get_filesystem(
None, filesystem_name, nas_server_obj)
if filesystem_obj:
msg = "Filesystem Object:" \
" {0}".format(filesystem_obj._get_properties())
LOG.info(msg)
# Checking if filesystem supports SMB protocol or not.
if filesystem_obj and \
filesystem_obj.supported_protocols.name == "NFS":
self.module.fail_json(msg="Cannot perform SMB share operations "
"as file system supports only NFS "
"protocol. Please enter a valid "
"Filesystem having supported protocol"
" as SMB or Multiprotocol.")
'''
Get details of Snapshot, if entered.
'''
snapshot_obj = None
if snapshot_id or snapshot_name:
# Snapshot Name and Snapshot ID both are unique across array.
# Hence no need to mention nas server details
snapshot_obj = self.get_snapshot(snapshot_name, snapshot_id)
if snapshot_obj:
msg = "Snapshot Object:" \
" {0}".format(snapshot_obj._get_properties())
LOG.info(msg)
else:
msg = "Snapshot Resource not fetched."
LOG.info(msg)
'''
Get the Details of the SMB Share
'''
smb_share_obj = self.get_smb_share_obj(
share_id, share_name, filesystem_obj, snapshot_obj,
nas_server_obj)
if smb_share_obj:
msg = "SMB Share Object:" \
" {0}".format(smb_share_obj._get_properties())
LOG.info(msg)
elif state == 'present' and share_id:
msg = "Unable to fetch SMB Share Resource. " \
"Incorrect SMB share id provided. " \
"Please enter a correct share id."
LOG.error(msg)
self.module.fail_json(msg=msg)
'''
Creation of SMB Share
'''
if state == "present" and not smb_share_obj:
smb_share_obj = self.create_smb_share(
share_name, path, filesystem_obj, snapshot_obj, description,
is_abe_enabled, is_branch_cache_enabled,
is_continuous_availability_enabled, is_encryption_enabled,
offline_availability, umask)
changed = True
'''
Update the SMB share details
'''
if state == "present" and smb_share_obj:
LOG.info("Modify the details of the SMB share.")
update_flag = self.to_update(smb_share_obj)
msg = "Update Flag: {0}".format(str(update_flag))
LOG.info(msg)
if update_flag:
self.update_smb_share(smb_share_obj, is_encryption_enabled,
is_continuous_availability_enabled,
is_abe_enabled,
is_branch_cache_enabled,
umask, description,
offline_availability)
changed = True
'''
Delete the SMB share details
'''
if state == "absent" and smb_share_obj:
self.delete_smb_share(smb_share_obj)
changed = True
'''
Update the changed state and SMB share details
'''
self.result["changed"] = changed
smb_details = self.prepare_output_dict(state, share_id, share_name,
filesystem_obj, snapshot_obj,
nas_server_obj)
self.result["smb_share_details"] = smb_details
self.module.exit_json(**self.result)
def prepare_output_dict(self, state, share_id, share_name,
filesystem_obj, snapshot_obj, nas_server_obj):
smb_share_details = None
smb_share_obj = None
if state == 'present':
smb_share_obj = self.get_smb_share_obj(
share_id, share_name, filesystem_obj,
snapshot_obj, nas_server_obj)
smb_share_details = smb_share_obj._get_properties()
if smb_share_details:
# Get Snapshot NAME and ID if SMB share exists for Snapshot
if smb_share_obj.type.name == "CIFS_SNAPSHOT":
smb_share_details['snapshot_name'] = smb_share_obj.snap.name
smb_share_details['snapshot_id'] = smb_share_obj.snap.id
# Get Filesystem NAME and ID
smb_share_details['filesystem_name'] = \
smb_share_obj.filesystem.name
smb_share_details['filesystem_id'] = smb_share_obj.filesystem.id
# Get NAS server NAME and ID
smb_share_details['nas_server_name'] = \
smb_share_obj.filesystem.nas_server.name
smb_share_details['nas_server_id'] = \
smb_share_obj.filesystem.nas_server.id
return smb_share_details
def get_smb_share_parameters():
"""
This method provides parameters required for the ansible smb share
modules on Unity
"""
return dict(
share_name=dict(), share_id=dict(),
filesystem_name=dict(), filesystem_id=dict(),
snapshot_name=dict(), snapshot_id=dict(),
nas_server_name=dict(), nas_server_id=dict(),
path=dict(no_log=True), umask=dict(), description=dict(),
offline_availability=dict(
choices=["MANUAL", "DOCUMENTS", "PROGRAMS", "NONE"]),
is_abe_enabled=dict(type='bool'),
is_branch_cache_enabled=dict(type='bool'),
is_continuous_availability_enabled=dict(type='bool'),
is_encryption_enabled=dict(type='bool'),
state=dict(required=True, choices=['present', 'absent'], type='str')
)
def main():
""" Create Unity SMB share object and perform action on it
based on user input from playbook"""
obj = SMBShare()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,751 @@
#!/usr/bin/python
# Copyright: (c) 2020, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
""" Ansible module for managing Snapshots on Unity"""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r'''
---
module: snapshot
short_description: Manage snapshots on the Unity storage system
description:
- Managing snapshots on the Unity storage system includes create snapshot,
delete snapshot, update snapshot, get snapshot, map host and unmap host.
version_added: '1.1.0'
extends_documentation_fragment:
- dellemc.unity.unity
author:
- P Srinivas Rao (@srinivas-rao5) <ansible.team@dell.com>
options:
snapshot_name:
description:
- The name of the snapshot.
- Mandatory parameter for creating a snapshot.
- For all other operations either I(snapshot_name) or I(snapshot_id) is
required.
type: str
vol_name:
description:
- The name of the volume for which snapshot is created.
- For creation of a snapshot either I(vol_name) or I(cg_name) is required.
- Not required for other operations.
type: str
cg_name:
description:
- The name of the Consistency Group for which snapshot is created.
- For creation of a snapshot either I(vol_name) or I(cg_name) is required.
- Not required for other operations.
type: str
snapshot_id:
description:
- The id of the snapshot.
- For all operations other than creation either I(snapshot_name) or
I(snapshot_id) is required.
type: str
auto_delete:
description:
- This option specifies whether the snapshot is auto deleted or not.
- If set to C(true), snapshot will expire based on the pool auto deletion
policy.
- If set to (false), snapshot will not be auto deleted
based on the pool auto deletion policy.
- Option I(auto_delete) can not be set to C(true), if I(expiry_time) is specified.
- If during creation neither I(auto_delete) nor I(expiry_time) is mentioned
then snapshot will be created keeping I(auto_delete) as C(true).
- Once the I(expiry_time) is set then snapshot cannot be assigned
to the auto delete policy.
type: bool
expiry_time:
description:
- This option is for specifying the date and time after which the
snapshot will expire.
- The time is to be mentioned in UTC timezone.
- The format is "MM/DD/YYYY HH:MM". Year must be in 4 digits.
type: str
description:
description:
- The additional information about the snapshot can be provided using
this option.
type: str
new_snapshot_name:
description:
- New name for the snapshot.
type: str
state:
description:
- The I(state) option is used to mention the existence of
the snapshot.
type: str
required: true
choices: [ 'absent', 'present' ]
host_name:
description:
- The name of the host.
- Either I(host_name) or I(host_id) is required to map or unmap a snapshot from
a host.
- Snapshot can be attached to multiple hosts.
type: str
host_id:
description:
- The id of the host.
- Either I(host_name) or I(host_id) is required to map or unmap a snapshot from
a host.
- Snapshot can be attached to multiple hosts.
type: str
host_state:
description:
- The I(host_state) option is used to mention the existence of the host
for snapshot.
- It is required when a snapshot is mapped or unmapped from host.
type: str
choices: ['mapped', 'unmapped']
notes:
- The I(check_mode) is not supported.
'''
EXAMPLES = r'''
- name: Create a Snapshot for a CG
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
port: "{{port}}"
cg_name: "{{cg_name}}"
snapshot_name: "{{cg_snapshot_name}}"
description: "{{description}}"
auto_delete: False
state: "present"
- name: Create a Snapshot for a volume with Host attached
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
port: "{{port}}"
vol_name: "{{vol_name}}"
snapshot_name: "{{vol_snapshot_name}}"
description: "{{description}}"
expiry_time: "04/15/2025 16:30"
host_name: "{{host_name}}"
host_state: "mapped"
state: "present"
- name: Unmap a host for a Snapshot
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
port: "{{port}}"
snapshot_name: "{{vol_snapshot_name}}"
host_name: "{{host_name}}"
host_state: "unmapped"
state: "present"
- name: Map snapshot to a host
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
port: "{{port}}"
snapshot_name: "{{vol_snapshot_name}}"
host_name: "{{host_name}}"
host_state: "mapped"
state: "present"
- name: Update attributes of a Snapshot for a volume
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "{{vol_snapshot_name}}"
new_snapshot_name: "{{new_snapshot_name}}"
description: "{{new_description}}"
host_name: "{{host_name}}"
host_state: "unmapped"
state: "present"
- name: Delete Snapshot of CG
dellemc.unity.snapshot:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
snapshot_name: "{{cg_snapshot_name}}"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: True
snapshot_details:
description: Details of the snapshot.
returned: When snapshot exists
type: dict
contains:
is_auto_delete:
description: Additional information mentioned for snapshot.
type: str
expiration_time:
description: Date and time after which the snapshot
will expire.
type: str
hosts_list:
description: Contains the name and id of the associated
hosts.
type: dict
id:
description: Unique identifier of the snapshot instance.
type: str
name:
description: The name of the snapshot.
type: str
storage_resource_name:
description: Name of the storage resource for which the
snapshot exists.
type: str
storage_resource_id:
description: Id of the storage resource for which the snapshot
exists.
type: str
sample: {
"access_type": null,
"attached_wwn": null,
"creation_time": "2022-10-21 08:20:25.803000+00:00",
"creator_schedule": null,
"creator_type": "SnapCreatorTypeEnum.USER_CUSTOM",
"creator_user": {
"id": "user_admin"
},
"description": "Test snap creation",
"existed": true,
"expiration_time": null,
"hash": 8756689457056,
"hosts_list": [],
"id": "85899355291",
"io_limit_policy": null,
"is_auto_delete": true,
"is_modifiable": false,
"is_modified": false,
"is_read_only": true,
"is_system_snap": false,
"last_writable_time": null,
"lun": null,
"name": "ansible_snap_cg_1_1",
"parent_snap": null,
"size": null,
"snap_group": null,
"state": "SnapStateEnum.READY",
"storage_resource_id": "res_95",
"storage_resource_name": "CG_ansible_test_2_new"
}
'''
import logging
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
from datetime import datetime
LOG = utils.get_logger('snapshot')
application_type = "Ansible/1.5.0"
class Snapshot(object):
"""Class with Snapshot operations"""
def __init__(self):
""" Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_snapshot_parameters())
mutually_exclusive = [['snapshot_name', 'snapshot_id'],
['vol_name', 'cg_name'],
['host_name', 'host_id']]
required_one_of = [['snapshot_name', 'snapshot_id']]
# initialize the ansible module
self.module = AnsibleModule(argument_spec=self.module_params,
supports_check_mode=False,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of)
utils.ensure_required_libs(self.module)
# result is a dictionary that contains changed status and
# snapshot details
self.result = {"changed": False,
'snapshot_details': {}}
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
self.snap_obj = utils.snap.UnitySnap(self.unity_conn)
LOG.info('Connection established with the Unity Array')
def validate_expiry_time(self, expiry_time):
"""Validates the specified expiry_time"""
try:
datetime.strptime(expiry_time, '%m/%d/%Y %H:%M')
except ValueError:
error_msg = "expiry_time not in MM/DD/YYYY HH:MM format"
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def to_update(self, snapshot, new_name=None, description=None,
auto_del=None, expiry_time=None, host=None,
host_state=None):
"""Determines whether to update the snapshot or not"""
if expiry_time:
# If the snapshot has is_auto_delete True,
# Check if auto_delete in the input is either None or True
if snapshot.is_auto_delete and (auto_del is None or auto_del):
self.module.fail_json(msg="expiry_time can be assigned when"
" auto delete is False")
if auto_del and snapshot.expiration_time:
error_msg = "expiry_time for snapshot is set." \
" Once it is set then snapshot cannot" \
" be assigned to auto_delete policy"
self.module.fail_json(msg=error_msg)
if new_name and new_name != snapshot.name:
return True
if description and description != snapshot.description:
return True
if auto_del and auto_del != snapshot.is_auto_delete:
return True
if to_update_expiry_time(snapshot, expiry_time):
return True
if host and to_update_host_list(snapshot, host, host_state):
return True
return False
def update_snapshot(self, snapshot, new_name=None,
description=None, auto_del=None, expiry_time=None,
host_access_list=None):
try:
duration = None
if expiry_time:
duration = convert_timestamp_to_sec(
expiry_time, self.unity_conn.system_time)
if duration and duration <= 0:
self.module.fail_json(msg="expiry_time should be after"
" the current system time")
snapshot.modify(name=new_name, retentionDuration=duration,
isAutoDelete=auto_del, description=description,
hostAccess=host_access_list)
snapshot.update()
except Exception as e:
error_msg = "Failed to modify snapshot" \
" [name: %s , id: %s] with error %s"\
% (snapshot.name, snapshot.id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def create_snapshot(self, snap_name, storage_id, description=None,
auto_del=None, expiry_time=None):
try:
duration = None
if expiry_time:
duration = convert_timestamp_to_sec(
expiry_time, self.unity_conn.system_time)
if duration <= 0:
self.module.fail_json(msg="expiry_time should be after"
" the current system time")
snapshot = self.snap_obj.create(
cli=self.unity_conn._cli, storage_resource=storage_id,
name=snap_name, description=description,
is_auto_delete=auto_del, retention_duration=duration)
return snapshot
except Exception as e:
error_msg = "Failed to create snapshot" \
" %s with error %s" % (snap_name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def delete_snapshot(self, snapshot):
try:
if not bool(get_hosts_dict(snapshot)):
snapshot.detach_from(None)
snapshot.delete()
else:
snapshot.delete()
return None
except Exception as e:
error_msg = "Failed to delete snapshot" \
" [name: %s, id: %s] with error %s" \
% (snapshot.name, snapshot.id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_snapshot_obj(self, name=None, id=None):
snapshot = id if id else name
msg = "Failed to get details of snapshot %s with error %s "
try:
return self.unity_conn.get_snap(name=name, _id=id)
except utils.HttpError as e:
if e.http_status == 401:
cred_err = "Incorrect username or password , {0}".format(
e.message)
self.module.fail_json(msg=cred_err)
else:
err_msg = msg % (snapshot, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
except utils.UnityResourceNotFoundError as e:
err_msg = msg % (snapshot, str(e))
LOG.error(err_msg)
return None
except Exception as e:
err_msg = msg % (snapshot, str(e))
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
def get_volume_obj(self, name):
try:
return self.unity_conn.get_lun(name=name)
except Exception as e:
error_msg = "Failed to get volume %s with error %s"\
% (name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_cg_obj(self, name):
try:
return self.unity_conn.get_cg(name=name)
except Exception as e:
error_msg = "Failed to get cg %s with error %s" % (name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_host_obj(self, name=None, id=None):
""" Get the Host object"""
try:
return self.unity_conn.get_host(name=name, _id=id)
except Exception as e:
host = id if id else name
error_msg = "Failed to get host %s with error %s"\
% (host, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def attach_to_snap(self, snapshot, host):
""" Attach snapshot to a host """
try:
if not get_hosts_dict(snapshot):
snapshot.detach_from(None)
snapshot.attach_to(host)
snapshot.update()
except Exception as e:
error_msg = "Failed to attach snapshot [name: %s, id: %s]" \
" to host [%s, %s] with error %s"\
% (snapshot.name, snapshot.id,
host.name, host.id, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def perform_module_operation(self):
"""
Perform different actions on snapshot module based on parameters
chosen in playbook
"""
snapshot_name = self.module.params['snapshot_name']
snapshot_id = self.module.params['snapshot_id']
vol_name = self.module.params['vol_name']
cg_name = self.module.params['cg_name']
auto_delete = self.module.params['auto_delete']
expiry_time = self.module.params['expiry_time']
description = self.module.params['description']
new_snapshot_name = self.module.params['new_snapshot_name']
host_name = self.module.params['host_name']
host_id = self.module.params['host_id']
host_state = self.module.params['host_state']
state = self.module.params['state']
host = None
storage_resource = None
changed = False
LOG.info("Getting Snapshot details")
snapshot = self.get_snapshot_obj(name=snapshot_name, id=snapshot_id)
if snapshot and not snapshot.existed:
snapshot = None
msg = "snapshot details: %s" % str(snapshot)
LOG.info(msg)
# Get Volume Object
if vol_name is not None:
if vol_name == "" or vol_name.isspace():
self.module.fail_json(msg="Invalid vol_name given, Please"
" provide a valid vol_name")
storage_resource = self.get_volume_obj(name=vol_name)
# Get Consistency Group Object
if cg_name is not None:
if cg_name == "" or cg_name.isspace():
self.module.fail_json(msg="Invalid cg_name given, Please"
" provide a valid cg_name")
storage_resource = self.get_cg_obj(name=cg_name)
# Get host object for volume snapshots
if host_id or host_name:
if cg_name:
self.module.fail_json(msg="Mapping CG snapshot to host"
" is not supported.")
host = self.get_host_obj(name=host_name, id=host_id)
# Check whether host_name or host_id is given in input
# along with host_state
if (host and not host_state) or (not host and host_state):
self.module.fail_json(
msg="Either host_name or host_id along with host_state "
"is required to map or unmap a snapshot from a host")
# Check for error, if user tries to create a snapshot with the
# same name for other storage resource.
if snapshot and storage_resource and\
(snapshot.storage_resource.id != storage_resource.id):
self.module.fail_json(
msg="Snapshot %s is of %s storage resource. Cannot create new"
" snapshot with same name for %s storage resource"
% (snapshot.name, snapshot.storage_resource.name,
storage_resource.name))
# check for valid expiry_time
if expiry_time is not None and \
(expiry_time == "" or expiry_time.isspace()):
self.module.fail_json(msg="Please provide valid expiry_time,"
" empty expiry_time given")
# Check if in input auto_delete is True and expiry_time is not None
if expiry_time and auto_delete:
error_msg = "Cannot set expiry_time if auto_delete given as True"
LOG.info(error_msg)
self.module.fail_json(msg=error_msg)
# Check whether to modify the snapshot or not
update_flag = False
if snapshot:
update_flag = self.to_update(snapshot,
new_name=new_snapshot_name,
description=description,
auto_del=auto_delete,
expiry_time=expiry_time,
host=host, host_state=host_state)
msg = "update_flag for snapshot %s" % str(update_flag)
LOG.info(msg)
# Create a Snapshot
if not snapshot and state == "present":
LOG.info("Creating a snapshot")
if snapshot_id:
self.module.fail_json(msg="Creation of Snapshot is allowed"
" using snapshot_name only, "
"snapshot_id given")
if snapshot_name == "" or snapshot_name.isspace():
self.module.fail_json(msg="snapshot_name is required for"
" creation of a snapshot,"
" empty snapshot_name given")
if not storage_resource:
self.module.fail_json(msg="vol_name or cg_name required to"
" create a snapshot")
if new_snapshot_name:
self.module.fail_json(
msg="new_snapshot_name can not be assigned"
" during creation of a snapshot")
snapshot = self.create_snapshot(snapshot_name,
storage_resource.id,
description, auto_delete,
expiry_time)
if host and host_state == "mapped":
self.attach_to_snap(snapshot, host)
changed = True
# Update the Snapshot
if snapshot and state == "present" and update_flag:
LOG.info("Updating the Snapshot details")
if host_state == 'mapped':
self.attach_to_snap(snapshot, host)
self.update_snapshot(
snapshot, new_name=new_snapshot_name,
description=description, auto_del=auto_delete,
expiry_time=expiry_time)
elif host_state == 'unmapped':
host_access_list = create_host_access_list(snapshot,
host,
host_state)
self.update_snapshot(
snapshot, new_name=new_snapshot_name,
description=description, auto_del=auto_delete,
expiry_time=expiry_time,
host_access_list=host_access_list)
else:
self.update_snapshot(
snapshot, new_name=new_snapshot_name,
description=description, auto_del=auto_delete,
expiry_time=expiry_time)
changed = True
# Delete the Snapshot
if state == "absent" and snapshot:
snapshot = self.delete_snapshot(snapshot)
changed = True
# Add snapshot details to the result.
if snapshot:
snapshot.update()
self.result["snapshot_details"] = \
create_snapshot_details_dict(snapshot)
else:
self.result["snapshot_details"] = {}
self.result["changed"] = changed
self.module.exit_json(**self.result)
def create_snapshot_details_dict(snapshot):
""" Add name and id of storage resource and hosts to snapshot details """
snapshot_dict = snapshot._get_properties()
del snapshot_dict['storage_resource']
del snapshot_dict['host_access']
snapshot_dict['hosts_list'] = get_hosts_list(
get_hosts_dict(snapshot))
snapshot_dict['storage_resource_name'] = \
snapshot.storage_resource.name
snapshot_dict['storage_resource_id'] = \
snapshot.storage_resource.id
return snapshot_dict
def get_hosts_list(hosts_dict):
""" Get the host name and host id of all the associated hosts """
hosts_list = []
if not hosts_dict:
return hosts_list
for host in list(hosts_dict.keys()):
hosts_list.append(
{
"host_name": host.name,
"host_id": host.id
}
)
return hosts_list
def create_host_access_list(snapshot, host, host_state):
""" This method creates a List of dictionaries which will be used
to modify the list of hosts mapped to a snapshot """
host_access_list = []
hosts_dict = get_hosts_dict(snapshot)
# If snapshot is not attached to any host.
if not hosts_dict:
return None
if to_update_host_list(snapshot, host, host_state):
if host_state == "mapped":
return None
for snap_host in list(hosts_dict.keys()):
if snap_host != host:
access_dict = {'host': snap_host,
'allowedAccess': hosts_dict[snap_host]}
host_access_list.append(access_dict)
return host_access_list
def get_hosts_dict(snapshot):
""" This method creates a dictionary, with host as key and
allowed access as value """
hosts_dict = {}
LOG.info("Inside get_hosts_dict")
if not snapshot.host_access:
return hosts_dict
for host_access_obj in snapshot.host_access:
hosts_dict[host_access_obj.host] = \
host_access_obj.allowed_access
return hosts_dict
def to_update_host_list(snapshot, host, host_state):
""" Determines whether to update hosts list or not"""
hosts_dict = get_hosts_dict(snapshot)
if (not hosts_dict or host not in list(hosts_dict.keys()))\
and host_state == "mapped":
return True
if (hosts_dict and host in list(hosts_dict.keys())) \
and host_state == "unmapped":
return True
return False
def to_update_expiry_time(snapshot, expiry_time=None):
""" Check whether to update expiry_time or not"""
if not expiry_time:
return False
if snapshot.expiration_time is None:
return True
if convert_timestamp_to_sec(expiry_time, snapshot.expiration_time) != 0:
return True
return False
def convert_timestamp_to_sec(expiry_time, snap_time):
"""Converts the time difference to seconds"""
snap_time_str = snap_time.strftime('%m/%d/%Y %H:%M')
snap_timestamp = datetime.strptime(snap_time_str, '%m/%d/%Y %H:%M')
expiry_timestamp = datetime.strptime(expiry_time, "%m/%d/%Y %H:%M")
return int((expiry_timestamp - snap_timestamp).total_seconds())
def get_snapshot_parameters():
"""This method provide parameter required for the ansible snapshot
module on Unity"""
return dict(
snapshot_name=dict(required=False, type='str'),
snapshot_id=dict(required=False, type='str'),
vol_name=dict(required=False, type='str'),
cg_name=dict(required=False, type='str'),
auto_delete=dict(required=False, type='bool'),
expiry_time=dict(required=False, type='str'),
description=dict(required=False, type='str'),
new_snapshot_name=dict(required=False, type='str'),
host_name=dict(required=False, type='str'),
host_id=dict(required=False, type='str'),
host_state=dict(required=False, type='str',
choices=['mapped', 'unmapped']),
state=dict(required=True, type='str', choices=['present', 'absent'])
)
def main():
""" Create Unity Snapshot object and perform actions on it
based on user input from playbook"""
obj = Snapshot()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,879 @@
#!/usr/bin/python
# Copyright: (c) 2020, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Ansible module for managing storage pool on Unity"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
module: storagepool
version_added: '1.1.0'
short_description: Manage storage pool on Unity
description:
- Managing storage pool on Unity storage system contains the operations
Get details of storage pool,
Create a storage pool,
Modify storage pool.
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Ambuj Dubey (@AmbujDube) <ansible.team@dell.com>
options:
pool_name:
description:
- Name of the storage pool, unique in the storage system.
type: str
pool_id:
description:
- Unique identifier of the pool instance.
type: str
new_pool_name:
description:
- New name of the storage pool, unique in the storage system.
type: str
pool_description:
description:
- The description of the storage pool.
type: str
fast_cache:
description:
- Indicates whether the fast cache is enabled for the storage pool.
- C(Enabled) - FAST Cache is enabled for the pool.
- C(Disabled) - FAST Cache is disabled for the pool.
choices: [enabled, disabled]
type: str
fast_vp:
description:
- Indicates whether to enable scheduled data relocations for the pool.
- C(Enabled) - Enabled scheduled data relocations for the pool.
- C(Disabled) - Disabled scheduled data relocations for the pool.
choices: [enabled, disabled]
type: str
raid_groups:
description:
- Parameters to create RAID group from the disks and add it to the pool.
type: dict
suboptions:
disk_group_id:
description:
- Id of the disk group.
type: str
disk_num:
description:
- Number of disks.
type: int
raid_type:
description:
- RAID group types or RAID levels.
choices: [None, RAID5, RAID0, RAID1, RAID3, RAID10, RAID6, Mixed, Automatic]
type: str
stripe_width :
description:
- RAID group stripe widths, including parity or mirror disks.
choices: ['BEST_FIT', '2', '4', '5', '6', '8', '9', '10', '12', '13', '14', '16']
type: str
alert_threshold:
description:
- Threshold at which the system will generate alerts about the free space in the pool, specified as a percentage.
- Minimum threshold limit is 50.
- Maximum threshold limit is 84.
type: int
is_harvest_enabled:
description:
- Enable/Disable automatic deletion of snapshots based on pool space usage.
type: bool
pool_harvest_high_threshold:
description:
- Max threshold for space used in pool beyond which the system automatically starts deleting snapshots in the pool.
- Applies when the automatic deletion of snapshots based on pool space usage is enabled for the system and pool.
- Minimum pool harvest high threshold value is 1.
- Maximum pool harvest high threshold value is 99.
type: float
pool_harvest_low_threshold:
description:
- Min threshold for space used in pool below which the system automatically stops deletion of snapshots in the pool.
- Applies when the automatic deletion of snapshots based on pool space usage is enabled for the system and pool.
- Minimum pool harvest low threshold value is 0.
- Maximum pool harvest low threshold value is 98.
type: float
is_snap_harvest_enabled:
description:
- Enable/Disable automatic deletion of snapshots based on pool space usage.
type: bool
snap_harvest_high_threshold:
description:
- Max threshold for space used in snapshot beyond which the system automatically starts deleting snapshots in the pool.
- Applies when the automatic deletion of snapshots based on pool space usage is enabled for the pool.
- Minimum snap harvest high threshold value is 1.
- Maximum snap harvest high threshold value is 99.
type: float
snap_harvest_low_threshold:
description:
- Min threshold for space used in snapshot below which the system will stop automatically deleting snapshots in the pool.
- Applies when the automatic deletion of snapshots based on pool space usage is enabled for the pool.
- Minimum snap harvest low threshold value is 0.
- Maximum snap harvest low threshold value is 98.
type: float
pool_type:
description:
- Indicates storage pool type.
choices: [TRADITIONAL, DYNAMIC]
type: str
state:
description:
- Define whether the storage pool should exist or not.
- C(Present) - indicates that the storage pool should exist on the system.
- C(Absent) - indicates that the storage pool should not exist on the system.
choices: [absent, present]
type: str
required: true
notes:
- Deletion of storage pool is not allowed through Ansible module.
- The I(check_mode) is not supported.
'''
EXAMPLES = r'''
- name: Get Storage pool details using pool_name
dellemc.unity.storagepool:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
pool_name: "{{pool_name}}"
state: "present"
- name: Get Storage pool details using pool_id
dellemc.unity.storagepool:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
pool_id: "{{pool_id}}"
state: "present"
- name: Modify Storage pool attributes using pool_name
dellemc.unity.storagepool:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
pool_name: "{{pool_name}}"
new_pool_name: "{{new_pool_name}}"
pool_description: "{{pool_description}}"
fast_cache: "{{fast_cache_enabled}}"
fast_vp: "{{fast_vp_enabled}}"
state: "present"
- name: Modify Storage pool attributes using pool_id
dellemc.unity.storagepool:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
pool_id: "{{pool_id}}"
new_pool_name: "{{new_pool_name}}"
pool_description: "{{pool_description}}"
fast_cache: "{{fast_cache_enabled}}"
fast_vp: "{{fast_vp_enabled}}"
state: "present"
- name: Create a StoragePool
dellemc.unity.storagepool:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
pool_name: "Test"
pool_description: "test pool"
raid_groups:
disk_group_id : "dg_16"
disk_num : 2
raid_type : "RAID10"
stripe_width : "BEST_FIT"
alert_threshold : 50
is_harvest_enabled : True
pool_harvest_high_threshold : 60
pool_harvest_low_threshold : 40
is_snap_harvest_enabled : True
snap_harvest_high_threshold : 70
snap_harvest_low_threshold : 50
fast_vp: "enabled"
fast_cache: "enabled"
pool_type : "DYNAMIC"
state: "present"
'''
RETURN = r'''
changed:
description: Whether or not the storage pool has changed.
returned: always
type: bool
sample: True
storage_pool_details:
description: The storage pool details.
returned: When storage pool exists.
type: dict
contains:
id:
description: Pool id, unique identifier of the pool.
type: str
name:
description: Pool name, unique in the storage system.
type: str
is_fast_cache_enabled:
description: Indicates whether the fast cache is enabled for the storage
pool.
true - FAST Cache is enabled for the pool.
false - FAST Cache is disabled for the pool.
type: bool
is_fast_vp_enabled:
description: Indicates whether to enable scheduled data relocations
for the storage pool.
true - Enabled scheduled data relocations for the pool.
false - Disabled scheduled data relocations for the pool.
type: bool
size_free_with_unit:
description: Indicates size_free with its appropriate unit
in human readable form.
type: str
size_subscribed_with_unit:
description: Indicates size_subscribed with its appropriate unit in
human readable form.
type: str
size_total_with_unit:
description: Indicates size_total with its appropriate unit in human
readable form.
type: str
size_used_with_unit:
description: Indicates size_used with its appropriate unit in human
readable form.
type: str
snap_size_subscribed_with_unit:
description: Indicates snap_size_subscribed with its
appropriate unit in human readable form.
type: str
snap_size_used_with_unit:
description: Indicates snap_size_used with its
appropriate unit in human readable form.
type: str
drives:
description: Indicates information about the drives
associated with the storage pool.
type: list
contains:
id:
description: Unique identifier of the drive.
type: str
name:
description: Indicates name of the drive.
type: str
size:
description: Indicates size of the drive.
type: str
disk_technology:
description: Indicates disk technology of the drive.
type: str
tier_type:
description: Indicates tier type of the drive.
type: str
sample: {
"alert_threshold": 50,
"creation_time": "2022-03-08 14:05:32+00:00",
"description": "",
"drives": [
{
"disk_technology": "SAS",
"id": "dpe_disk_22",
"name": "DPE Drive 22",
"size": 590860984320,
"tier_type": "PERFORMANCE"
},
{
"disk_technology": "SAS",
"id": "dpe_disk_23",
"name": "DPE Drive 23",
"size": 590860984320,
"tier_type": "PERFORMANCE"
},
{
"disk_technology": "SAS",
"id": "dpe_disk_24",
"name": "DPE Drive 24",
"size": 590860984320,
"tier_type": "PERFORMANCE"
}
],
"existed": true,
"harvest_state": "UsageHarvestStateEnum.IDLE",
"hash": 8744642897210,
"health": {
"UnityHealth": {
"hash": 8744642799842
}
},
"id": "pool_280",
"is_all_flash": false,
"is_empty": false,
"is_fast_cache_enabled": false,
"is_fast_vp_enabled": false,
"is_harvest_enabled": true,
"is_snap_harvest_enabled": true,
"metadata_size_subscribed": 105763569664,
"metadata_size_used": 57176752128,
"name": "test_pool",
"object_id": 12884902146,
"pool_fast_vp": {
"UnityPoolFastVp": {
"hash": 8744647518980
}
},
"pool_space_harvest_high_threshold": 59.0,
"pool_space_harvest_low_threshold": 40.0,
"pool_type": "StoragePoolTypeEnum.DYNAMIC",
"raid_type": "RaidTypeEnum.RAID10",
"rebalance_progress": null,
"size_free": 470030483456,
"size_free_with_unit": "437.75 GB",
"size_subscribed": 447215820800,
"size_subscribed_with_unit": "416.5 GB",
"size_total": 574720311296,
"size_total_with_unit": "535.25 GB",
"size_used": 76838068224,
"size_used_with_unit": "71.56 GB",
"snap_size_subscribed": 128851369984,
"snap_size_subscribed_with_unit": "120.0 GB",
"snap_size_used": 2351104,
"snap_size_used_with_unit": "2.24 MB",
"snap_space_harvest_high_threshold": 80.0,
"snap_space_harvest_low_threshold": 60.0,
"tiers": {
"UnityPoolTierList": [
{
"disk_count": [
0,
3,
0
],
"existed": true,
"hash": 8744643017382,
"name": [
"Extreme Performance",
"Performance",
"Capacity"
],
"pool_units": [
null,
{
"UnityPoolUnitList": [
{
"UnityPoolUnit": {
"hash": 8744642786759,
"id": "rg_4"
}
},
{
"UnityPoolUnit": {
"hash": 8744642786795,
"id": "rg_5"
}
}
]
},
null
],
"raid_type": [
"RaidTypeEnum.NONE",
"RaidTypeEnum.RAID10",
"RaidTypeEnum.NONE"
],
"size_free": [
0,
470030483456,
0
],
"size_moving_down": [
0,
0,
0
],
"size_moving_up": [
0,
0,
0
],
"size_moving_within": [
0,
0,
0
],
"size_total": [
0,
574720311296,
0
],
"size_used": [
0,
104689827840,
0
],
"stripe_width": [
null,
"RaidStripeWidthEnum._2",
null
],
"tier_type": [
"TierTypeEnum.EXTREME_PERFORMANCE",
"TierTypeEnum.PERFORMANCE",
"TierTypeEnum.CAPACITY"
]
}
]
}
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
import logging
LOG = utils.get_logger('storagepool')
application_type = "Ansible/1.5.0"
class StoragePool(object):
"""Class with storage pool operations"""
def __init__(self):
""" Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_storagepool_parameters())
mutually_exclusive = [['pool_name', 'pool_id']]
required_one_of = [['pool_name', 'pool_id']]
# initialize the Ansible module
self.module = AnsibleModule(argument_spec=self.module_params,
supports_check_mode=False,
mutually_exclusive=mutually_exclusive,
required_one_of=required_one_of)
utils.ensure_required_libs(self.module)
self.conn = utils.\
get_unity_unisphere_connection(self.module.params, application_type)
def get_details(self, pool_id=None, pool_name=None):
""" Get storage pool details"""
try:
api_response = self.conn.get_pool(_id=pool_id, name=pool_name)
details = api_response._get_properties()
is_fast_vp_enabled = api_response._get_property_from_raw(
'pool_fast_vp').is_schedule_enabled
details['is_fast_vp_enabled'] = is_fast_vp_enabled
details['size_free_with_unit'] = utils.\
convert_size_with_unit(int(details['size_free']))
details['size_subscribed_with_unit'] = utils.\
convert_size_with_unit(int(details['size_subscribed']))
details['size_total_with_unit'] = utils.\
convert_size_with_unit(int(details['size_total']))
details['size_used_with_unit'] = utils.\
convert_size_with_unit(int(details['size_used']))
details['snap_size_subscribed_with_unit'] = utils.\
convert_size_with_unit(int(details['snap_size_subscribed']))
details['snap_size_used_with_unit'] = utils.\
convert_size_with_unit(int(details['snap_size_used']))
pool_instance = utils.UnityPool.get(self.conn._cli, details['id'])
pool_tier_list = []
pool_tier_list.append((pool_instance.tiers)._get_properties())
pool_tier_dict = {}
pool_tier_dict['UnityPoolTierList'] = pool_tier_list
details['tiers'] = pool_tier_dict
return details
except Exception as e:
error = str(e)
check_list = ['not found', 'no attribute']
if any(ele in error for ele in check_list):
error_message = "pool details are not found"
LOG.info(error_message)
return None
error_message = 'Get details of storage pool failed with ' \
'error: {0}'.format(str(e))
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def is_pool_modification_required(self, storage_pool_details):
""" Check if attributes of storage pool needs to be modified
"""
try:
if self.module.params['new_pool_name'] and \
self.module.params['new_pool_name'] != \
storage_pool_details['name']:
return True
if self.module.params['pool_description'] is not None and \
self.module.params['pool_description'] != \
storage_pool_details['description']:
return True
if self.module.params['fast_cache']:
if (self.module.params['fast_cache'] == "enabled" and
not storage_pool_details['is_fast_cache_enabled']) or\
(self.module.params['fast_cache'] == "disabled" and storage_pool_details['is_fast_cache_enabled']):
return True
if self.module.params['fast_vp']:
if (self.module.params['fast_vp'] == "enabled" and
not storage_pool_details['is_fast_vp_enabled']) or \
(self.module.params['fast_vp'] == "disabled" and
storage_pool_details['is_fast_vp_enabled']):
return True
LOG.info("modify not required")
return False
except Exception as e:
error_message = 'Failed to determine if any modification'\
'required for pool attributes with error: {0}'.format(str(e))
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def pool_modify(self, id, new_pool_name,
pool_description, fast_cache, fast_vp):
""" Modify attributes of storage pool """
pool_obj = utils.UnityPool.get(self.conn._cli, id)
try:
pool_obj.modify(name=new_pool_name, description=pool_description,
is_fast_cache_enabled=fast_cache,
is_fastvp_enabled=fast_vp)
new_storage_pool_details = self.get_details(pool_id=id,
pool_name=None)
LOG.info("Modification Successful")
return new_storage_pool_details
except Exception as e:
if self.module.params['pool_id']:
pool_identifier = self.module.params['pool_id']
else:
pool_identifier = self.module.params['pool_name']
error_message = 'Modify attributes of storage pool {0} ' \
'failed with error: {1}'.format(pool_identifier, str(e))
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def get_pool_drives(self, pool_id=None, pool_name=None):
""" Get pool drives attached to pool"""
pool_identifier = pool_id or pool_name
pool_drives_list = []
try:
drive_instances = utils.UnityDiskList.get(self.conn._cli)
if drive_instances:
for drive in drive_instances:
if drive.pool and (drive.pool.id == pool_identifier or drive.pool.name == pool_identifier):
pool_drive = {"id": drive.id, "name": drive.name, "size": drive.size,
"disk_technology": drive.disk_technology.name,
"tier_type": drive.tier_type.name}
pool_drives_list.append(pool_drive)
LOG.info("Successfully retrieved pool drive details")
return pool_drives_list
except Exception as e:
error_message = 'Get details of pool drives failed with ' \
'error: {0}'.format(str(e))
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def get_raid_type_enum(self, raid_type):
""" Get raid_type_enum.
:param raid_type: The raid_type
:return: raid_type enum
"""
if raid_type in utils.RaidTypeEnum.__members__:
return utils.RaidTypeEnum[raid_type]
else:
errormsg = "Invalid choice %s for Raid Type" % raid_type
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def get_raid_stripe_width_enum(self, stripe_width):
""" Get raid_stripe_width enum.
:param stripe_width: The raid_stripe_width
:return: raid_stripe_width enum
"""
if stripe_width != "BEST_FIT":
stripe_width = "_" + stripe_width
if stripe_width in utils.RaidStripeWidthEnum.__members__:
return utils.RaidStripeWidthEnum[stripe_width]
else:
errormsg = "Invalid choice %s for stripe width" % stripe_width
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def get_pool_type_enum(self, pool_type):
""" Get the storage pool_type enum.
:param pool_type: The pool_type
:return: pool_type enum
"""
if pool_type == "TRADITIONAL":
return 1
elif pool_type == "DYNAMIC":
return 2
else:
errormsg = "Invalid choice %s for Storage Pool Type" % pool_type
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def get_raid_groups(self, raid_groups):
""" Get the raid groups for creating pool"""
try:
disk_obj = utils.UnityDiskGroup.get(self.conn._cli, _id=raid_groups['disk_group_id'])
disk_num = raid_groups['disk_num']
raid_type = raid_groups['raid_type']
raid_type = self.get_raid_type_enum(raid_type) \
if raid_type else None
stripe_width = raid_groups['stripe_width']
stripe_width = self.get_raid_stripe_width_enum(stripe_width) \
if stripe_width else None
raid_group = utils.RaidGroupParameter(disk_group=disk_obj,
disk_num=disk_num, raid_type=raid_type,
stripe_width=stripe_width)
raid_groups = [raid_group]
return raid_groups
except Exception as e:
error_message = 'Failed to create storage pool with error: %s' % str(e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def validate_create_pool_params(self, alert_threshold=None,
pool_harvest_high_threshold=None,
pool_harvest_low_threshold=None,
snap_harvest_high_threshold=None,
snap_harvest_low_threshold=None):
""" Validates params for creating pool"""
if alert_threshold and (alert_threshold < 50 or alert_threshold > 84):
errormsg = "Alert threshold is not in the allowed value range of 50 - 84"
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
if pool_harvest_high_threshold and (pool_harvest_high_threshold < 1 or pool_harvest_high_threshold > 99):
errormsg = "Pool harvest high threshold is not in the allowed value range of 1 - 99"
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
if pool_harvest_low_threshold and (pool_harvest_low_threshold < 0 or pool_harvest_low_threshold > 98):
errormsg = "Pool harvest low threshold is not in the allowed value range of 0 - 98"
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
if snap_harvest_high_threshold and (snap_harvest_high_threshold < 1 or snap_harvest_high_threshold > 99):
errormsg = "Snap harvest high threshold is not in the allowed value range of 1 - 99"
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
if snap_harvest_low_threshold and (snap_harvest_low_threshold < 0 or snap_harvest_low_threshold > 98):
errormsg = "Snap harvest low threshold is not in the allowed value range of 0 - 98"
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def create_pool(self, name, raid_groups):
""" Creates a StoragePool"""
try:
pool_obj = utils.UnityPool.get(self.conn._cli)
pool_description = self.module.params['pool_description']
raid_groups = self.get_raid_groups(raid_groups) \
if raid_groups else None
alert_threshold = self.module.params['alert_threshold']
pool_harvest_high_threshold = None
pool_harvest_low_threshold = None
snap_harvest_high_threshold = None
snap_harvest_low_threshold = None
is_harvest_enabled = self.module.params['is_harvest_enabled']
if is_harvest_enabled:
pool_harvest_high_threshold = self.module.params['pool_harvest_high_threshold']
pool_harvest_low_threshold = self.module.params['pool_harvest_low_threshold']
is_snap_harvest_enabled = self.module.params['is_snap_harvest_enabled']
if is_snap_harvest_enabled:
snap_harvest_high_threshold = self.module.params['snap_harvest_high_threshold']
snap_harvest_low_threshold = self.module.params['snap_harvest_low_threshold']
self.validate_create_pool_params(alert_threshold=alert_threshold,
pool_harvest_high_threshold=pool_harvest_high_threshold,
pool_harvest_low_threshold=pool_harvest_low_threshold,
snap_harvest_high_threshold=snap_harvest_high_threshold,
snap_harvest_low_threshold=snap_harvest_low_threshold)
pool_type = self.module.params['pool_type']
pool_type = self.get_pool_type_enum(pool_type) \
if pool_type else None
fast_vp = self.module.params['fast_vp']
if fast_vp:
if fast_vp == "enabled":
fast_vp = True
else:
fast_vp = False
pool_obj.create(self.conn._cli, name=name, description=pool_description, raid_groups=raid_groups,
alert_threshold=alert_threshold,
is_harvest_enabled=is_harvest_enabled,
is_snap_harvest_enabled=is_snap_harvest_enabled,
pool_harvest_high_threshold=pool_harvest_high_threshold,
pool_harvest_low_threshold=pool_harvest_low_threshold,
snap_harvest_high_threshold=snap_harvest_high_threshold,
snap_harvest_low_threshold=snap_harvest_low_threshold,
is_fastvp_enabled=fast_vp,
pool_type=pool_type)
LOG.info("Creation of storage pool successful")
storage_pool_details = self.get_details(pool_name=name)
changed = True
return changed, storage_pool_details
except Exception as e:
error_message = 'Failed to create storage pool with error: %s' % str(e)
LOG.error(error_message)
self.module.fail_json(msg=error_message)
def perform_module_operation(self):
"""
Perform different actions on storage pool module based on parameters
chosen in playbook
"""
pool_name = self.module.params['pool_name']
pool_id = self.module.params['pool_id']
new_pool_name = self.module.params['new_pool_name']
pool_description = self.module.params['pool_description']
fast_cache = self.module.params['fast_cache']
fast_vp = self.module.params['fast_vp']
state = self.module.params['state']
raid_groups = self.module.params['raid_groups']
if fast_cache:
if fast_cache == "enabled":
fast_cache = True
else:
fast_cache = False
if fast_vp:
if fast_vp == "enabled":
fast_vp = True
else:
fast_vp = False
# result is a dictionary that contains changed status and storage pool details
result = dict(
changed=False,
storage_pool_details={}
)
storage_pool_details = self.get_details(pool_id, pool_name)
result['storage_pool_details'] = storage_pool_details
if state == 'absent' and storage_pool_details:
error_message = 'Deletion of storage pool is not allowed through'\
' Ansible module'
LOG.error(error_message)
self.module.fail_json(msg=error_message)
# Create storage pool
if state == 'present' and not storage_pool_details:
if pool_name is not None and len(pool_name) != 0:
result['changed'], storage_pool_details \
= self.create_pool(name=pool_name, raid_groups=raid_groups)
result['storage_pool_details'] = storage_pool_details
else:
error_message = 'The parameter pool_name length is 0. It'\
' is too short. The min length is 1'
LOG.error(error_message)
self.module.fail_json(msg=error_message)
# Get pool drive details
if result['storage_pool_details']:
result['storage_pool_details']['drives'] = self.get_pool_drives(pool_id=pool_id, pool_name=pool_name)
if state == 'present' and storage_pool_details:
if new_pool_name is not None and len(new_pool_name) == 0:
error_message = 'The parameter new_pool_name length is 0. It'\
' is too short. The min length is 1'
LOG.error(error_message)
self.module.fail_json(msg=error_message)
pool_modify_flag = self.\
is_pool_modification_required(storage_pool_details)
LOG.info("Storage pool modification flag %s",
str(pool_modify_flag))
if pool_modify_flag:
result['storage_pool_details'] = \
self.pool_modify(storage_pool_details['id'], new_pool_name,
pool_description, fast_cache, fast_vp)
result['changed'] = True
self.module.exit_json(**result)
def get_storagepool_parameters():
"""This method provides parameters required for the ansible storage pool
module on Unity"""
return dict(
pool_name=dict(required=False, type='str'),
pool_id=dict(required=False, type='str'),
new_pool_name=dict(required=False, type='str'),
pool_description=dict(required=False, type='str'),
fast_cache=dict(required=False, type='str', choices=['enabled',
'disabled']),
fast_vp=dict(required=False, type='str', choices=['enabled',
'disabled']),
state=dict(required=True, type='str', choices=['present', 'absent']),
raid_groups=dict(required=False, type='dict', options=dict(
disk_group_id=dict(required=False, type='str'),
disk_num=dict(required=False, type='int'),
raid_type=dict(required=False, type='str', choices=['None', 'RAID5', 'RAID0', 'RAID1', 'RAID3', 'RAID10',
'RAID6', 'Mixed', 'Automatic']),
stripe_width=dict(required=False, type='str', choices=['BEST_FIT', '2', '4', '5',
'6', '8', '9', '10', '12', '13', '14', '16']))),
alert_threshold=dict(required=False, type='int'),
is_harvest_enabled=dict(required=False, type='bool'),
pool_harvest_high_threshold=dict(required=False, type='float'),
pool_harvest_low_threshold=dict(required=False, type='float'),
is_snap_harvest_enabled=dict(required=False, type='bool'),
snap_harvest_high_threshold=dict(required=False, type='float'),
snap_harvest_low_threshold=dict(required=False, type='float'),
pool_type=dict(required=False, type='str', choices=['TRADITIONAL', 'DYNAMIC'])
)
def main():
""" Create Unity storage pool object and perform action on it
based on user input from playbook"""
obj = StoragePool()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,708 @@
#!/usr/bin/python
# Copyright: (c) 2021, Dell Technologies
# Apache License version 2.0 (see MODULE-LICENSE or http://www.apache.org/licenses/LICENSE-2.0.txt)
"""Ansible module for managing quota tree on Unity"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
---
module: tree_quota
short_description: Manage quota tree on the Unity storage system
description:
- Managing Quota tree on the Unity storage system includes
Create quota tree,
Get quota tree,
Modify quota tree and
Delete quota tree.
version_added: '1.2.0'
extends_documentation_fragment:
- dellemc.unity.unity
author:
- Spandita Panigrahi (@panigs7) <ansible.team@dell.com>
options:
filesystem_name:
description:
- The name of the filesystem for which quota tree is created.
- For creation or modification of a quota tree either I(filesystem_name) or
I(filesystem_id) is required.
type: str
filesystem_id:
description:
- The ID of the filesystem for which the quota tree is created.
- For creation of a quota tree either I(filesystem_id) or
I(filesystem_name) is required.
type: str
nas_server_name:
description:
- The name of the NAS server in which the filesystem is created.
- For creation of a quota tree either I(nas_server_name) or
I(nas_server_id) is required.
type: str
nas_server_id:
description:
- The ID of the NAS server in which the filesystem is created.
- For creation of a quota tree either I(filesystem_id) or
I(filesystem_name) is required.
type: str
tree_quota_id:
description:
- The ID of the quota tree.
- Either I(tree_quota_id) or I(path) to quota tree is required to
view/modify/delete quota tree.
type: str
path:
description:
- The path to the quota tree.
- Either I(tree_quota_id) or I(path) to quota tree is required to
create/view/modify/delete a quota tree.
- Path must start with a forward slash '/'.
type: str
hard_limit:
description:
- Hard limitation for a quota tree on the total space available. If exceeded,
users in quota tree cannot write data.
- Value C(0) implies no limit.
- One of the values of I(soft_limit) and I(hard_limit) can be C(0), however, both cannot be both C(0)
during creation of a quota tree.
type: int
soft_limit:
description:
- Soft limitation for a quota tree on the total space available. If exceeded,
notification will be sent to users in the quota tree for the grace period mentioned, beyond
which users cannot use space.
- Value C(0) implies no limit.
- Both I(soft_limit) and I(hard_limit) cannot be C(0) during creation of quota tree.
type: int
cap_unit:
description:
- Unit of I(soft_limit) and I(hard_limit) size.
- It defaults to C(GB) if not specified.
choices: ['MB', 'GB', 'TB']
type: str
description:
description:
- Description of a quota tree.
type: str
state:
description:
- The state option is used to mention the existence of the filesystem
quota tree.
type: str
required: true
choices: ['absent', 'present']
notes:
- The I(check_mode) is not supported.
'''
EXAMPLES = r'''
- name: Get quota tree details by quota tree id
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
tree_quota_id: "treequota_171798700679_10"
state: "present"
- name: Get quota tree details by quota tree path
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_name: "fs_2171"
nas_server_id: "nas_21"
path: "/test"
state: "present"
- name: Create quota tree for a filesystem with filesystem id
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_id: "fs_2171"
hard_limit: 6
cap_unit: "TB"
soft_limit: 5
path: "/test_new"
state: "present"
- name: Create quota tree for a filesystem with filesystem name
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_name: "Test_filesystem"
nas_server_name: "lglad068"
hard_limit: 6
cap_unit: "TB"
soft_limit: 5
path: "/test_new"
state: "present"
- name: Modify quota tree limit usage by quota tree path
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
path: "/test_new"
hard_limit: 10
cap_unit: "TB"
soft_limit: 8
state: "present"
- name: Modify quota tree by quota tree id
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_id: "fs_2171"
tree_quota_id: "treequota_171798700679_10"
hard_limit: 12
cap_unit: "TB"
soft_limit: 10
state: "present"
- name: Delete quota tree by quota tree id
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_id: "fs_2171"
tree_quota_id: "treequota_171798700679_10"
state: "absent"
- name: Delete quota tree by path
dellemc.unity.tree_quota:
unispherehost: "{{unispherehost}}"
username: "{{username}}"
password: "{{password}}"
validate_certs: "{{validate_certs}}"
filesystem_id: "fs_2171"
path: "/test_new"
state: "absent"
'''
RETURN = r'''
changed:
description: Whether or not the resource has changed.
returned: always
type: bool
sample: True
get_tree_quota_details:
description: Details of the quota tree.
returned: When quota tree exists
type: dict
contains:
filesystem:
description: Filesystem details for which the quota
tree is created.
type: dict
contains:
UnityFileSystem:
description: Filesystem details for which the
quota tree is created.
type: dict
contains:
id:
description: ID of the filesystem for
which the quota tree is create.
type: str
description:
description: Description of the quota tree.
type: str
path:
description: Path to quota tree.
A valid path must start with a forward slash '/'.
It is mandatory while creating a quota tree.
type: str
hard_limit:
description: Hard limit of quota tree.
If the quota tree's space usage exceeds
the hard limit, users in quota tree cannot write data.
type: int
soft_limit:
description: Soft limit of the quota tree.
If the quota tree's space usage exceeds the soft limit,
the storage system starts to count down based
on the specified grace period.
type: int
id:
description: Quota tree ID.
type: str
size_used:
description: Size of used space in the filesystem by the user files.
type: int
gp_left:
description: The grace period left after the
soft limit for the user quota is exceeded.
type: int
state:
description: State of the quota tree.
type: int
sample: {
"description": "",
"existed": true,
"filesystem": {
"UnityFileSystem": {
"hash": 8788549469862,
"id": "fs_137",
"name": "test",
"nas_server": {
"id": "nas_1",
"name": "lglad072"
}
}
},
"gp_left": null,
"hard_limit": "6.0 TB",
"hash": 8788549497558,
"id": "treequota_171798694897_1",
"path": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"size_used": 0,
"soft_limit": "5.0 TB",
"state": 0
}
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
import utils
LOG = utils.get_logger('tree_quota')
application_type = "Ansible/1.5.0"
class QuotaTree(object):
"""Class with Quota Tree operations"""
def __init__(self):
"""Define all parameters required by this module"""
self.module_params = utils.get_unity_management_host_parameters()
self.module_params.update(get_quota_tree_parameters())
mutually_exclusive = [['filesystem_name', 'filesystem_id'],
['nas_server_name', 'nas_server_id']]
# initialize the Ansible module
self.module = AnsibleModule(
argument_spec=self.module_params,
supports_check_mode=False,
mutually_exclusive=mutually_exclusive)
utils.ensure_required_libs(self.module)
self.unity_conn = utils.get_unity_unisphere_connection(
self.module.params, application_type)
def check_quota_tree_is_present(self, fs_id, path, tree_quota_id):
"""
Check if quota tree is present in filesystem.
:param fs_id: ID of filesystem where quota tree is searched.
:param path: Path to the quota tree
:param tree_quota_id: ID of the quota tree
:return: ID of quota tree if it exists else None.
"""
if tree_quota_id is None and path is None:
return None
all_tree_quota = self.unity_conn.get_tree_quota(filesystem=fs_id,
id=tree_quota_id,
path=path)
if tree_quota_id and len(all_tree_quota) == 0 \
and self.module.params['state'] == "present":
errormsg = "Tree quota %s does not exist." % tree_quota_id
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
if len(all_tree_quota) > 0:
msg = "Quota tree with id %s is present in filesystem %s" % (all_tree_quota[0].id,
fs_id)
LOG.info(msg)
return all_tree_quota[0].id
else:
return None
def create_quota_tree(self, fs_id, soft_limit, hard_limit, unit, path, description):
"""
Create quota tree of a filesystem.
:param fs_id: ID of filesystem where quota tree is to be created.
:param soft_limit: Soft limit
:param hard_limit: Hard limit
:param unit: Unit of soft limit and hard limit
:param path: Path to quota tree
:param description: Description for quota tree
:return: Dict containing new quota tree details.
"""
if soft_limit is None and hard_limit is None:
errormsg = "Both soft limit and hard limit cannot be empty. " \
"Please provide atleast one to create quota tree."
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
soft_limit_in_bytes = utils.get_size_bytes(soft_limit, unit)
hard_limit_in_bytes = utils.get_size_bytes(hard_limit, unit)
try:
obj_tree_quota = self.unity_conn.create_tree_quota(filesystem_id=fs_id, hard_limit=hard_limit_in_bytes,
soft_limit=soft_limit_in_bytes, path=path,
description=description)
LOG.info("Successfully created quota tree")
if obj_tree_quota:
return obj_tree_quota
else:
return None
except Exception as e:
errormsg = "Create quota tree operation at path {0} failed in filesystem {1}" \
" with error {2}".format(path, fs_id, str(e))
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def get_filesystem_tree_quota_display_attributes(self, tree_quota_id):
"""Display quota tree attributes
:param tree_quota_id: Quota tree ID
:return: Quota tree dict to display
"""
try:
tree_quota_obj = self.unity_conn.get_tree_quota(_id=tree_quota_id)
tree_quota_details = tree_quota_obj._get_properties()
if tree_quota_obj and tree_quota_obj.existed:
tree_quota_details['soft_limit'] = utils. \
convert_size_with_unit(int(tree_quota_details['soft_limit']))
tree_quota_details['hard_limit'] = utils. \
convert_size_with_unit(int(tree_quota_details['hard_limit']))
tree_quota_details['filesystem']['UnityFileSystem']['name'] = \
tree_quota_obj.filesystem.name
tree_quota_details['filesystem']['UnityFileSystem'].update(
{'nas_server': {'name': tree_quota_obj.filesystem.nas_server.name,
'id': tree_quota_obj.filesystem.nas_server.id}})
return tree_quota_details
except Exception as e:
errormsg = "Failed to display quota tree details {0} with " \
"error {1}".format(tree_quota_obj.id, str(e))
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def get_filesystem(self, nas_server=None, name=None, id=None):
"""
Get filesystem details.
:param nas_server: Nas server object.
:param name: Name of filesystem.
:param id: ID of filesystem.
:return: Dict containing filesystem details if it exists.
"""
id_or_name = id if id else name
try:
obj_fs = None
if name:
if not nas_server:
err_msg = "NAS Server is required to get the FileSystem."
LOG.error(err_msg)
self.module.fail_json(msg=err_msg)
obj_fs = self.unity_conn.get_filesystem(name=name,
nas_server=nas_server)
if obj_fs and obj_fs.existed:
LOG.info("Successfully got the filesystem object %s.",
obj_fs)
return obj_fs
if id:
if nas_server:
obj_fs = self.unity_conn \
.get_filesystem(id=id, nas_server=nas_server)
else:
obj_fs = self.unity_conn.get_filesystem(id=id)
if obj_fs and obj_fs.existed:
LOG.info("Successfully got the filesystem object %s.",
obj_fs)
return obj_fs
except Exception as e:
error_msg = "Failed to get filesystem %s with error %s." \
% (id_or_name, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def get_nas_server_obj(self, name=None, id=None):
"""
Get nas server details.
:param name: Nas server name.
:param id: Nas server ID.
:return: Dict containing nas server details if it exists.
"""
nas_server = id if id else name
error_msg = ("Failed to get NAS server %s." % nas_server)
try:
obj_nas = self.unity_conn.get_nas_server(_id=id, name=name)
if name and obj_nas.existed:
LOG.info("Successfully got the NAS server object %s.",
obj_nas)
return obj_nas
elif id and obj_nas.existed:
LOG.info("Successfully got the NAS server object %s.",
obj_nas)
return obj_nas
else:
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
except Exception as e:
error_msg = "Failed to get NAS server %s with error %s." \
% (nas_server, str(e))
LOG.error(error_msg)
self.module.fail_json(msg=error_msg)
def modify_tree_quota(self, tree_quota_id, soft_limit, hard_limit, unit, description):
"""
Modify quota tree of filesystem.
:param tree_quota_id: ID of the quota tree
:param soft_limit: Soft limit
:param hard_limit: Hard limit
:param unit: Unit of soft limit and hard limit
:param description: Description of quota tree
:return: Boolean value whether modify quota tree operation is successful.
"""
try:
if soft_limit is None and hard_limit is None:
return False
tree_quota_obj = self.unity_conn.get_tree_quota(tree_quota_id)._get_properties()
if soft_limit is None:
soft_limit_in_bytes = tree_quota_obj['soft_limit']
else:
soft_limit_in_bytes = utils.get_size_bytes(soft_limit, unit)
if hard_limit is None:
hard_limit_in_bytes = tree_quota_obj['hard_limit']
else:
hard_limit_in_bytes = utils.get_size_bytes(hard_limit, unit)
if description is None:
description = tree_quota_obj['description']
if tree_quota_obj:
if tree_quota_obj['soft_limit'] == soft_limit_in_bytes and \
tree_quota_obj['hard_limit'] == hard_limit_in_bytes and \
tree_quota_obj['description'] == description:
return False
else:
modify_tree_quota = self.unity_conn.modify_tree_quota(tree_quota_id=tree_quota_id,
hard_limit=hard_limit_in_bytes,
soft_limit=soft_limit_in_bytes,
description=description)
LOG.info("Successfully modified quota tree")
if modify_tree_quota:
return True
except Exception as e:
errormsg = "Modify quota tree operation {0} failed" \
" with error {1}".format(tree_quota_id, str(e))
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def delete_tree_quota(self, tree_quota_id):
"""
Delete quota tree of a filesystem.
:param tree_quota_id: ID of quota tree
:return: Boolean whether quota tree is deleted
"""
try:
delete_tree_quota_obj = self.unity_conn.delete_tree_quota(tree_quota_id=tree_quota_id)
if delete_tree_quota_obj:
return True
except Exception as e:
errormsg = "Delete operation of quota tree id:{0} " \
"failed with error {1}".format(tree_quota_id,
str(e))
LOG.error(errormsg)
self.module.fail_json(msg=errormsg)
def perform_module_operation(self):
"""
Perform different actions on quota tree module based on parameters
passed in the playbook
"""
filesystem_id = self.module.params['filesystem_id']
filesystem_name = self.module.params['filesystem_name']
nas_server_name = self.module.params['nas_server_name']
nas_server_id = self.module.params['nas_server_id']
cap_unit = self.module.params['cap_unit']
state = self.module.params['state']
hard_limit = self.module.params['hard_limit']
soft_limit = self.module.params['soft_limit']
path = self.module.params['path']
description = self.module.params['description']
tree_quota_id = self.module.params['tree_quota_id']
create_tree_quota_obj = None
nas_server_resource = None
get_unity_quota_tree_details = None
fs_id = None
changed = False
'''
result is a dictionary to contain end state and quota tree details
'''
result = dict(
changed=False,
create_tree_quota=False,
modify_tree_quota=False,
get_tree_quota_details={},
delete_tree_quota=False
)
if (soft_limit or hard_limit) and cap_unit is None:
cap_unit = 'GB'
if soft_limit and utils.is_size_negative(soft_limit):
error_message = "Invalid soft_limit provided, " \
"must be greater than or equal to 0"
LOG.error(error_message)
self.module.fail_json(msg=error_message)
if hard_limit and utils.is_size_negative(hard_limit):
error_message = "Invalid hard_limit provided, " \
"must be greater than or equal to 0"
LOG.error(error_message)
self.module.fail_json(msg=error_message)
'''
Get NAS server Object
'''
if nas_server_name is not None:
if utils.is_input_empty(nas_server_name):
self.module.fail_json(msg="Invalid nas_server_name given,"
" Please provide a valid name.")
nas_server_resource = self \
.get_nas_server_obj(name=nas_server_name)
elif nas_server_id is not None:
if utils.is_input_empty(nas_server_id):
self.module.fail_json(msg="Invalid nas_server_id given,"
" Please provide a valid ID.")
nas_server_resource = self.get_nas_server_obj(id=nas_server_id)
'''
Get filesystem Object
'''
if filesystem_name is not None:
if utils.is_input_empty(filesystem_name):
self.module.fail_json(msg="Invalid filesystem_name given,"
" Please provide a valid name.")
filesystem_obj = self \
.get_filesystem(nas_server=nas_server_resource,
name=filesystem_name)
fs_id = filesystem_obj.id
elif filesystem_id is not None:
if utils.is_input_empty(filesystem_id):
self.module.fail_json(msg="Invalid filesystem_id given,"
" Please provide a valid ID.")
filesystem_obj = self \
.get_filesystem(id=filesystem_id)
if filesystem_obj:
fs_id = filesystem_obj[0].id
else:
self.module.fail_json(msg="Filesystem does not exist.")
'''
Validate path to quota tree
'''
if path is not None:
if utils.is_input_empty(path):
self.module.fail_json(msg=" Please provide a valid path.")
elif not path.startswith('/'):
self.module.fail_json(msg="The path is relative to the root of the file system "
"and must start with a forward slash '/'.")
if filesystem_id is None and filesystem_name is None:
self.module.fail_json(msg="Please provide either filesystem_name or fileystem_id.")
quota_tree_id_present = self.check_quota_tree_is_present(fs_id, path, tree_quota_id)
tree_quota_id = quota_tree_id_present
'''
Create quota tree
'''
if (filesystem_id or filesystem_name) and path is not None and state == "present":
if not tree_quota_id:
LOG.info("Creating quota tree")
create_tree_quota_obj = self.create_quota_tree(fs_id, soft_limit, hard_limit,
cap_unit, path, description)
if create_tree_quota_obj:
tree_quota_id = create_tree_quota_obj.id
result['create_tree_quota'] = True
'''
Modify quota tree
'''
if tree_quota_id and state == "present":
LOG.info("Modifying quota tree")
result['modify_tree_quota'] = self.modify_tree_quota(tree_quota_id, soft_limit, hard_limit, cap_unit,
description)
'''
Delete quota tree
'''
if tree_quota_id is not None and state == "absent":
LOG.info("Deleting quota tree")
result['delete_tree_quota'] = self.delete_tree_quota(tree_quota_id)
'''
Get quota tree details
'''
if state == "present" and tree_quota_id is not None:
result['get_tree_quota_details'] = self.get_filesystem_tree_quota_display_attributes(tree_quota_id)
else:
result['get_tree_quota_details'] = {}
if result['create_tree_quota'] or result['modify_tree_quota'] or result['delete_tree_quota']:
result['changed'] = True
self.module.exit_json(**result)
def get_quota_tree_parameters():
"""This method provide parameters required for the ansible
quota tree module on Unity"""
return dict(
filesystem_id=dict(required=False, type='str'),
filesystem_name=dict(required=False, type='str'),
state=dict(required=True, type='str', choices=['present', 'absent']),
hard_limit=dict(required=False, type='int'),
soft_limit=dict(required=False, type='int'),
cap_unit=dict(required=False, type='str', choices=['MB', 'GB', 'TB']),
tree_quota_id=dict(required=False, type='str'),
nas_server_name=dict(required=False, type='str'),
nas_server_id=dict(required=False, type='str'),
path=dict(required=False, type='str', no_log=True),
description=dict(required=False, type='str')
)
def main():
""" Create Unity quota tree object and perform action on it
based on user input from playbook"""
obj = QuotaTree()
obj.perform_module_operation()
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,3 @@
urllib3
storops>=1.2.11
setuptools

View File

@@ -0,0 +1,3 @@
---
collections:
- name: dellemc.unity