Debian Codegraph @

ansible_collections/netapp/ontap/plugins/module_utils/rest_ontap_personality.py

raw
1 """ Support functions for NetApp ansible modules
2 Provides common processing for responses and errors from REST calls
3 """
4
5 from __future__ import (absolute_import, division, print_function)
6 __metaclass__ = type
7
8 from ansible_collections.netapp.ontap.plugins.module_utils import rest_generic
9
10 # Below method of checking ONTAP personality is not valid for vsadmin login
11 # def check_ontap_personality(rest_api):
12 # api = "private/cli/debug/smdb/table/OntapPersonality" if rest_api.meets_rest_minimum_version(True, 9, 17, 1) \
13 # else "private/cli/debug/smdb/table/OntapMode"
14 # response, error = rest_generic.get_one_record(rest_api, api)
15 # return response, error
16
17
18 # def is_asa_r2_system(rest_api, module):
19 # """ Checks if the given host is ASA r2 system """
20 # record, error = check_ontap_personality(rest_api)
21 # if error:
22 # module.fail_json(msg='Failed while checking if the given host is an ASA r2 system or not')
23 # return record.get("ASA_R2") or record.get('ASA_NEXT')
24
25
26 def check_ontap_personality(rest_api):
27 api = "cluster"
28 fields = "san_optimized,disaggregated"
29 response, error = rest_generic.get_one_record(rest_api, api, fields=fields)
30 return response, error
31
32
33 def is_asa_r2_system(rest_api, module):
34 """ Checks if the given host is ASA r2 system """
35 record, error = check_ontap_personality(rest_api)
36 if error:
37 module.fail_json(msg='Failed while checking if the given host is an ASA r2 system or not')
38
39 # If both san_optimized and disaggregated are true, the system is ASA r2.
40 # If san_optimized is false but disaggregated is true, the system is AFX (aka OAM)
41 # If disaggregated is false and san_optimized is true, the system is the original ASA.
42 # If disaggregated is false, the system is Unified ONTAP.
43 return record.get("san_optimized") and record.get("disaggregated")