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