2424
2525__metaclass__ = type
2626
27-
2827from ansible .utils .display import Display
2928from ansible .plugins .action import ActionBase
3029from .rest_module_utils import get_rest_module
@@ -44,11 +43,18 @@ def run(self, tmp=None, task_vars=None):
4443 child_fabrics = self ._task .args ['child_fabrics' ]
4544 state = self ._task .args ['state' ]
4645
46+ network_os = task_vars ['ansible_network_os' ]
47+ rest_module = get_rest_module (network_os )
48+ if not rest_module :
49+ results ['failed' ] = True
50+ results ['msg' ] = f"Unsupported network_os: { network_os } "
51+ return results
52+
4753 if state == 'present' :
4854 for fabric in child_fabrics :
4955 json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric , fabric )
5056 add_fabric_result = self ._execute_module (
51- module_name = task_vars [ 'ansible_network_os_rest' ] ,
57+ module_name = rest_module ,
5258 module_args = {
5359 "method" : "POST" ,
5460 "path" : "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd" ,
@@ -77,7 +83,7 @@ def run(self, tmp=None, task_vars=None):
7783 for fabric in child_fabrics :
7884 json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric , fabric )
7985 remove_fabric_result = self ._execute_module (
80- module_name = task_vars [ 'ansible_network_os_rest' ] ,
86+ module_name = rest_module ,
8187 module_args = {
8288 "method" : "POST" ,
8389 "path" : "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdExit" ,
0 commit comments