2626
2727from ansible .utils .display import Display
2828from ansible .plugins .action import ActionBase
29- from .rest_module_utils import get_rest_module
30- from ...plugin_utils / helper_functions import ndfc_get_fabric_attributes
31- from ...plugin_utils / helper_functions import ndfc_get_fabric_switches
29+ from ... plugin_utils . helper_functions import ndfc_get_fabric_attributes
30+ from ...plugin_utils . helper_functions import ndfc_get_fabric_switches
31+ from ...plugin_utils . helper_functions import get_rest_module
3232import re
3333
3434display = Display ()
@@ -45,10 +45,17 @@ def run(self, tmp=None, task_vars=None):
4545 model_data = self ._task .args ["model_data" ]
4646 parent_fabric = self ._task .args ["parent_fabric" ]
4747
48+ network_os = task_vars ['ansible_network_os' ]
49+ rest_module = get_rest_module (network_os )
50+ if not rest_module :
51+ results ['failed' ] = True
52+ results ['msg' ] = f"Unsupported network_os: { network_os } "
53+ return results
54+
4855 # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD
4956 # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD)
5057 msd_fabric_associations = self ._execute_module (
51- module_name = task_vars [ 'ansible_network_os_rest' ] ,
58+ module_name = rest_module ,
5259 module_args = {
5360 "method" : "GET" ,
5461 "path" : "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations" ,
0 commit comments