Debian Codegraph @

ansible_collections/dellemc/openmanage/tests/unit/plugins/modules/test_ome_profile_info.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 # Dell OpenManage Ansible Modules
3 # Version 10.0.0
4 # Copyright (C) 2023-2025 Dell Inc. or its subsidiaries. All Rights Reserved.
5 # GNU General Public License v3.0+
6 # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
7
8
9 from __future__ import (absolute_import, division, print_function)
10
11 __metaclass__ = type
12
13 import json
14 from io import StringIO
15 import pytest
16 from ansible.module_utils._text import to_text
17 from ansible.module_utils.six.moves.urllib.error import HTTPError, URLError
18 from ansible.module_utils.urls import ConnectionError, SSLValidationError
19 from ansible_collections.dellemc.openmanage.plugins.modules import ome_profile_info
20 from ansible_collections.dellemc.openmanage.tests.unit.plugins.modules.common import FakeAnsibleModule
21
22 SUCCESS_MSG = "Successfully retrieved the profile information."
23 NO_PROFILES_MSG = "No profiles were found."
24 MODULE_PATH = 'ansible_collections.dellemc.openmanage.plugins.modules.ome_profile_info.'
25
26
27 @pytest.fixture
28 def ome_connection_mock_for_profile_info(mocker, ome_response_mock):
29 connection_class_mock = mocker.patch(MODULE_PATH + 'RestOME')
30 ome_connection_mock_obj = connection_class_mock.return_value.__enter__.return_value
31 ome_connection_mock_obj.invoke_request.return_value = ome_response_mock
32 return ome_connection_mock_obj
33
34
35 class TestOmeProfileInfo(FakeAnsibleModule):
36 module = ome_profile_info
37
38 @pytest.mark.parametrize("params", [
39 {"json_data": {"value": [{'Id': 1234, 'Name': "ABCTAG1", "Type": 1000}],
40 "AttributeGroups": [
41 {
42 "GroupNameId": 9,
43 "DisplayName": "iDRAC",
44 "SubAttributeGroups": [
45 {
46 "GroupNameId": 32688,
47 "DisplayName": "Active Directory",
48 "SubAttributeGroups": [],
49 "Attributes": [
50 {
51 "AttributeId": 7587,
52 "CustomId": 0,
53 "AttributeEditInfoId": 2342,
54 "DisplayName": "ActiveDirectory 1 Active Directory RAC Name",
55 "Description": None,
56 "Value": None,
57 "IsReadOnly": False,
58 "IsIgnored": True,
59 "IsSecure": False,
60 "IsLinkedToSecure": False,
61 "TargetSpecificTypeId": 3
62 }
63 ]
64 },
65 {
66 "GroupNameId": 32851,
67 "DisplayName": "IPv4 Information",
68 "SubAttributeGroups": [],
69 "Attributes": [
70 {
71 "AttributeId": 8133,
72 "CustomId": 0,
73 "AttributeEditInfoId": 2199,
74 "DisplayName": "IPv4 1 IPv4 DHCP Enable",
75 "Description": None,
76 "Value": "Enabled",
77 "IsReadOnly": False,
78 "IsIgnored": True,
79 "IsSecure": False,
80 "IsLinkedToSecure": False,
81 "TargetSpecificTypeId": 2
82 },
83 {
84 "AttributeId": 7974,
85 "CustomId": 0,
86 "AttributeEditInfoId": 2198,
87 "DisplayName": "IPv4 1 IPv4 Enable",
88 "Description": None,
89 "Value": "Enabled",
90 "IsReadOnly": False,
91 "IsIgnored": True,
92 "IsSecure": False,
93 "IsLinkedToSecure": False,
94 "TargetSpecificTypeId": 2
95 }
96 ]
97 },
98 {
99 "GroupNameId": 32852,
100 "DisplayName": "IPv4 Static Information",
101 "SubAttributeGroups": [],
102 "Attributes": [
103 {
104 "AttributeId": 7916,
105 "CustomId": 0,
106 "AttributeEditInfoId": 2400,
107 "DisplayName": "IPv4Static 1 Gateway",
108 "Description": None,
109 "Value": "XX.XX.XX.XX",
110 "IsReadOnly": False,
111 "IsIgnored": True,
112 "IsSecure": False,
113 "IsLinkedToSecure": False,
114 "TargetSpecificTypeId": 2
115 },
116 {
117 "AttributeId": 8245,
118 "CustomId": 0,
119 "AttributeEditInfoId": 2399,
120 "DisplayName": "IPv4Static 1 IPv4 Address",
121 "Description": None,
122 "Value": "XX.XX.XX.XX20",
123 "IsReadOnly": False,
124 "IsIgnored": True,
125 "IsSecure": False,
126 "IsLinkedToSecure": False,
127 "TargetSpecificTypeId": 3
128 },
129 {
130 "AttributeId": 7724,
131 "CustomId": 0,
132 "AttributeEditInfoId": 2403,
133 "DisplayName": "IPv4Static 1 Net Mask",
134 "Description": None,
135 "Value": "XXX.XXX.XXX.XXX",
136 "IsReadOnly": False,
137 "IsIgnored": True,
138 "IsSecure": False,
139 "IsLinkedToSecure": False,
140 "TargetSpecificTypeId": 2
141 }
142 ]
143 },
144 {
145 "GroupNameId": 32855,
146 "DisplayName": "IPv6 Information",
147 "SubAttributeGroups": [],
148 "Attributes": [
149 {
150 "AttributeId": 8186,
151 "CustomId": 0,
152 "AttributeEditInfoId": 2207,
153 "DisplayName": "IPv6 1 IPV6 Auto Config",
154 "Description": None,
155 "Value": "Enabled",
156 "IsReadOnly": False,
157 "IsIgnored": True,
158 "IsSecure": False,
159 "IsLinkedToSecure": False,
160 "TargetSpecificTypeId": 2
161 },
162 {
163 "AttributeId": 7973,
164 "CustomId": 0,
165 "AttributeEditInfoId": 2205,
166 "DisplayName": "IPv6 1 IPV6 Enable",
167 "Description": None,
168 "Value": "Disabled",
169 "IsReadOnly": False,
170 "IsIgnored": True,
171 "IsSecure": False,
172 "IsLinkedToSecure": False,
173 "TargetSpecificTypeId": 2
174 }
175 ]
176 },
177 {
178 "GroupNameId": 32856,
179 "DisplayName": "IPv6 Static Information",
180 "SubAttributeGroups": [],
181 "Attributes": [
182 {
183 "AttributeId": 8244,
184 "CustomId": 0,
185 "AttributeEditInfoId": 2405,
186 "DisplayName": "IPv6Static 1 IPv6 Address 1",
187 "Description": None,
188 "Value": "::",
189 "IsReadOnly": False,
190 "IsIgnored": True,
191 "IsSecure": False,
192 "IsLinkedToSecure": False,
193 "TargetSpecificTypeId": 3
194 },
195 {
196 "AttributeId": 7917,
197 "CustomId": 0,
198 "AttributeEditInfoId": 2404,
199 "DisplayName": "IPv6Static 1 IPv6 Gateway",
200 "Description": None,
201 "Value": "::",
202 "IsReadOnly": False,
203 "IsIgnored": True,
204 "IsSecure": False,
205 "IsLinkedToSecure": False,
206 "TargetSpecificTypeId": 2
207 },
208 {
209 "AttributeId": 7687,
210 "CustomId": 0,
211 "AttributeEditInfoId": 2408,
212 "DisplayName": "IPv6Static 1 IPV6 Link Local Prefix Length",
213 "Description": None,
214 "Value": None,
215 "IsReadOnly": False,
216 "IsIgnored": True,
217 "IsSecure": False,
218 "IsLinkedToSecure": False,
219 "TargetSpecificTypeId": 3
220 }
221 ]
222 },
223 {
224 "GroupNameId": 32930,
225 "DisplayName": "NIC Information",
226 "SubAttributeGroups": [],
227 "Attributes": [
228 {
229 "AttributeId": 8111,
230 "CustomId": 0,
231 "AttributeEditInfoId": 2193,
232 "DisplayName": "NIC 1 DNS RAC Name",
233 "Description": None,
234 "Value": None,
235 "IsReadOnly": False,
236 "IsIgnored": True,
237 "IsSecure": False,
238 "IsLinkedToSecure": False,
239 "TargetSpecificTypeId": 3
240 },
241 {
242 "AttributeId": 7189,
243 "CustomId": 0,
244 "AttributeEditInfoId": 2194,
245 "DisplayName": "NIC 1 Enable VLAN",
246 "Description": None,
247 "Value": "Disabled",
248 "IsReadOnly": False,
249 "IsIgnored": False,
250 "IsSecure": False,
251 "IsLinkedToSecure": False,
252 "TargetSpecificTypeId": 2
253 },
254 {
255 "AttributeId": 7166,
256 "CustomId": 0,
257 "AttributeEditInfoId": 2197,
258 "DisplayName": "NIC 1 VLAN ID",
259 "Description": None,
260 "Value": "1",
261 "IsReadOnly": False,
262 "IsIgnored": False,
263 "IsSecure": False,
264 "IsLinkedToSecure": False,
265 "TargetSpecificTypeId": 2
266 }
267 ]
268 },
269 {
270 "GroupNameId": 32934,
271 "DisplayName": "NIC Static Information",
272 "SubAttributeGroups": [],
273 "Attributes": [
274 {
275 "AttributeId": 8116,
276 "CustomId": 0,
277 "AttributeEditInfoId": 2396,
278 "DisplayName": "NICStatic 1 DNS Domain Name",
279 "Description": None,
280 "Value": None,
281 "IsReadOnly": False,
282 "IsIgnored": True,
283 "IsSecure": False,
284 "IsLinkedToSecure": False,
285 "TargetSpecificTypeId": 3
286 }
287 ]
288 }
289 ],
290 "Attributes": []
291 },
292 {
293 "GroupNameId": 4,
294 "DisplayName": "NIC",
295 "SubAttributeGroups": [
296 {
297 "GroupNameId": 66,
298 "DisplayName": "NIC.Integrated.1-1-1",
299 "SubAttributeGroups": [
300 {
301 "GroupNameId": 32761,
302 "DisplayName": "FCoE Target 01",
303 "SubAttributeGroups": [],
304 "Attributes": [
305 {
306 "AttributeId": 6723,
307 "CustomId": 0,
308 "AttributeEditInfoId": 4769,
309 "DisplayName": "Boot LUN",
310 "Description": None,
311 "Value": "0",
312 "IsReadOnly": False,
313 "IsIgnored": True,
314 "IsSecure": False,
315 "IsLinkedToSecure": False,
316 "TargetSpecificTypeId": 2
317 },
318 {
319 "AttributeId": 6735,
320 "CustomId": 0,
321 "AttributeEditInfoId": 5083,
322 "DisplayName": "Boot Order",
323 "Description": None,
324 "Value": "0",
325 "IsReadOnly": False,
326 "IsIgnored": False,
327 "IsSecure": False,
328 "IsLinkedToSecure": False,
329 "TargetSpecificTypeId": 2
330 },
331 {
332 "AttributeId": 6722,
333 "CustomId": 0,
334 "AttributeEditInfoId": 4734,
335 "DisplayName": "Virtual LAN ID",
336 "Description": None,
337 "Value": "1",
338 "IsReadOnly": False,
339 "IsIgnored": True,
340 "IsSecure": False,
341 "IsLinkedToSecure": False,
342 "TargetSpecificTypeId": 2
343 },
344 {
345 "AttributeId": 6721,
346 "CustomId": 0,
347 "AttributeEditInfoId": 4641,
348 "DisplayName": "World Wide Port Name Target",
349 "Description": None,
350 "Value": "00:00:00:00:00:00:00:00",
351 "IsReadOnly": False,
352 "IsIgnored": True,
353 "IsSecure": False,
354 "IsLinkedToSecure": False,
355 "TargetSpecificTypeId": 2
356 }
357 ]
358 },
359 {
360 "GroupNameId": 32762,
361 "DisplayName": "FCoE Target 02",
362 "SubAttributeGroups": [],
363 "Attributes": [
364 {
365 "AttributeId": 6733,
366 "CustomId": 0,
367 "AttributeEditInfoId": 5113,
368 "DisplayName": "Boot Order",
369 "Description": None,
370 "Value": "0",
371 "IsReadOnly": False,
372 "IsIgnored": False,
373 "IsSecure": False,
374 "IsLinkedToSecure": False,
375 "TargetSpecificTypeId": 2
376 }
377 ]
378 },
379 {
380 "GroupNameId": 32763,
381 "DisplayName": "FCoE Target 03",
382 "SubAttributeGroups": [],
383 "Attributes": [
384 {
385 "AttributeId": 6732,
386 "CustomId": 0,
387 "AttributeEditInfoId": 5122,
388 "DisplayName": "Boot Order",
389 "Description": None,
390 "Value": "0",
391 "IsReadOnly": False,
392 "IsIgnored": False,
393 "IsSecure": False,
394 "IsLinkedToSecure": False,
395 "TargetSpecificTypeId": 2
396 }
397 ]
398 },
399 {
400 "GroupNameId": 32764,
401 "DisplayName": "FCoE Target 04",
402 "SubAttributeGroups": [],
403 "Attributes": [
404 {
405 "AttributeId": 6734,
406 "CustomId": 0,
407 "AttributeEditInfoId": 5082,
408 "DisplayName": "Boot Order",
409 "Description": None,
410 "Value": "0",
411 "IsReadOnly": False,
412 "IsIgnored": False,
413 "IsSecure": False,
414 "IsLinkedToSecure": False,
415 "TargetSpecificTypeId": 2
416 }
417 ]
418 },
419 {
420 "GroupNameId": 32870,
421 "DisplayName": "iSCSI General Parameters",
422 "SubAttributeGroups": [],
423 "Attributes": [
424 {
425 "AttributeId": 6730,
426 "CustomId": 0,
427 "AttributeEditInfoId": 4768,
428 "DisplayName": "CHAP Authentication",
429 "Description": None,
430 "Value": None,
431 "IsReadOnly": False,
432 "IsIgnored": True,
433 "IsSecure": False,
434 "IsLinkedToSecure": False,
435 "TargetSpecificTypeId": 3
436 },
437 {
438 "AttributeId": 6729,
439 "CustomId": 0,
440 "AttributeEditInfoId": 4767,
441 "DisplayName": "CHAP Mutual Authentication",
442 "Description": None,
443 "Value": None,
444 "IsReadOnly": False,
445 "IsIgnored": True,
446 "IsSecure": False,
447 "IsLinkedToSecure": False,
448 "TargetSpecificTypeId": 3
449 }
450 ]
451 },
452 {
453 "GroupNameId": 32871,
454 "DisplayName": "iSCSI Initiator Parameters",
455 "SubAttributeGroups": [],
456 "Attributes": [
457 {
458 "AttributeId": 6713,
459 "CustomId": 0,
460 "AttributeEditInfoId": 4601,
461 "DisplayName": "CHAP ID",
462 "Description": None,
463 "Value": None,
464 "IsReadOnly": False,
465 "IsIgnored": True,
466 "IsSecure": False,
467 "IsLinkedToSecure": False,
468 "TargetSpecificTypeId": 2
469 },
470 {
471 "AttributeId": 6712,
472 "CustomId": 0,
473 "AttributeEditInfoId": 4681,
474 "DisplayName": "CHAP Secret",
475 "Description": None,
476 "Value": None,
477 "IsReadOnly": False,
478 "IsIgnored": True,
479 "IsSecure": False,
480 "IsLinkedToSecure": False,
481 "TargetSpecificTypeId": 2
482 }
483 ]
484 },
485 {
486 "GroupNameId": 32867,
487 "DisplayName": "iSCSI Target 01",
488 "SubAttributeGroups": [],
489 "Attributes": [
490 {
491 "AttributeId": 6720,
492 "CustomId": 0,
493 "AttributeEditInfoId": 4802,
494 "DisplayName": "Boot LUN",
495 "Description": None,
496 "Value": "0",
497 "IsReadOnly": False,
498 "IsIgnored": True,
499 "IsSecure": False,
500 "IsLinkedToSecure": False,
501 "TargetSpecificTypeId": 2
502 },
503 {
504 "AttributeId": 6719,
505 "CustomId": 0,
506 "AttributeEditInfoId": 4920,
507 "DisplayName": "CHAP Secret",
508 "Description": None,
509 "Value": None,
510 "IsReadOnly": False,
511 "IsIgnored": True,
512 "IsSecure": False,
513 "IsLinkedToSecure": False,
514 "TargetSpecificTypeId": 2
515 },
516 {
517 "AttributeId": 6718,
518 "CustomId": 0,
519 "AttributeEditInfoId": 4609,
520 "DisplayName": "IP Address",
521 "Description": None,
522 "Value": "0.0.0.0",
523 "IsReadOnly": False,
524 "IsIgnored": True,
525 "IsSecure": False,
526 "IsLinkedToSecure": False,
527 "TargetSpecificTypeId": 2
528 },
529 {
530 "AttributeId": 6717,
531 "CustomId": 0,
532 "AttributeEditInfoId": 4537,
533 "DisplayName": "iSCSI Name",
534 "Description": None,
535 "Value": None,
536 "IsReadOnly": False,
537 "IsIgnored": True,
538 "IsSecure": False,
539 "IsLinkedToSecure": False,
540 "TargetSpecificTypeId": 2
541 },
542 {
543 "AttributeId": 6716,
544 "CustomId": 0,
545 "AttributeEditInfoId": 4698,
546 "DisplayName": "TCP Port",
547 "Description": None,
548 "Value": "3260",
549 "IsReadOnly": False,
550 "IsIgnored": True,
551 "IsSecure": False,
552 "IsLinkedToSecure": False,
553 "TargetSpecificTypeId": 2
554 }
555 ]
556 }
557 ],
558 "Attributes": []
559 },
560 {
561 "GroupNameId": 67,
562 "DisplayName": "NIC.Integrated.1-2-1",
563 "SubAttributeGroups": [
564 {
565 "GroupNameId": 32761,
566 "DisplayName": "FCoE Target 01",
567 "SubAttributeGroups": [],
568 "Attributes": [
569 {
570 "AttributeId": 6788,
571 "CustomId": 0,
572 "AttributeEditInfoId": 4769,
573 "DisplayName": "Boot LUN",
574 "Description": None,
575 "Value": "0",
576 "IsReadOnly": False,
577 "IsIgnored": True,
578 "IsSecure": False,
579 "IsLinkedToSecure": False,
580 "TargetSpecificTypeId": 2
581 },
582 {
583 "AttributeId": 6801,
584 "CustomId": 0,
585 "AttributeEditInfoId": 5083,
586 "DisplayName": "Boot Order",
587 "Description": None,
588 "Value": "0",
589 "IsReadOnly": False,
590 "IsIgnored": False,
591 "IsSecure": False,
592 "IsLinkedToSecure": False,
593 "TargetSpecificTypeId": 2
594 },
595 {
596 "AttributeId": 6787,
597 "CustomId": 0,
598 "AttributeEditInfoId": 4734,
599 "DisplayName": "Virtual LAN ID",
600 "Description": None,
601 "Value": "1",
602 "IsReadOnly": False,
603 "IsIgnored": True,
604 "IsSecure": False,
605 "IsLinkedToSecure": False,
606 "TargetSpecificTypeId": 2
607 },
608 {
609 "AttributeId": 6786,
610 "CustomId": 0,
611 "AttributeEditInfoId": 4641,
612 "DisplayName": "World Wide Port Name Target",
613 "Description": None,
614 "Value": "00:00:00:00:00:00:00:00",
615 "IsReadOnly": False,
616 "IsIgnored": True,
617 "IsSecure": False,
618 "IsLinkedToSecure": False,
619 "TargetSpecificTypeId": 2
620 }
621 ]
622 },
623 {
624 "GroupNameId": 32762,
625 "DisplayName": "FCoE Target 02",
626 "SubAttributeGroups": [],
627 "Attributes": [
628 {
629 "AttributeId": 6799,
630 "CustomId": 0,
631 "AttributeEditInfoId": 5113,
632 "DisplayName": "Boot Order",
633 "Description": None,
634 "Value": "0",
635 "IsReadOnly": False,
636 "IsIgnored": False,
637 "IsSecure": False,
638 "IsLinkedToSecure": False,
639 "TargetSpecificTypeId": 2
640 }
641 ]
642 },
643 {
644 "GroupNameId": 32763,
645 "DisplayName": "FCoE Target 03",
646 "SubAttributeGroups": [],
647 "Attributes": [
648 {
649 "AttributeId": 6798,
650 "CustomId": 0,
651 "AttributeEditInfoId": 5122,
652 "DisplayName": "Boot Order",
653 "Description": None,
654 "Value": "0",
655 "IsReadOnly": False,
656 "IsIgnored": False,
657 "IsSecure": False,
658 "IsLinkedToSecure": False,
659 "TargetSpecificTypeId": 2
660 }
661 ]
662 },
663 {
664 "GroupNameId": 32764,
665 "DisplayName": "FCoE Target 04",
666 "SubAttributeGroups": [],
667 "Attributes": [
668 {
669 "AttributeId": 6800,
670 "CustomId": 0,
671 "AttributeEditInfoId": 5082,
672 "DisplayName": "Boot Order",
673 "Description": None,
674 "Value": "0",
675 "IsReadOnly": False,
676 "IsIgnored": False,
677 "IsSecure": False,
678 "IsLinkedToSecure": False,
679 "TargetSpecificTypeId": 2
680 }
681 ]
682 },
683 {
684 "GroupNameId": 32870,
685 "DisplayName": "iSCSI General Parameters",
686 "SubAttributeGroups": [],
687 "Attributes": [
688 {
689 "AttributeId": 6796,
690 "CustomId": 0,
691 "AttributeEditInfoId": 4768,
692 "DisplayName": "CHAP Authentication",
693 "Description": None,
694 "Value": None,
695 "IsReadOnly": False,
696 "IsIgnored": True,
697 "IsSecure": False,
698 "IsLinkedToSecure": False,
699 "TargetSpecificTypeId": 3
700 },
701 {
702 "AttributeId": 6795,
703 "CustomId": 0,
704 "AttributeEditInfoId": 4767,
705 "DisplayName": "CHAP Mutual Authentication",
706 "Description": None,
707 "Value": None,
708 "IsReadOnly": False,
709 "IsIgnored": True,
710 "IsSecure": False,
711 "IsLinkedToSecure": False,
712 "TargetSpecificTypeId": 3
713 }
714 ]
715 },
716 {
717 "GroupNameId": 32871,
718 "DisplayName": "iSCSI Initiator Parameters",
719 "SubAttributeGroups": [],
720 "Attributes": [
721 {
722 "AttributeId": 6778,
723 "CustomId": 0,
724 "AttributeEditInfoId": 4601,
725 "DisplayName": "CHAP ID",
726 "Description": None,
727 "Value": None,
728 "IsReadOnly": False,
729 "IsIgnored": True,
730 "IsSecure": False,
731 "IsLinkedToSecure": False,
732 "TargetSpecificTypeId": 2
733 },
734 {
735 "AttributeId": 6777,
736 "CustomId": 0,
737 "AttributeEditInfoId": 4681,
738 "DisplayName": "CHAP Secret",
739 "Description": None,
740 "Value": None,
741 "IsReadOnly": False,
742 "IsIgnored": True,
743 "IsSecure": False,
744 "IsLinkedToSecure": False,
745 "TargetSpecificTypeId": 2
746 }
747 ]
748 },
749 {
750 "GroupNameId": 32867,
751 "DisplayName": "iSCSI Target 01",
752 "SubAttributeGroups": [],
753 "Attributes": [
754 {
755 "AttributeId": 6785,
756 "CustomId": 0,
757 "AttributeEditInfoId": 4802,
758 "DisplayName": "Boot LUN",
759 "Description": None,
760 "Value": "0",
761 "IsReadOnly": False,
762 "IsIgnored": True,
763 "IsSecure": False,
764 "IsLinkedToSecure": False,
765 "TargetSpecificTypeId": 2
766 },
767 {
768 "AttributeId": 6784,
769 "CustomId": 0,
770 "AttributeEditInfoId": 4920,
771 "DisplayName": "CHAP Secret",
772 "Description": None,
773 "Value": None,
774 "IsReadOnly": False,
775 "IsIgnored": True,
776 "IsSecure": False,
777 "IsLinkedToSecure": False,
778 "TargetSpecificTypeId": 2
779 },
780 {
781 "AttributeId": 6783,
782 "CustomId": 0,
783 "AttributeEditInfoId": 4609,
784 "DisplayName": "IP Address",
785 "Description": None,
786 "Value": "0.0.0.0",
787 "IsReadOnly": False,
788 "IsIgnored": True,
789 "IsSecure": False,
790 "IsLinkedToSecure": False,
791 "TargetSpecificTypeId": 2
792 },
793 {
794 "AttributeId": 6782,
795 "CustomId": 0,
796 "AttributeEditInfoId": 4537,
797 "DisplayName": "iSCSI Name",
798 "Description": None,
799 "Value": None,
800 "IsReadOnly": False,
801 "IsIgnored": True,
802 "IsSecure": False,
803 "IsLinkedToSecure": False,
804 "TargetSpecificTypeId": 2
805 },
806 {
807 "AttributeId": 6781,
808 "CustomId": 0,
809 "AttributeEditInfoId": 4698,
810 "DisplayName": "TCP Port",
811 "Description": None,
812 "Value": "3260",
813 "IsReadOnly": False,
814 "IsIgnored": True,
815 "IsSecure": False,
816 "IsLinkedToSecure": False,
817 "TargetSpecificTypeId": 2
818 }
819 ]
820 }
821 ],
822 "Attributes": []
823 },
824 {
825 "GroupNameId": 65,
826 "DisplayName": "NIC.Integrated.1-3-1",
827 "SubAttributeGroups": [
828 {
829 "GroupNameId": 32870,
830 "DisplayName": "iSCSI General Parameters",
831 "SubAttributeGroups": [],
832 "Attributes": [
833 {
834 "AttributeId": 6677,
835 "CustomId": 0,
836 "AttributeEditInfoId": 4768,
837 "DisplayName": "CHAP Authentication",
838 "Description": None,
839 "Value": None,
840 "IsReadOnly": False,
841 "IsIgnored": True,
842 "IsSecure": False,
843 "IsLinkedToSecure": False,
844 "TargetSpecificTypeId": 3
845 },
846 {
847 "AttributeId": 6676,
848 "CustomId": 0,
849 "AttributeEditInfoId": 4767,
850 "DisplayName": "CHAP Mutual Authentication",
851 "Description": None,
852 "Value": None,
853 "IsReadOnly": False,
854 "IsIgnored": True,
855 "IsSecure": False,
856 "IsLinkedToSecure": False,
857 "TargetSpecificTypeId": 3
858 }
859 ]
860 },
861 {
862 "GroupNameId": 32871,
863 "DisplayName": "iSCSI Initiator Parameters",
864 "SubAttributeGroups": [],
865 "Attributes": [
866 {
867 "AttributeId": 6664,
868 "CustomId": 0,
869 "AttributeEditInfoId": 4601,
870 "DisplayName": "CHAP ID",
871 "Description": None,
872 "Value": None,
873 "IsReadOnly": False,
874 "IsIgnored": True,
875 "IsSecure": False,
876 "IsLinkedToSecure": False,
877 "TargetSpecificTypeId": 2
878 },
879 {
880 "AttributeId": 6663,
881 "CustomId": 0,
882 "AttributeEditInfoId": 4681,
883 "DisplayName": "CHAP Secret",
884 "Description": None,
885 "Value": None,
886 "IsReadOnly": False,
887 "IsIgnored": True,
888 "IsSecure": False,
889 "IsLinkedToSecure": False,
890 "TargetSpecificTypeId": 2
891 }
892 ]
893 },
894 {
895 "GroupNameId": 32867,
896 "DisplayName": "iSCSI Target 01",
897 "SubAttributeGroups": [],
898 "Attributes": [
899 {
900 "AttributeId": 6671,
901 "CustomId": 0,
902 "AttributeEditInfoId": 4802,
903 "DisplayName": "Boot LUN",
904 "Description": None,
905 "Value": "0",
906 "IsReadOnly": False,
907 "IsIgnored": True,
908 "IsSecure": False,
909 "IsLinkedToSecure": False,
910 "TargetSpecificTypeId": 2
911 },
912 {
913 "AttributeId": 6670,
914 "CustomId": 0,
915 "AttributeEditInfoId": 4920,
916 "DisplayName": "CHAP Secret",
917 "Description": None,
918 "Value": None,
919 "IsReadOnly": False,
920 "IsIgnored": True,
921 "IsSecure": False,
922 "IsLinkedToSecure": False,
923 "TargetSpecificTypeId": 2
924 },
925 {
926 "AttributeId": 6669,
927 "CustomId": 0,
928 "AttributeEditInfoId": 4609,
929 "DisplayName": "IP Address",
930 "Description": None,
931 "Value": "0.0.0.0",
932 "IsReadOnly": False,
933 "IsIgnored": True,
934 "IsSecure": False,
935 "IsLinkedToSecure": False,
936 "TargetSpecificTypeId": 2
937 },
938 {
939 "AttributeId": 6668,
940 "CustomId": 0,
941 "AttributeEditInfoId": 4537,
942 "DisplayName": "iSCSI Name",
943 "Description": None,
944 "Value": None,
945 "IsReadOnly": False,
946 "IsIgnored": True,
947 "IsSecure": False,
948 "IsLinkedToSecure": False,
949 "TargetSpecificTypeId": 2
950 },
951 {
952 "AttributeId": 6667,
953 "CustomId": 0,
954 "AttributeEditInfoId": 4698,
955 "DisplayName": "TCP Port",
956 "Description": None,
957 "Value": "3260",
958 "IsReadOnly": False,
959 "IsIgnored": True,
960 "IsSecure": False,
961 "IsLinkedToSecure": False,
962 "TargetSpecificTypeId": 2
963 }
964 ]
965 }
966 ],
967 "Attributes": []
968 },
969 {
970 "GroupNameId": 68,
971 "DisplayName": "NIC.Integrated.1-4-1",
972 "SubAttributeGroups": [
973 {
974 "GroupNameId": 32870,
975 "DisplayName": "iSCSI General Parameters",
976 "SubAttributeGroups": [],
977 "Attributes": [
978 {
979 "AttributeId": 6852,
980 "CustomId": 0,
981 "AttributeEditInfoId": 4768,
982 "DisplayName": "CHAP Authentication",
983 "Description": None,
984 "Value": None,
985 "IsReadOnly": False,
986 "IsIgnored": True,
987 "IsSecure": False,
988 "IsLinkedToSecure": False,
989 "TargetSpecificTypeId": 3
990 },
991 {
992 "AttributeId": 6851,
993 "CustomId": 0,
994 "AttributeEditInfoId": 4767,
995 "DisplayName": "CHAP Mutual Authentication",
996 "Description": None,
997 "Value": None,
998 "IsReadOnly": False,
999 "IsIgnored": True,
1000 "IsSecure": False,
1001 "IsLinkedToSecure": False,
1002 "TargetSpecificTypeId": 3
1003 }
1004 ]
1005 },
1006 {
1007 "GroupNameId": 32871,
1008 "DisplayName": "iSCSI Initiator Parameters",
1009 "SubAttributeGroups": [],
1010 "Attributes": [
1011 {
1012 "AttributeId": 6838,
1013 "CustomId": 0,
1014 "AttributeEditInfoId": 4601,
1015 "DisplayName": "CHAP ID",
1016 "Description": None,
1017 "Value": None,
1018 "IsReadOnly": False,
1019 "IsIgnored": True,
1020 "IsSecure": False,
1021 "IsLinkedToSecure": False,
1022 "TargetSpecificTypeId": 2
1023 },
1024 {
1025 "AttributeId": 6837,
1026 "CustomId": 0,
1027 "AttributeEditInfoId": 4681,
1028 "DisplayName": "CHAP Secret",
1029 "Description": None,
1030 "Value": None,
1031 "IsReadOnly": False,
1032 "IsIgnored": True,
1033 "IsSecure": False,
1034 "IsLinkedToSecure": False,
1035 "TargetSpecificTypeId": 2
1036 }
1037 ]
1038 },
1039 {
1040 "GroupNameId": 32867,
1041 "DisplayName": "iSCSI Target 01",
1042 "SubAttributeGroups": [],
1043 "Attributes": [
1044 {
1045 "AttributeId": 6846,
1046 "CustomId": 0,
1047 "AttributeEditInfoId": 4802,
1048 "DisplayName": "Boot LUN",
1049 "Description": None,
1050 "Value": "0",
1051 "IsReadOnly": False,
1052 "IsIgnored": True,
1053 "IsSecure": False,
1054 "IsLinkedToSecure": False,
1055 "TargetSpecificTypeId": 2
1056 },
1057 {
1058 "AttributeId": 6845,
1059 "CustomId": 0,
1060 "AttributeEditInfoId": 4920,
1061 "DisplayName": "CHAP Secret",
1062 "Description": None,
1063 "Value": None,
1064 "IsReadOnly": False,
1065 "IsIgnored": True,
1066 "IsSecure": False,
1067 "IsLinkedToSecure": False,
1068 "TargetSpecificTypeId": 2
1069 },
1070 {
1071 "AttributeId": 6844,
1072 "CustomId": 0,
1073 "AttributeEditInfoId": 4609,
1074 "DisplayName": "IP Address",
1075 "Description": None,
1076 "Value": "0.0.0.0",
1077 "IsReadOnly": False,
1078 "IsIgnored": True,
1079 "IsSecure": False,
1080 "IsLinkedToSecure": False,
1081 "TargetSpecificTypeId": 2
1082 },
1083 {
1084 "AttributeId": 6843,
1085 "CustomId": 0,
1086 "AttributeEditInfoId": 4537,
1087 "DisplayName": "iSCSI Name",
1088 "Description": None,
1089 "Value": None,
1090 "IsReadOnly": False,
1091 "IsIgnored": True,
1092 "IsSecure": False,
1093 "IsLinkedToSecure": False,
1094 "TargetSpecificTypeId": 2
1095 },
1096 {
1097 "AttributeId": 6842,
1098 "CustomId": 0,
1099 "AttributeEditInfoId": 4698,
1100 "DisplayName": "TCP Port",
1101 "Description": None,
1102 "Value": "3260",
1103 "IsReadOnly": False,
1104 "IsIgnored": True,
1105 "IsSecure": False,
1106 "IsLinkedToSecure": False,
1107 "TargetSpecificTypeId": 2
1108 }
1109 ]
1110 }
1111 ],
1112 "Attributes": []
1113 }
1114 ],
1115 "Attributes": []
1116 },
1117 {
1118 "GroupNameId": 5,
1119 "DisplayName": "System",
1120 "SubAttributeGroups": [
1121 {
1122 "GroupNameId": 33016,
1123 "DisplayName": "Server Operating System",
1124 "SubAttributeGroups": [],
1125 "Attributes": [
1126 {
1127 "AttributeId": 8513,
1128 "CustomId": 0,
1129 "AttributeEditInfoId": 2497,
1130 "DisplayName": "ServerOS 1 Server Host Name",
1131 "Description": None,
1132 "Value": None,
1133 "IsReadOnly": False,
1134 "IsIgnored": True,
1135 "IsSecure": False,
1136 "IsLinkedToSecure": False,
1137 "TargetSpecificTypeId": 3
1138 }
1139 ]
1140 },
1141 {
1142 "GroupNameId": 33019,
1143 "DisplayName": "Server Topology",
1144 "SubAttributeGroups": [],
1145 "Attributes": [
1146 {
1147 "AttributeId": 8593,
1148 "CustomId": 0,
1149 "AttributeEditInfoId": 2248,
1150 "DisplayName": "ServerTopology 1 Aisle Name",
1151 "Description": None,
1152 "Value": None,
1153 "IsReadOnly": False,
1154 "IsIgnored": True,
1155 "IsSecure": False,
1156 "IsLinkedToSecure": False,
1157 "TargetSpecificTypeId": 2
1158 },
1159 {
1160 "AttributeId": 8551,
1161 "CustomId": 0,
1162 "AttributeEditInfoId": 2247,
1163 "DisplayName": "ServerTopology 1 Data Center Name",
1164 "Description": None,
1165 "Value": None,
1166 "IsReadOnly": False,
1167 "IsIgnored": True,
1168 "IsSecure": False,
1169 "IsLinkedToSecure": False,
1170 "TargetSpecificTypeId": 2
1171 },
1172 {
1173 "AttributeId": 8371,
1174 "CustomId": 0,
1175 "AttributeEditInfoId": 2249,
1176 "DisplayName": "ServerTopology 1 Rack Name",
1177 "Description": None,
1178 "Value": None,
1179 "IsReadOnly": False,
1180 "IsIgnored": True,
1181 "IsSecure": False,
1182 "IsLinkedToSecure": False,
1183 "TargetSpecificTypeId": 3
1184 },
1185 {
1186 "AttributeId": 8370,
1187 "CustomId": 0,
1188 "AttributeEditInfoId": 2250,
1189 "DisplayName": "ServerTopology 1 Rack Slot",
1190 "Description": None,
1191 "Value": None,
1192 "IsReadOnly": False,
1193 "IsIgnored": True,
1194 "IsSecure": False,
1195 "IsLinkedToSecure": False,
1196 "TargetSpecificTypeId": 3
1197 },
1198 {
1199 "AttributeId": 8346,
1200 "CustomId": 0,
1201 "AttributeEditInfoId": 2500,
1202 "DisplayName": "ServerTopology 1 Room Name",
1203 "Description": None,
1204 "Value": None,
1205 "IsReadOnly": False,
1206 "IsIgnored": True,
1207 "IsSecure": False,
1208 "IsLinkedToSecure": False,
1209 "TargetSpecificTypeId": 2
1210 }
1211 ]
1212 }
1213 ],
1214 "Attributes": []
1215 }]
1216 },
1217 'message': SUCCESS_MSG, "success": True, 'case': "template with id",
1218 'mparams': {"template_id": 1234}},
1219 {"json_data": {"value": [{'Id': 1234, 'Name': "temp1", "Type": 1000}]},
1220 'message': SUCCESS_MSG, "success": True, 'case': "template with name",
1221 'mparams': {"template_name": "temp1"}},
1222 {"json_data": {"value": [{'Id': 1234, 'Name': "temp2", "Type": 1000}]},
1223 'message': "Template with name 'temp1' not found.", "success": True, 'case': "template with name",
1224 'mparams': {"template_name": "temp1"}},
1225 {"json_data": {'Id': 1234, 'Name': "temp1", "Type": 1000},
1226 'message': SUCCESS_MSG, "success": True, 'case': "profile with id",
1227 'mparams': {"profile_id": 1234}},
1228 {"json_data": {"value": [{'Id': 1235, 'ProfileName': "prof0", "Type": 1000},
1229 {'Id': 1234, 'ProfileName': "prof1", "Type": 1000}]},
1230 'message': SUCCESS_MSG, "success": True, 'case': "profile with name",
1231 'mparams': {"profile_name": "prof1"}},
1232 {"json_data": {"value": [{'Id': 1235, 'ProfileName': "prof0", "Type": 1000},
1233 {'Id': 1234, 'ProfileName': "prof1", "Type": 1000}]},
1234 'message': "Profiles with profile_name prof2 not found.", "success": True, 'case': "profile with name",
1235 'mparams': {"profile_name": "prof2"}},
1236 {"json_data": {"value": [{'Id': 1234, 'Name': "prof1", "Type": 1000}]},
1237 'message': SUCCESS_MSG, "success": True, 'case': "template with name",
1238 'mparams': {"system_query_options": {"filter": "ProfileName eq 'prof2'"}}},
1239 {"json_data": {"value": [{'Id': 1234, 'Name': "prof1", "Type": 1000}]},
1240 'message': SUCCESS_MSG, "success": True, 'case': "template with name",
1241 'mparams': {}},
1242 ])
1243 def test_ome_profile_info_success(self, params, ome_connection_mock_for_profile_info, ome_response_mock,
1244 ome_default_args, module_mock):
1245 ome_response_mock.success = params.get("success", True)
1246 ome_response_mock.json_data = params['json_data']
1247 ome_connection_mock_for_profile_info.get_all_items_with_pagination.return_value = params['json_data']
1248 ome_default_args.update(params['mparams'])
1249 result = self._run_module(ome_default_args, check_mode=params.get('check_mode', False))
1250 assert result['msg'] == params['message']
1251
1252 @pytest.mark.parametrize("exc_type",
1253 [IOError, ValueError, TypeError, ConnectionError, HTTPError, URLError])
1254 def test_ome_profile_info_main_exception_failure_case(self, exc_type, mocker, ome_default_args,
1255 ome_connection_mock_for_profile_info, ome_response_mock):
1256 ome_default_args.update({"template_id": 1234})
1257 ome_response_mock.status_code = 400
1258 ome_response_mock.success = False
1259 json_str = to_text(json.dumps({"info": "error_details"}))
1260 if exc_type == URLError:
1261 mocker.patch(MODULE_PATH + 'get_template_details', side_effect=exc_type("url open error"))
1262 result = self._run_module(ome_default_args)
1263 assert result["unreachable"] is True
1264 elif exc_type not in [HTTPError, SSLValidationError]:
1265 mocker.patch(MODULE_PATH + 'get_template_details', side_effect=exc_type("exception message"))
1266 result = self._run_module(ome_default_args)
1267 assert result['failed'] is True
1268 else:
1269 mocker.patch(MODULE_PATH + 'get_template_details',
1270 side_effect=exc_type('https://testhost.com', 400, 'http error message',
1271 {"accept-type": "application/json"}, StringIO(json_str)))
1272 result = self._run_module(ome_default_args)
1273 assert result['failed'] is True
1274 assert 'msg' in result
1275
1276 def test_get_profile_with_exception(self, ome_connection_mock_for_profile_info,):
1277 query = {'Name': "prof1"}
1278 url_prm = None
1279 ome_connection_mock_for_profile_info.get_all_items_with_pagination.side_effect = Exception("exception")
1280 result = self.module.get_profile_query(ome_connection_mock_for_profile_info, query, url_prm)
1281 assert result == []
1282
1283 @pytest.mark.parametrize("params", [{"mparams": {}}])
1284 def test_fetch_profile_list_exception(self, params, ome_connection_mock_for_profile_info, ome_default_args):
1285 query = None
1286 url_prm = None
1287 f_module = self.get_module_mock(params=params["mparams"])
1288 ome_connection_mock_for_profile_info.get_all_items_with_pagination.return_value = {"value": []}
1289 with pytest.raises(Exception) as exc_info:
1290 self.module.fetch_profile_list(f_module, ome_connection_mock_for_profile_info, query, url_prm)
1291 assert str(exc_info.value) == "Successfully retrieved the profile information."