Debian Codegraph @

ansible_collections/dellemc/unity/plugins/modules/info.py

raw symbols SCIP
1 #!/usr/bin/python
2 # Copyright: (c) 2020-2025, Dell Technologies
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 """Ansible module for Gathering information about Unity"""
6
7 from __future__ import absolute_import, division, print_function
8
9 __metaclass__ = type
10
11 DOCUMENTATION = r'''
12 ---
13 module: info
14
15 version_added: '1.1.0'
16
17 short_description: Gathering information about Unity
18
19 description:
20 - Gathering information about Unity storage system includes
21 Get the details of Unity array,
22 Get list of Hosts in Unity array,
23 Get list of FC initiators in Unity array,
24 Get list of iSCSI initiators in Unity array,
25 Get list of Consistency groups in Unity array,
26 Get list of Storage pools in Unity array,
27 Get list of Volumes in Unity array,
28 Get list of Snapshot schedules in Unity array,
29 Get list of NAS servers in Unity array,
30 Get list of File systems in Unity array,
31 Get list of Snapshots in Unity array,
32 Get list of SMB shares in Unity array,
33 Get list of NFS exports in Unity array,
34 Get list of User quotas in Unity array,
35 Get list of Quota tree in Unity array,
36 Get list of NFS Servers in Unity array,
37 Get list of CIFS Servers in Unity array.
38 Get list of Ethernet ports in Unity array.
39 Get list of File interfaces used in Unity array.
40 Get list of Replication sessions in Unity array.
41
42 extends_documentation_fragment:
43 - dellemc.unity.unity
44
45 author:
46 - Rajshree Khare (@kharer5) <[email protected]>
47 - Akash Shendge (@shenda1) <[email protected]>
48 - Meenakshi Dembi (@dembim) <[email protected]>
49
50 options:
51 gather_subset:
52 description:
53 - List of string variables to specify the Unity storage system entities
54 for which information is required.
55 choices: [host, fc_initiator, iscsi_initiator, cg, storage_pool, vol,
56 snapshot_schedule, nas_server, file_system, snapshot, nfs_export,
57 smb_share, user_quota, tree_quota, disk_group, nfs_server, cifs_server, ethernet_port, file_interface, replication_session]
58 type: list
59 elements: str
60
61 notes:
62 - The I(check_mode) is supported.
63 '''
64
65 EXAMPLES = r'''
66 - name: Get detailed list of Unity entities
67 info:
68 unispherehost: "{{unispherehost}}"
69 username: "{{username}}"
70 password: "{{password}}"
71 validate_certs: "{{validate_certs}}"
72 gather_subset:
73 - host
74 - fc_initiator
75 - iscsi_initiator
76 - cg
77 - storage_pool
78 - vol
79 - snapshot_schedule
80 - nas_server
81 - file_system
82 - snapshot
83 - nfs_export
84 - smb_share
85 - user_quota
86 - tree_quota
87 - disk_group
88 - nfs_server
89 - cifs_server
90 - ethernet_port
91 - file_interface
92 - replication_session
93
94 - name: Get information of Unity array
95 info:
96 unispherehost: "{{unispherehost}}"
97 username: "{{username}}"
98 password: "{{password}}"
99 validate_certs: "{{validate_certs}}"
100
101 - name: Get list of hosts on Unity array
102 info:
103 unispherehost: "{{unispherehost}}"
104 username: "{{username}}"
105 password: "{{password}}"
106 validate_certs: "{{validate_certs}}"
107 gather_subset:
108 - host
109
110 - name: Get list of FC initiators on Unity array
111 info:
112 unispherehost: "{{unispherehost}}"
113 username: "{{username}}"
114 password: "{{password}}"
115 validate_certs: "{{validate_certs}}"
116 gather_subset:
117 - fc_initiator
118
119 - name: Get list of ISCSI initiators on Unity array
120 info:
121 unispherehost: "{{unispherehost}}"
122 username: "{{username}}"
123 password: "{{password}}"
124 validate_certs: "{{validate_certs}}"
125 gather_subset:
126 - iscsi_initiator
127
128 - name: Get list of consistency groups on Unity array
129 info:
130 unispherehost: "{{unispherehost}}"
131 username: "{{username}}"
132 password: "{{password}}"
133 validate_certs: "{{validate_certs}}"
134 gather_subset:
135 - cg
136
137 - name: Get list of storage pools on Unity array
138 info:
139 unispherehost: "{{unispherehost}}"
140 username: "{{username}}"
141 password: "{{password}}"
142 validate_certs: "{{validate_certs}}"
143 gather_subset:
144 - storage_pool
145
146 - name: Get list of volumes on Unity array
147 info:
148 unispherehost: "{{unispherehost}}"
149 username: "{{username}}"
150 password: "{{password}}"
151 validate_certs: "{{validate_certs}}"
152 gather_subset:
153 - vol
154
155 - name: Get list of snapshot schedules on Unity array
156 info:
157 unispherehost: "{{unispherehost}}"
158 username: "{{username}}"
159 password: "{{password}}"
160 validate_certs: "{{validate_certs}}"
161 gather_subset:
162 - snapshot_schedule
163
164 - name: Get list of NAS Servers on Unity array
165 info:
166 unispherehost: "{{unispherehost}}"
167 username: "{{username}}"
168 password: "{{password}}"
169 validate_certs: "{{validate_certs}}"
170 gather_subset:
171 - nas_server
172
173 - name: Get list of File Systems on Unity array
174 info:
175 unispherehost: "{{unispherehost}}"
176 username: "{{username}}"
177 password: "{{password}}"
178 validate_certs: "{{validate_certs}}"
179 gather_subset:
180 - file_system
181
182 - name: Get list of Snapshots on Unity array
183 info:
184 unispherehost: "{{unispherehost}}"
185 username: "{{username}}"
186 password: "{{password}}"
187 validate_certs: "{{validate_certs}}"
188 gather_subset:
189 - snapshot
190
191 - name: Get list of NFS exports on Unity array
192 info:
193 unispherehost: "{{unispherehost}}"
194 username: "{{username}}"
195 password: "{{password}}"
196 validate_certs: "{{validate_certs}}"
197 gather_subset:
198 - nfs_export
199
200 - name: Get list of SMB shares on Unity array
201 info:
202 unispherehost: "{{unispherehost}}"
203 username: "{{username}}"
204 password: "{{password}}"
205 validate_certs: "{{validate_certs}}"
206 gather_subset:
207 - smb_share
208
209 - name: Get list of user quotas on Unity array
210 info:
211 unispherehost: "{{unispherehost}}"
212 username: "{{username}}"
213 password: "{{password}}"
214 validate_certs: "{{validate_certs}}"
215 gather_subset:
216 - user_quota
217
218 - name: Get list of quota trees on Unity array
219 info:
220 unispherehost: "{{unispherehost}}"
221 username: "{{username}}"
222 password: "{{password}}"
223 validate_certs: "{{validate_certs}}"
224 gather_subset:
225 - tree_quota
226
227 - name: Get list of disk groups on Unity array
228 info:
229 unispherehost: "{{unispherehost}}"
230 username: "{{username}}"
231 password: "{{password}}"
232 validate_certs: "{{validate_certs}}"
233 gather_subset:
234 - disk_group
235
236 - name: Get list of NFS Servers on Unity array
237 info:
238 unispherehost: "{{unispherehost}}"
239 username: "{{username}}"
240 password: "{{password}}"
241 validate_certs: "{{validate_certs}}"
242 gather_subset:
243 - nfs_server
244
245 - name: Get list of CIFS Servers on Unity array
246 info:
247 unispherehost: "{{unispherehost}}"
248 username: "{{username}}"
249 password: "{{password}}"
250 validate_certs: "{{validate_certs}}"
251 gather_subset:
252 - cifs_server
253
254 - name: Get list of ethernet ports on Unity array
255 info:
256 unispherehost: "{{unispherehost}}"
257 username: "{{username}}"
258 password: "{{password}}"
259 validate_certs: "{{validate_certs}}"
260 gather_subset:
261 - ethernet_port
262
263 - name: Get list of file interfaces on Unity array
264 info:
265 unispherehost: "{{unispherehost}}"
266 username: "{{username}}"
267 password: "{{password}}"
268 validate_certs: "{{validate_certs}}"
269 gather_subset:
270 - file_interface
271
272 - name: Get list of replication sessions on Unity array
273 info:
274 unispherehost: "{{unispherehost}}"
275 username: "{{username}}"
276 password: "{{password}}"
277 validate_certs: "{{validate_certs}}"
278 gather_subset:
279 - replication_session
280 '''
281
282 RETURN = r'''
283 Array_Details:
284 description: Details of the Unity Array.
285 returned: always
286 type: dict
287 contains:
288 api_version:
289 description: The current api version of the Unity Array.
290 type: str
291 earliest_api_version:
292 description: The earliest api version of the Unity Array.
293 type: str
294 model:
295 description: The model of the Unity Array.
296 type: str
297 name:
298 description: The name of the Unity Array.
299 type: str
300 software_version:
301 description: The software version of the Unity Array.
302 type: str
303 sample: {
304 "api_version": "12.0",
305 "earliest_api_version": "4.0",
306 "existed": true,
307 "hash": 8766644083532,
308 "id": "0",
309 "model": "Unity 480",
310 "name": "APM00213404195",
311 "software_version": "5.2.1"
312 }
313
314 Hosts:
315 description: Details of the hosts.
316 returned: When hosts exist.
317 type: list
318 contains:
319 id:
320 description: The ID of the host.
321 type: str
322 name:
323 description: The name of the host.
324 type: str
325 sample: [
326 {
327 "auto_manage_type": "HostManageEnum.UNKNOWN",
328 "datastores": null,
329 "description": "",
330 "existed": true,
331 "fc_host_initiators": null,
332 "hash": 8762200072289,
333 "health": {
334 "UnityHealth": {
335 "hash": 8762200072352
336 }
337 },
338 "host_container": null,
339 "host_ip_ports": {
340 "UnityHostIpPortList": [
341 {
342 "UnityHostIpPort": {
343 "hash": 8762200072361
344 }
345 }
346 ]
347 },
348 "host_luns": null,
349 "host_polled_uuid": null,
350 "host_pushed_uuid": null,
351 "host_uuid": null,
352 "host_v_vol_datastore": null,
353 "id": "Host_2191",
354 "iscsi_host_initiators": null,
355 "last_poll_time": null,
356 "name": "10.225.2.153",
357 "os_type": "Linux",
358 "registration_type": null,
359 "storage_resources": null,
360 "tenant": null,
361 "type": "HostTypeEnum.HOST_MANUAL",
362 "vms": null
363 }
364 ]
365
366 FC_initiators:
367 description: Details of the FC initiators.
368 returned: When FC initiator exist.
369 type: list
370 contains:
371 WWN:
372 description: The WWN of the FC initiator.
373 type: str
374 id:
375 description: The id of the FC initiator.
376 type: str
377 sample: [
378 {
379 "WWN": "20:00:00:0E:1E:E9:B8:FC:21:00:00:0E:1E:E9:B8:FC",
380 "id": "HostInitiator_3"
381 },
382 {
383 "WWN": "20:00:00:0E:1E:E9:B8:F7:21:00:00:0E:1E:E9:B8:F7",
384 "id": "HostInitiator_4"
385 }
386 ]
387
388 ISCSI_initiators:
389 description: Details of the ISCSI initiators.
390 returned: When ISCSI initiators exist.
391 type: list
392 contains:
393 IQN:
394 description: The IQN of the ISCSI initiator.
395 type: str
396 id:
397 description: The id of the ISCSI initiator.
398 type: str
399 sample: [
400 {
401 "IQN": "iqn.1994-05.com.redhat:634d768090f",
402 "id": "HostInitiator_1"
403 },
404 {
405 "IQN": "iqn.1994-05.com.redhat:2835ba62cc6d",
406 "id": "HostInitiator_2"
407 }
408 ]
409
410 Consistency_Groups:
411 description: Details of the Consistency Groups.
412 returned: When Consistency Groups exist.
413 type: list
414 contains:
415 id:
416 description: The ID of the Consistency Group.
417 type: str
418 name:
419 description: The name of the Consistency Group.
420 type: str
421 sample: [
422 {
423 "advanced_dedup_status": "DedupStatusEnum.DISABLED",
424 "block_host_access": {
425 "UnityBlockHostAccessList": [
426 {
427 "UnityBlockHostAccess": {
428 "hash": 8745385821206
429 }
430 },
431 {
432 "UnityBlockHostAccess": {
433 "hash": 8745386530115
434 }
435 },
436 {
437 "UnityBlockHostAccess": {
438 "hash": 8745386530124
439 }
440 }
441 ]
442 },
443 "data_reduction_percent": 0,
444 "data_reduction_ratio": 1.0,
445 "data_reduction_size_saved": 0,
446 "data_reduction_status": "DataReductionStatusEnum.DISABLED",
447 "datastores": null,
448 "dedup_status": null,
449 "description": "CG has created with all parametres.",
450 "esx_filesystem_block_size": null,
451 "esx_filesystem_major_version": null,
452 "existed": true,
453 "filesystem": null,
454 "hash": 8745385801328,
455 "health": {
456 "UnityHealth": {
457 "hash": 8745386647098
458 }
459 },
460 "host_v_vol_datastore": null,
461 "id": "res_93",
462 "is_replication_destination": false,
463 "is_snap_schedule_paused": false,
464 "luns": {
465 "UnityLunList": [
466 {
467 "UnityLun": {
468 "hash": 8745389830024,
469 "id": "sv_64"
470 }
471 },
472 {
473 "UnityLun": {
474 "hash": 8745386526751,
475 "id": "sv_63"
476 }
477 }
478 ]
479 },
480 "metadata_size": 8858370048,
481 "metadata_size_allocated": 7516192768,
482 "name": "CG1_Ansible_Test_SS",
483 "per_tier_size_used": [
484 11811160064,
485 0,
486 0
487 ],
488 "pools": {
489 "UnityPoolList": [
490 {
491 "UnityPool": {
492 "hash": 8745386552375,
493 "id": "pool_3"
494 }
495 }
496 ]
497 },
498 "relocation_policy": "TieringPolicyEnum.AUTOTIER",
499 "replication_type": "ReplicationTypeEnum.NONE",
500 "size_allocated": 99418112,
501 "size_total": 268435456000,
502 "size_used": null,
503 "snap_count": 1,
504 "snap_schedule": {
505 "UnitySnapSchedule": {
506 "hash": 8745386550224,
507 "id": "snapSch_66"
508 }
509 },
510 "snaps_size_allocated": 8888320,
511 "snaps_size_total": 108675072,
512 "thin_status": "ThinStatusEnum.TRUE",
513 "type": "StorageResourceTypeEnum.CONSISTENCY_GROUP",
514 "virtual_volumes": null,
515 "vmware_uuid": null
516 },
517 ]
518
519 Storage_Pools:
520 description: Details of the Storage Pools.
521 returned: When Storage Pools exist.
522 type: list
523 contains:
524 id:
525 description: The ID of the Storage Pool.
526 type: str
527 name:
528 description: The name of the Storage Pool.
529 type: str
530 sample: [
531 {
532 "alert_threshold": 70,
533 "creation_time": "2021-10-18 12:45:12+00:00",
534 "description": "",
535 "existed": true,
536 "harvest_state": "UsageHarvestStateEnum.PAUSED_COULD_NOT_REACH_HWM",
537 "hash": 8741501012399,
538 "health": {
539 "UnityHealth": {
540 "hash": 8741501012363
541 }
542 },
543 "id": "pool_2",
544 "is_all_flash": false,
545 "is_empty": false,
546 "is_fast_cache_enabled": false,
547 "is_harvest_enabled": true,
548 "is_snap_harvest_enabled": false,
549 "metadata_size_subscribed": 312458870784,
550 "metadata_size_used": 244544700416,
551 "name": "fastVP_pool",
552 "object_id": 12884901891,
553 "pool_fast_vp": {
554 "UnityPoolFastVp": {
555 "hash": 8741501228023
556 }
557 },
558 "pool_space_harvest_high_threshold": 95.0,
559 "pool_space_harvest_low_threshold": 85.0,
560 "pool_type": "StoragePoolTypeEnum.TRADITIONAL",
561 "raid_type": "RaidTypeEnum.RAID5",
562 "rebalance_progress": null,
563 "size_free": 2709855928320,
564 "size_subscribed": 2499805044736,
565 "size_total": 3291018690560,
566 "size_used": 455513956352,
567 "snap_size_subscribed": 139720515584,
568 "snap_size_used": 66002944,
569 "snap_space_harvest_high_threshold": 25.0,
570 "snap_space_harvest_low_threshold": 20.0,
571 "tiers": {
572 "UnityPoolTierList": [
573 {
574 "UnityPoolTier": {
575 "hash": 8741500996410
576 }
577 },
578 {
579 "UnityPoolTier": {
580 "hash": 8741501009430
581 }
582 },
583 {
584 "UnityPoolTier": {
585 "hash": 8741501009508
586 }
587 }
588 ]
589 }
590 },
591 ]
592
593 Volumes:
594 description: Details of the Volumes.
595 returned: When Volumes exist.
596 type: list
597 contains:
598 id:
599 description: The ID of the Volume.
600 type: str
601 name:
602 description: The name of the Volume.
603 type: str
604 sample: [
605 {
606 "current_node": "NodeEnum.SPB",
607 "data_reduction_percent": 0,
608 "data_reduction_ratio": 1.0,
609 "data_reduction_size_saved": 0,
610 "default_node": "NodeEnum.SPB",
611 "description": null,
612 "effective_io_limit_max_iops": null,
613 "effective_io_limit_max_kbps": null,
614 "existed": true,
615 "family_base_lun": {
616 "UnityLun": {
617 "hash": 8774260820794,
618 "id": "sv_27"
619 }
620 },
621 "family_clone_count": 0,
622 "hash": 8774260854260,
623 "health": {
624 "UnityHealth": {
625 "hash": 8774260812499
626 }
627 },
628 "host_access": {
629 "UnityBlockHostAccessList": [
630 {
631 "UnityBlockHostAccess": {
632 "hash": 8774260826387
633 }
634 }
635 ]
636 },
637 "id": "sv_27",
638 "io_limit_policy": null,
639 "is_advanced_dedup_enabled": false,
640 "is_compression_enabled": null,
641 "is_data_reduction_enabled": false,
642 "is_replication_destination": false,
643 "is_snap_schedule_paused": false,
644 "is_thin_clone": false,
645 "is_thin_enabled": false,
646 "metadata_size": 4294967296,
647 "metadata_size_allocated": 4026531840,
648 "name": "VSI-UNITY-test-task",
649 "per_tier_size_used": [
650 111400714240,
651 0,
652 0
653 ],
654 "pool": {
655 "UnityPool": {
656 "hash": 8774260811427
657 }
658 },
659 "size_allocated": 107374182400,
660 "size_total": 107374182400,
661 "size_used": null,
662 "snap_count": 0,
663 "snap_schedule": null,
664 "snap_wwn": "60:06:01:60:5C:F0:50:00:94:3E:91:4D:51:5A:4F:97",
665 "snaps_size": 0,
666 "snaps_size_allocated": 0,
667 "storage_resource": {
668 "UnityStorageResource": {
669 "hash": 8774267822228
670 }
671 },
672 "tiering_policy": "TieringPolicyEnum.AUTOTIER_HIGH",
673 "type": "LUNTypeEnum.VMWARE_ISCSI",
674 "wwn": "60:06:01:60:5C:F0:50:00:00:B5:95:61:2E:34:DB:B2"
675 },
676 ]
677
678 Snapshot_Schedules:
679 description: Details of the Snapshot Schedules.
680 returned: When Snapshot Schedules exist.
681 type: list
682 contains:
683 id:
684 description: The ID of the Snapshot Schedule.
685 type: str
686 name:
687 description: The name of the Snapshot Schedule.
688 type: str
689 sample: [
690 {
691 "existed": true,
692 "hash": 8775599492651,
693 "id": "snapSch_1",
694 "is_default": true,
695 "is_modified": null,
696 "is_sync_replicated": false,
697 "luns": null,
698 "modification_time": "2021-08-18 19:10:33.774000+00:00",
699 "name": "CEM_DEFAULT_SCHEDULE_DEFAULT_PROTECTION",
700 "rules": {
701 "UnitySnapScheduleRuleList": [
702 {
703 "UnitySnapScheduleRule": {
704 "hash": 8775599498593
705 }
706 }
707 ]
708 },
709 "storage_resources": {
710 "UnityStorageResourceList": [
711 {
712 "UnityStorageResource": {
713 "hash": 8775599711597,
714 "id": "res_88"
715 }
716 },
717 {
718 "UnityStorageResource": {
719 "hash": 8775599711528,
720 "id": "res_3099"
721 }
722 }
723 ]
724 },
725 "version": "ScheduleVersionEnum.LEGACY"
726 },
727 ]
728
729 NAS_Servers:
730 description: Details of the NAS Servers.
731 returned: When NAS Servers exist.
732 type: list
733 contains:
734 id:
735 description: The ID of the NAS Server.
736 type: str
737 name:
738 description: The name of the NAS Server.
739 type: str
740 sample: [
741 {
742 "allow_unmapped_user": null,
743 "cifs_server": null,
744 "current_sp": {
745 "UnityStorageProcessor": {
746 "hash": 8747629920422,
747 "id": "spb"
748 }
749 },
750 "current_unix_directory_service": "NasServerUnixDirectoryServiceEnum.NONE",
751 "default_unix_user": null,
752 "default_windows_user": null,
753 "existed": true,
754 "file_dns_server": null,
755 "file_interface": {
756 "UnityFileInterfaceList": [
757 {
758 "UnityFileInterface": {
759 "hash": 8747626606870,
760 "id": "if_6"
761 }
762 }
763 ]
764 },
765 "filesystems": {
766 "UnityFileSystemList": [
767 {
768 "UnityFileSystem": {
769 "hash": 8747625901355,
770 "id": "fs_6892"
771 }
772 },
773 ]
774 },
775 "hash": 8747625900370,
776 "health": {
777 "UnityHealth": {
778 "hash": 8747625900493
779 }
780 },
781 "home_sp": {
782 "UnityStorageProcessor": {
783 "hash": 8747625877420,
784 "id": "spb"
785 }
786 },
787 "id": "nas_1",
788 "is_backup_only": false,
789 "is_multi_protocol_enabled": false,
790 "is_packet_reflect_enabled": false,
791 "is_replication_destination": false,
792 "is_replication_enabled": false,
793 "is_windows_to_unix_username_mapping_enabled": null,
794 "name": "lglad072",
795 "pool": {
796 "UnityPool": {
797 "hash": 8747629920479,
798 "id": "pool_3"
799 }
800 },
801 "preferred_interface_settings": {
802 "UnityPreferredInterfaceSettings": {
803 "hash": 8747626625166,
804 "id": "preferred_if_1"
805 }
806 },
807 "replication_type": "ReplicationTypeEnum.NONE",
808 "size_allocated": 2952790016,
809 "tenant": null,
810 "virus_checker": {
811 "UnityVirusChecker": {
812 "hash": 8747626604144,
813 "id": "cava_1"
814 }
815 }
816 },
817 ]
818
819 File_Systems:
820 description: Details of the File Systems.
821 returned: When File Systems exist.
822 type: list
823 contains:
824 id:
825 description: The ID of the File System.
826 type: str
827 name:
828 description: The name of the File System.
829 type: str
830 sample: [
831 {
832 "access_policy": "AccessPolicyEnum.UNIX",
833 "cifs_notify_on_change_dir_depth": 512,
834 "cifs_share": null,
835 "data_reduction_percent": 0,
836 "data_reduction_ratio": 1.0,
837 "data_reduction_size_saved": 0,
838 "description": "",
839 "existed": true,
840 "folder_rename_policy": "FSRenamePolicyEnum.SMB_RENAME_FORBIDDEN",
841 "format": "FSFormatEnum.UFS64",
842 "hash": 8786518053735,
843 "health": {
844 "UnityHealth": {
845 "hash": 8786518049091
846 }
847 },
848 "host_io_size": "HostIOSizeEnum.GENERAL_8K",
849 "id": "fs_12",
850 "is_advanced_dedup_enabled": false,
851 "is_cifs_notify_on_access_enabled": false,
852 "is_cifs_notify_on_write_enabled": false,
853 "is_cifs_op_locks_enabled": true,
854 "is_cifs_sync_writes_enabled": false,
855 "is_data_reduction_enabled": false,
856 "is_read_only": false,
857 "is_smbca": false,
858 "is_thin_enabled": true,
859 "locking_policy": "FSLockingPolicyEnum.MANDATORY",
860 "metadata_size": 4294967296,
861 "metadata_size_allocated": 3758096384,
862 "min_size_allocated": 0,
863 "name": "vro-daniel-test",
864 "nas_server": {
865 "UnityNasServer": {
866 "hash": 8786517296113,
867 "id": "nas_1"
868 }
869 },
870 "nfs_share": null,
871 "per_tier_size_used": [
872 6442450944,
873 0,
874 0
875 ],
876 "pool": {
877 "UnityPool": {
878 "hash": 8786518259493,
879 "id": "pool_3"
880 }
881 },
882 "pool_full_policy": "ResourcePoolFullPolicyEnum.FAIL_WRITES",
883 "size_allocated": 283148288,
884 "size_allocated_total": 4041244672,
885 "size_preallocated": 2401206272,
886 "size_total": 107374182400,
887 "size_used": 1620312064,
888 "snap_count": 0,
889 "snaps_size": 0,
890 "snaps_size_allocated": 0,
891 "storage_resource": {
892 "UnityStorageResource": {
893 "hash": 8786518044167,
894 "id": "res_20"
895 }
896 },
897 "supported_protocols": "FSSupportedProtocolEnum.NFS",
898 "tiering_policy": "TieringPolicyEnum.AUTOTIER_HIGH",
899 "type": "FilesystemTypeEnum.FILESYSTEM"
900 },
901 ]
902
903 Snapshots:
904 description: Details of the Snapshots.
905 returned: When Snapshots exist.
906 type: list
907 contains:
908 id:
909 description: The ID of the Snapshot.
910 type: str
911 name:
912 description: The name of the Snapshot.
913 type: str
914 sample: [
915 {
916 "access_type": "FilesystemSnapAccessTypeEnum.CHECKPOINT",
917 "attached_wwn": null,
918 "creation_time": "2022-04-06 11:19:26.818000+00:00",
919 "creator_schedule": null,
920 "creator_type": "SnapCreatorTypeEnum.REP_V2",
921 "creator_user": null,
922 "description": "",
923 "existed": true,
924 "expiration_time": null,
925 "hash": 8739100256648,
926 "host_access": null,
927 "id": "38654716464",
928 "io_limit_policy": null,
929 "is_auto_delete": false,
930 "is_modifiable": false,
931 "is_modified": false,
932 "is_read_only": true,
933 "is_system_snap": true,
934 "last_writable_time": null,
935 "lun": {
936 "UnityLun": {
937 "hash": 8739100148962,
938 "id": "sv_301"
939 }
940 },
941 "name": "42949677504_APM00213404195_0000.ckpt000_9508038064690266.2_238",
942 "parent_snap": null,
943 "size": 3221225472,
944 "snap_group": null,
945 "state": "SnapStateEnum.READY",
946 "storage_resource": {
947 "UnityStorageResource": {
948 "hash": 8739100173002,
949 "id": "sv_301"
950 }
951 }
952 },
953 ]
954
955 NFS_Exports:
956 description: Details of the NFS Exports.
957 returned: When NFS Exports exist.
958 type: list
959 contains:
960 id:
961 description: The ID of the NFS Export.
962 type: str
963 name:
964 description: The name of the NFS Export.
965 type: str
966 sample: [
967 {
968 "anonymous_gid": 4294967294,
969 "anonymous_uid": 4294967294,
970 "creation_time": "2021-12-01 06:21:48.381000+00:00",
971 "default_access": "NFSShareDefaultAccessEnum.NO_ACCESS",
972 "description": "",
973 "existed": true,
974 "export_option": 1,
975 "export_paths": [
976 "10.230.24.20:/zack_nfs_01"
977 ],
978 "filesystem": {
979 "UnityFileSystem": {
980 "hash": 8747298565566,
981 "id": "fs_67"
982 }
983 },
984 "hash": 8747298565548,
985 "host_accesses": null,
986 "id": "NFSShare_29",
987 "is_read_only": null,
988 "min_security": "NFSShareSecurityEnum.SYS",
989 "modification_time": "2022-04-01 11:44:17.553000+00:00",
990 "name": "zack_nfs_01",
991 "nfs_owner_username": null,
992 "no_access_hosts": null,
993 "no_access_hosts_string": "10.226.198.207,10.226.198.25,10.226.198.44,10.226.198.85,Host1,
994 Host2,Host4,Host5,Host6,10.10.0.0/255.255.240.0",
995 "path": "/",
996 "read_only_hosts": null,
997 "read_only_hosts_string": "",
998 "read_only_root_access_hosts": null,
999 "read_only_root_hosts_string": "",
1000 "read_write_hosts": null,
1001 "read_write_hosts_string": "",
1002 "read_write_root_hosts_string": "",
1003 "role": "NFSShareRoleEnum.PRODUCTION",
1004 "root_access_hosts": null,
1005 "snap": null,
1006 "type": "NFSTypeEnum.NFS_SHARE"
1007 },
1008 ]
1009
1010 SMB_Shares:
1011 description: Details of the SMB Shares.
1012 returned: When SMB Shares exist.
1013 type: list
1014 contains:
1015 id:
1016 description: The ID of the SMB Share.
1017 type: str
1018 name:
1019 description: The name of the SMB Share.
1020 type: str
1021 sample: [
1022 {
1023 "creation_time": "2022-03-17 11:56:54.867000+00:00",
1024 "description": "",
1025 "existed": true,
1026 "export_paths": [
1027 "\\\\multi-prot-pie.extreme1.com\\multi-prot-hui",
1028 "\\\\10.230.24.26\\multi-prot-hui"
1029 ],
1030 "filesystem": {
1031 "UnityFileSystem": {
1032 "hash": 8741295638110,
1033 "id": "fs_140"
1034 }
1035 },
1036 "hash": 8741295638227,
1037 "id": "SMBShare_20",
1038 "is_abe_enabled": false,
1039 "is_ace_enabled": false,
1040 "is_branch_cache_enabled": false,
1041 "is_continuous_availability_enabled": false,
1042 "is_dfs_enabled": false,
1043 "is_encryption_enabled": false,
1044 "is_read_only": null,
1045 "modified_time": "2022-03-17 11:56:54.867000+00:00",
1046 "name": "multi-prot-hui",
1047 "offline_availability": "CifsShareOfflineAvailabilityEnum.NONE",
1048 "path": "/",
1049 "snap": null,
1050 "type": "CIFSTypeEnum.CIFS_SHARE",
1051 "umask": "022"
1052 },
1053 ]
1054
1055 User_Quotas:
1056 description: Details of the user quotas.
1057 returned: When user quotas exist.
1058 type: list
1059 contains:
1060 id:
1061 description: The ID of the user quota.
1062 type: str
1063 uid:
1064 description: The UID of the user quota.
1065 type: str
1066 sample: [
1067 {
1068 "id": "userquota_171798694698_0_60000",
1069 "uid": 60000
1070 },
1071 {
1072 "id": "userquota_171798694939_0_5001",
1073 "uid": 5001
1074 }
1075 ]
1076
1077 Tree_Quotas:
1078 description: Details of the quota trees.
1079 returned: When quota trees exist.
1080 type: list
1081 contains:
1082 id:
1083 description: The ID of the quota tree.
1084 type: str
1085 path:
1086 description: The path of the quota tree.
1087 type: str
1088 sample: [
1089 {
1090 "id": "treequota_171798709589_1",
1091 "path": "/vro-ui-fs-rkKfimmN"
1092 },
1093 {
1094 "id": "treequota_171798709590_1",
1095 "path": "/vro-ui-fs-mGYXAMqk"
1096 }
1097 ]
1098
1099 Disk_Groups:
1100 description: Details of the disk groups.
1101 returned: When disk groups exist.
1102 type: list
1103 contains:
1104 id:
1105 description: The ID of the disk group.
1106 type: str
1107 name:
1108 description: The name of the disk group.
1109 type: str
1110 tier_type:
1111 description: The tier type of the disk group.
1112 type: str
1113 sample: [
1114 {
1115 "id": "dg_3",
1116 "name": "400 GB SAS Flash 2",
1117 "tier_type": "EXTREME_PERFORMANCE"
1118 },
1119 {
1120 "id": "dg_16",
1121 "name": "600 GB SAS 10K",
1122 "tier_type": "PERFORMANCE"
1123 }
1124 ]
1125
1126 NFS_Servers:
1127 description: Details of the NFS Servers.
1128 returned: When NFS Servers exist.
1129 type: list
1130 contains:
1131 id:
1132 description: The ID of the NFS Servers.
1133 type: str
1134 sample: [
1135 {
1136 "id": "nfs_3",
1137 },
1138 {
1139 "id": "nfs_4",
1140 },
1141 {
1142 "id": "nfs_9",
1143 }
1144 ]
1145 CIFS_Servers:
1146 description: Details of the CIFS Servers.
1147 returned: When CIFS Servers exist.
1148 type: list
1149 contains:
1150 id:
1151 description: The ID of the CIFS Servers.
1152 type: str
1153 name:
1154 description: The name of the CIFS server.
1155 type: str
1156 sample: [
1157 {
1158 "id": "cifs_3",
1159 "name": "test_cifs_1"
1160 },
1161 {
1162 "id": "cifs_4",
1163 "name": "test_cifs_2"
1164 },
1165 {
1166 "id": "cifs_9",
1167 "name": "test_cifs_3"
1168 }
1169 ]
1170 Ethernet_ports:
1171 description: Details of the ethernet ports.
1172 returned: When ethernet ports exist.
1173 type: list
1174 contains:
1175 id:
1176 description: The ID of the ethernet port.
1177 type: str
1178 name:
1179 description: The name of the ethernet port.
1180 type: str
1181 sample: [
1182 {
1183 "id": "spa_mgmt",
1184 "name": "SP A Management Port"
1185 },
1186 {
1187 "id": "spa_ocp_0_eth0",
1188 "name": "SP A 4-Port Card Ethernet Port 0"
1189 },
1190 {
1191 "id": "spa_ocp_0_eth1",
1192 "name": "SP A 4-Port Card Ethernet Port 1"
1193 }
1194 ]
1195 File_interfaces:
1196 description: Details of the file inetrfaces.
1197 returned: When file inetrface exist.
1198 type: list
1199 contains:
1200 id:
1201 description: The ID of the file inetrface.
1202 type: str
1203 name:
1204 description: The name of the file inetrface.
1205 type: str
1206 ip_address:
1207 description: IP address of the file inetrface.
1208 type: str
1209 sample: [
1210 {
1211 "id": "if_3",
1212 "ip_address": "xx.xx.xx.xx",
1213 "name": "1_APMXXXXXXXXXX"
1214 },
1215 {
1216 "id": "if_3",
1217 "ip_address": "xx.xx.xx.xx",
1218 "name": "2_APMXXXXXXXXXX"
1219 },
1220 {
1221 "id": "if_3",
1222 "ip_address": "xx.xx.xx.xx",
1223 "name": "3_APMXXXXXXXXXX"
1224 }
1225 ]
1226 Replication_sessions:
1227 description: Details of the Replication sessions.
1228 returned: When Replication sessions exist.
1229 type: list
1230 contains:
1231 id:
1232 description: The ID of the Replication session.
1233 type: str
1234 name:
1235 description: The name of the Replication session.
1236 type: str
1237 sample: [
1238 {
1239 "current_transfer_est_remain_time": 0,
1240 "daily_snap_replication_policy": null,
1241 "dst_resource_id": "nas_8",
1242 "dst_spa_interface": {
1243 "UnityRemoteInterface": {
1244 "hash": 8771253398547,
1245 "id": "APM00213404195:if_181"
1246 }
1247 },
1248 "dst_spb_interface": {
1249 "UnityRemoteInterface": {
1250 "hash": 8771253424144,
1251 "id": "APM00213404195:if_180"
1252 }
1253 },
1254 "dst_status": "ReplicationSessionStatusEnum.OK",
1255 "existed": true,
1256 "hash": 8771259012271,
1257 "health": {
1258 "UnityHealth": {
1259 "hash": 8771253424168
1260 }
1261 },
1262 "hourly_snap_replication_policy": null,
1263 "id": "103079215114_APM00213404195_0000_103079215274_APM00213404194_0000",
1264 "last_sync_time": "2023-04-18 10:35:25+00:00",
1265 "local_role": "ReplicationSessionReplicationRoleEnum.DESTINATION",
1266 "max_time_out_of_sync": 0,
1267 "members": null,
1268 "name": "rep_sess_nas",
1269 "network_status": "ReplicationSessionNetworkStatusEnum.OK",
1270 "remote_system": {
1271 "UnityRemoteSystem": {
1272 "hash": 8771253380142
1273 }
1274 },
1275 "replication_resource_type": "ReplicationEndpointResourceTypeEnum.NASSERVER",
1276 "src_resource_id": "nas_213",
1277 "src_spa_interface": {
1278 "UnityRemoteInterface": {
1279 "hash": 8771253475010,
1280 "id": "APM00213404194:if_195"
1281 }
1282 },
1283 "src_spb_interface": {
1284 "UnityRemoteInterface": {
1285 "hash": 8771253374169,
1286 "id": "APM00213404194:if_194"
1287 }
1288 },
1289 "src_status": "ReplicationSessionStatusEnum.OK",
1290 "status": "ReplicationOpStatusEnum.ACTIVE",
1291 "sync_progress": 0,
1292 "sync_state": "ReplicationSessionSyncStateEnum.IN_SYNC"
1293 },
1294 ]
1295 '''
1296
1297 from ansible.module_utils.basic import AnsibleModule
1298 from ansible_collections.dellemc.unity.plugins.module_utils.storage.dell \
1299 import utils
1300
1301 LOG = utils.get_logger('info')
1302 SUCCESSFULL_LISTED_MSG = 'Successfully listed.'
1303
1304 application_type = "Ansible/1.7.1"
1305
1306
1307 class Info(object):
1308 """Class with Info operations"""
1309
1310 def __init__(self):
1311 """ Define all parameters required by this module"""
1312
1313 self.module_params = utils.get_unity_management_host_parameters()
1314 self.module_params.update(get_info_parameters())
1315
1316 """ initialize the ansible module """
1317 self.module = AnsibleModule(argument_spec=self.module_params,
1318 supports_check_mode=True)
1319 utils.ensure_required_libs(self.module)
1320
1321 self.unity = utils.get_unity_unisphere_connection(self.module.params,
1322 application_type)
1323 LOG.info('Got the unity instance for provisioning on Unity')
1324
1325 def get_array_details(self):
1326 """ Get the list of snapshot schedules on a given Unity storage
1327 system """
1328
1329 try:
1330 LOG.info('Getting array details ')
1331 array_details = self.unity.info
1332 return array_details._get_properties()
1333
1334 except utils.HttpError as e:
1335 if e.http_status == 401:
1336 msg = 'Incorrect username or password provided.'
1337 LOG.error(msg)
1338 self.module.fail_json(msg=msg)
1339 else:
1340 msg = str(e)
1341 LOG.error(msg)
1342 self.module.fail_json(msg=msg)
1343 except Exception as e:
1344 msg = 'Get array details from unity array failed with' \
1345 ' error %s' % (str(e))
1346 LOG.error(msg)
1347 self.module.fail_json(msg=msg)
1348
1349 def get_hosts_list(self):
1350 """ Get the list of hosts on a given Unity storage system """
1351
1352 try:
1353 LOG.info('Getting hosts list ')
1354 hosts = self.unity.get_host()
1355 return result_list(hosts)
1356
1357 except Exception as e:
1358 msg = 'Get hosts list from unity array failed with' \
1359 ' error %s' % (str(e))
1360 LOG.error(msg)
1361 self.module.fail_json(msg=msg)
1362
1363 def get_fc_initiators_list(self):
1364 """ Get the list of FC Initiators on a given Unity storage system """
1365
1366 try:
1367 LOG.info('Getting FC initiators list ')
1368 fc_initiator = utils.host.UnityHostInitiatorList \
1369 .get(cli=self.unity._cli, type=utils.HostInitiatorTypeEnum.FC)
1370 return fc_initiators_result_list(fc_initiator)
1371
1372 except Exception as e:
1373 msg = 'Get FC initiators list from unity array failed with' \
1374 ' error %s' % (str(e))
1375 LOG.error(msg)
1376 self.module.fail_json(msg=msg)
1377
1378 def get_iscsi_initiators_list(self):
1379 """ Get the list of ISCSI initiators on a given Unity storage
1380 system """
1381
1382 try:
1383 LOG.info('Getting ISCSI initiators list ')
1384 iscsi_initiator = utils.host.UnityHostInitiatorList \
1385 .get(cli=self.unity._cli, type=utils.HostInitiatorTypeEnum.
1386 ISCSI)
1387 return iscsi_initiators_result_list(iscsi_initiator)
1388
1389 except Exception as e:
1390 msg = 'Get ISCSI initiators list from unity array failed with' \
1391 ' error %s' % (str(e))
1392 LOG.error(msg)
1393 self.module.fail_json(msg=msg)
1394
1395 def get_consistency_groups_list(self):
1396 """ Get the list of consistency groups on a given Unity storage
1397 system """
1398
1399 try:
1400 LOG.info('Getting consistency groups list ')
1401 consistency_groups = utils.cg.UnityConsistencyGroupList \
1402 .get(self.unity._cli)
1403 return result_list(consistency_groups)
1404
1405 except Exception as e:
1406 msg = 'Get consistency groups list from unity array failed with' \
1407 ' error %s' % (str(e))
1408 LOG.error(msg)
1409 self.module.fail_json(msg=msg)
1410
1411 def get_storage_pools_list(self):
1412 """ Get the list of storage pools on a given Unity storage
1413 system """
1414
1415 try:
1416 LOG.info('Getting storage pools list ')
1417 storage_pools = self.unity.get_pool()
1418 return result_list(storage_pools)
1419
1420 except Exception as e:
1421 msg = 'Get storage pools list from unity array failed with' \
1422 ' error %s' % (str(e))
1423 LOG.error(msg)
1424 self.module.fail_json(msg=msg)
1425
1426 def get_volumes_list(self):
1427 """ Get the list of volumes on a given Unity storage
1428 system """
1429
1430 try:
1431 LOG.info('Getting volumes list ')
1432 volumes = self.unity.get_lun()
1433 return result_list(volumes)
1434
1435 except Exception as e:
1436 msg = 'Get volumes list from unity array failed with' \
1437 ' error %s' % (str(e))
1438 LOG.error(msg)
1439 self.module.fail_json(msg=msg)
1440
1441 def get_snapshot_schedules_list(self):
1442 """ Get the list of snapshot schedules on a given Unity storage
1443 system """
1444
1445 try:
1446 LOG.info('Getting snapshot schedules list ')
1447 snapshot_schedules = utils.snap_schedule.UnitySnapScheduleList \
1448 .get(cli=self.unity._cli)
1449 return result_list(snapshot_schedules)
1450
1451 except Exception as e:
1452 msg = 'Get snapshot schedules list from unity array failed with' \
1453 ' error %s' % (str(e))
1454 LOG.error(msg)
1455 self.module.fail_json(msg=msg)
1456
1457 def get_nas_servers_list(self):
1458 """Get the list of NAS servers on a given Unity storage system"""
1459
1460 try:
1461 LOG.info("Getting NAS servers list")
1462 nas_servers = self.unity.get_nas_server()
1463 return result_list(nas_servers)
1464
1465 except Exception as e:
1466 msg = 'Get NAS servers list from unity array failed with' \
1467 ' error %s' % (str(e))
1468 LOG.error(msg)
1469 self.module.fail_json(msg=msg)
1470
1471 def get_file_systems_list(self):
1472 """Get the list of file systems on a given Unity storage system"""
1473
1474 try:
1475 LOG.info("Getting file systems list")
1476 file_systems = self.unity.get_filesystem()
1477 return result_list(file_systems)
1478
1479 except Exception as e:
1480 msg = 'Get file systems list from unity array failed with' \
1481 ' error %s' % (str(e))
1482 LOG.error(msg)
1483 self.module.fail_json(msg=msg)
1484
1485 def get_snapshots_list(self):
1486 """Get the list of snapshots on a given Unity storage system"""
1487
1488 try:
1489 LOG.info("Getting snapshots list")
1490 snapshots = self.unity.get_snap()
1491 return result_list(snapshots)
1492
1493 except Exception as e:
1494 msg = 'Get snapshots from unity array failed with' \
1495 ' error %s' % (str(e))
1496 LOG.error(msg)
1497 self.module.fail_json(msg=msg)
1498
1499 def get_nfs_exports_list(self):
1500 """Get the list of NFS exports on a given Unity storage system"""
1501
1502 try:
1503 LOG.info("Getting NFS exports list")
1504 nfs_exports = self.unity.get_nfs_share()
1505 return result_list(nfs_exports)
1506
1507 except Exception as e:
1508 msg = 'Get NFS exports from unity array failed with' \
1509 ' error %s' % (str(e))
1510 LOG.error(msg)
1511 self.module.fail_json(msg=msg)
1512
1513 def get_smb_shares_list(self):
1514 """Get the list of SMB shares on a given Unity storage system"""
1515
1516 try:
1517 LOG.info("Getting SMB shares list")
1518 smb_shares = self.unity.get_cifs_share()
1519 return result_list(smb_shares)
1520
1521 except Exception as e:
1522 msg = 'Get SMB shares from unity array failed with' \
1523 ' error %s' % (str(e))
1524 LOG.error(msg)
1525 self.module.fail_json(msg=msg)
1526
1527 def get_user_quota_list(self):
1528 """Get the list of user quotas on a given Unity storage system"""
1529
1530 try:
1531 LOG.info("Getting user quota list")
1532 user_quotas = self.unity.get_user_quota()
1533 return user_quota_result_list(user_quotas)
1534
1535 except Exception as e:
1536 msg = 'Get user quotas from unity array failed with' \
1537 ' error %s' % (str(e))
1538 LOG.error(msg)
1539 self.module.fail_json(msg=msg)
1540
1541 def get_tree_quota_list(self):
1542 """Get the list of quota trees on a given Unity storage system"""
1543
1544 try:
1545 LOG.info("Getting quota tree list")
1546 tree_quotas = self.unity.get_tree_quota()
1547 return tree_quota_result_list(tree_quotas)
1548
1549 except Exception as e:
1550 msg = 'Get quota trees from unity array failed with' \
1551 ' error %s' % (str(e))
1552 LOG.error(msg)
1553 self.module.fail_json(msg=msg)
1554
1555 def get_disk_groups_list(self):
1556 """Get the list of disk group details on a given Unity storage system"""
1557
1558 try:
1559 LOG.info("Getting disk group list")
1560 pool_disk_list = []
1561 disk_instances = utils.UnityDiskGroupList(cli=self.unity._cli)
1562 if disk_instances:
1563 for disk in disk_instances:
1564 pool_disk = {"id": disk.id, "name": disk.name,
1565 "tier_type": disk.tier_type.name}
1566 pool_disk_list.append(pool_disk)
1567 return pool_disk_list
1568 except Exception as e:
1569 msg = 'Get disk group from unity array failed with' \
1570 ' error %s' % (str(e))
1571 LOG.error(msg)
1572 self.module.fail_json(msg=msg)
1573
1574 def get_nfs_server_list(self):
1575 """Get the list of NFS servers on a given Unity storage system"""
1576
1577 try:
1578 LOG.info("Getting NFS servers list")
1579 nfs_servers = self.unity.get_nfs_server()
1580 return nfs_server_result_list(nfs_servers)
1581
1582 except Exception as e:
1583 msg = 'Get NFS servers list from unity array failed with' \
1584 ' error %s' % (str(e))
1585 LOG.error(msg)
1586 self.module.fail_json(msg=msg)
1587
1588 def get_cifs_server_list(self):
1589 """Get the list of CIFS servers on a given Unity storage system"""
1590
1591 try:
1592 LOG.info("Getting CIFS servers list")
1593 cifs_servers = self.unity.get_cifs_server()
1594 return result_list(cifs_servers)
1595
1596 except Exception as e:
1597 msg = 'Get CIFS servers list from unity array failed with' \
1598 ' error %s' % (str(e))
1599 LOG.error(msg)
1600 self.module.fail_json(msg=msg)
1601
1602 def get_ethernet_port_list(self):
1603 """Get the list of ethernet ports on a given Unity storage system"""
1604
1605 try:
1606 LOG.info("Getting ethernet ports list")
1607 ethernet_port = self.unity.get_ethernet_port()
1608 return result_list(ethernet_port)
1609
1610 except Exception as e:
1611 msg = 'Get ethernet port list from unity array failed with' \
1612 ' error %s' % (str(e))
1613 LOG.error(msg)
1614 self.module.fail_json(msg=msg)
1615
1616 def get_file_interface_list(self):
1617 """Get the list of file interfaces on a given Unity storage system"""
1618
1619 try:
1620 LOG.info("Getting file interfaces list")
1621 file_interface = self.unity.get_file_interface()
1622 return file_interface_result_list(file_interface)
1623
1624 except Exception as e:
1625 msg = 'Get file interface list from unity array failed with' \
1626 ' error %s' % (str(e))
1627 LOG.error(msg)
1628 self.module.fail_json(msg=msg)
1629
1630 def get_replication_session_list(self):
1631 """Get the list of replication sessions on a given Unity storage system"""
1632
1633 try:
1634 LOG.info("Getting replication sessions list")
1635 replication_sessions = self.unity.get_replication_session()
1636 return result_list(replication_sessions)
1637
1638 except Exception as e:
1639 msg = 'Get replication session list from unity array failed with' \
1640 ' error %s' % (str(e))
1641 LOG.error(msg)
1642 self.module.fail_json(msg=msg)
1643
1644 def perform_module_operation(self):
1645 """ Perform different actions on Info based on user parameter
1646 chosen in playbook """
1647
1648 """ Get the array details a given Unity storage system """
1649
1650 array_details = self.get_array_details()
1651 host = []
1652 fc_initiator = []
1653 iscsi_initiator = []
1654 cg = []
1655 storage_pool = []
1656 vol = []
1657 snapshot_schedule = []
1658 nas_server = []
1659 file_system = []
1660 snapshot = []
1661 nfs_export = []
1662 smb_share = []
1663 user_quota = []
1664 tree_quota = []
1665 disk_group = []
1666 nfs_server = []
1667 cifs_server = []
1668 ethernet_port = []
1669 file_interface = []
1670 replication_session = []
1671
1672 subset = self.module.params['gather_subset']
1673 if subset is not None:
1674 if 'host' in subset:
1675 host = self.get_hosts_list()
1676 if 'fc_initiator' in subset:
1677 fc_initiator = self.get_fc_initiators_list()
1678 if 'iscsi_initiator' in subset:
1679 iscsi_initiator = self.get_iscsi_initiators_list()
1680 if 'cg' in subset:
1681 cg = self.get_consistency_groups_list()
1682 if 'storage_pool' in subset:
1683 storage_pool = self.get_storage_pools_list()
1684 if 'vol' in subset:
1685 vol = self.get_volumes_list()
1686 if 'snapshot_schedule' in subset:
1687 snapshot_schedule = self.get_snapshot_schedules_list()
1688 if 'nas_server' in subset:
1689 nas_server = self.get_nas_servers_list()
1690 if 'file_system' in subset:
1691 file_system = self.get_file_systems_list()
1692 if 'snapshot' in subset:
1693 snapshot = self.get_snapshots_list()
1694 if 'nfs_export' in subset:
1695 nfs_export = self.get_nfs_exports_list()
1696 if 'smb_share' in subset:
1697 smb_share = self.get_smb_shares_list()
1698 if 'user_quota' in subset:
1699 user_quota = self.get_user_quota_list()
1700 if 'tree_quota' in subset:
1701 tree_quota = self.get_tree_quota_list()
1702 if 'disk_group' in subset:
1703 disk_group = self.get_disk_groups_list()
1704 if 'nfs_server' in subset:
1705 nfs_server = self.get_nfs_server_list()
1706 if 'cifs_server' in subset:
1707 cifs_server = self.get_cifs_server_list()
1708 if 'ethernet_port' in subset:
1709 ethernet_port = self.get_ethernet_port_list()
1710 if 'file_interface' in subset:
1711 file_interface = self.get_file_interface_list()
1712 if 'replication_session' in subset:
1713 replication_session = self.get_replication_session_list()
1714
1715 self.module.exit_json(
1716 Array_Details=array_details,
1717 Hosts=host,
1718 FC_initiators=fc_initiator,
1719 ISCSI_initiators=iscsi_initiator,
1720 Consistency_Groups=cg,
1721 Storage_Pools=storage_pool,
1722 Volumes=vol,
1723 Snapshot_Schedules=snapshot_schedule,
1724 NAS_Servers=nas_server,
1725 File_Systems=file_system,
1726 Snapshots=snapshot,
1727 NFS_Exports=nfs_export,
1728 SMB_Shares=smb_share,
1729 User_Quotas=user_quota,
1730 Tree_Quotas=tree_quota,
1731 Disk_Groups=disk_group,
1732 NFS_Servers=nfs_server,
1733 CIFS_Servers=cifs_server,
1734 Ethernet_ports=ethernet_port,
1735 File_interfaces=file_interface,
1736 Replication_sessions=replication_session
1737 )
1738
1739
1740 def result_list(entity):
1741 """ Get the name and id associated with the Unity entities """
1742 result = []
1743
1744 if entity:
1745 LOG.info(SUCCESSFULL_LISTED_MSG)
1746 for item in entity:
1747 result.append(
1748 item._get_properties()
1749 )
1750 return result
1751 else:
1752 return None
1753
1754
1755 def fc_initiators_result_list(entity):
1756 """ Get the WWN and id associated with the Unity FC initiators """
1757 result = []
1758
1759 if entity:
1760 LOG.info(SUCCESSFULL_LISTED_MSG)
1761 for item in entity:
1762 result.append(
1763 {
1764 "WWN": item.initiator_id,
1765 "id": item.id
1766 }
1767 )
1768 return result
1769 else:
1770 return None
1771
1772
1773 def iscsi_initiators_result_list(entity):
1774 """ Get the IQN and id associated with the Unity ISCSI initiators """
1775 result = []
1776
1777 if entity:
1778 LOG.info(SUCCESSFULL_LISTED_MSG)
1779 for item in entity:
1780 result.append(
1781 {
1782 "IQN": item.initiator_id,
1783 "id": item.id
1784 }
1785 )
1786 return result
1787 else:
1788 return None
1789
1790
1791 def user_quota_result_list(entity):
1792 """ Get the id and uid associated with the Unity user quotas """
1793 result = []
1794
1795 if entity:
1796 LOG.info(SUCCESSFULL_LISTED_MSG)
1797 for item in entity:
1798 result.append(
1799 {
1800 "uid": item.uid,
1801 "id": item.id
1802 }
1803 )
1804 return result
1805 else:
1806 return None
1807
1808
1809 def tree_quota_result_list(entity):
1810 """ Get the id and path associated with the Unity quota trees """
1811 result = []
1812
1813 if entity:
1814 LOG.info(SUCCESSFULL_LISTED_MSG)
1815 for item in entity:
1816 result.append(
1817 {
1818 "path": item.path,
1819 "id": item.id
1820 }
1821 )
1822 return result
1823 else:
1824 return None
1825
1826
1827 def nfs_server_result_list(entity):
1828 """ Get the id of NFS Server """
1829 result = []
1830
1831 if entity:
1832 LOG.info(SUCCESSFULL_LISTED_MSG)
1833 for item in entity:
1834 result.append(
1835 item._get_properties()
1836 )
1837 return result
1838 else:
1839 return None
1840
1841
1842 def file_interface_result_list(entity):
1843 """ Get the id, name and IP of File Interfaces """
1844 result = []
1845
1846 if entity:
1847 LOG.info(SUCCESSFULL_LISTED_MSG)
1848 for item in entity:
1849 result.append(
1850 item._get_properties()
1851 )
1852 return result
1853 else:
1854 return None
1855
1856
1857 def get_info_parameters():
1858 """This method provides parameters required for the ansible
1859 info module on Unity"""
1860 return dict(gather_subset=dict(type='list', required=False,
1861 elements='str',
1862 choices=['host', 'fc_initiator',
1863 'iscsi_initiator', 'cg',
1864 'storage_pool', 'vol',
1865 'snapshot_schedule', 'nas_server',
1866 'file_system', 'snapshot',
1867 'nfs_export', 'smb_share',
1868 'user_quota', 'tree_quota', 'disk_group', 'nfs_server', 'cifs_server',
1869 'ethernet_port', 'file_interface', 'replication_session']))
1870
1871
1872 def main():
1873 """ Create Unity Info object and perform action on it
1874 based on user input from playbook"""
1875 obj = Info()
1876 obj.perform_module_operation()
1877
1878
1879 if __name__ == '__main__':
1880 main()