From 6dc6538eefedfba399c2289a6b7b8d50014d756b Mon Sep 17 00:00:00 2001 From: Chris Archibald Date: Wed, 28 Nov 2018 12:03:44 -0800 Subject: [PATCH] Bug fixes for na_ontap_fcp (#48583) --- lib/ansible/modules/storage/netapp/na_ontap_fcp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/storage/netapp/na_ontap_fcp.py b/lib/ansible/modules/storage/netapp/na_ontap_fcp.py index 1f2e53fb5d..997c2088ae 100644 --- a/lib/ansible/modules/storage/netapp/na_ontap_fcp.py +++ b/lib/ansible/modules/storage/netapp/na_ontap_fcp.py @@ -111,9 +111,12 @@ class NetAppOntapFCP(object): try: self.server.invoke_successfully(netapp_utils.zapi.NaElement('fcp-service-start'), True) except netapp_utils.zapi.NaApiError as error: - self.module.fail_json(msg='Error starting FCP %s' % - (to_native(error)), - exception=traceback.format_exc()) + # Error 13013 denotes fcp service already started. + if to_native(error.code) == "13013": + return None + else: + self.module.fail_json(msg='Error starting FCP %s' % (to_native(error)), + exception=traceback.format_exc()) def stop_fcp(self): """ @@ -164,6 +167,9 @@ class NetAppOntapFCP(object): exception=traceback.format_exc()) def apply(self): + results = netapp_utils.get_cserver(self.server) + cserver = netapp_utils.setup_na_ontap_zapi(module=self.module, vserver=results) + netapp_utils.ems_log_event("na_ontap_fcp", cserver) exists = self.get_fcp() changed = False if self.parameters['state'] == 'present': @@ -180,6 +186,8 @@ class NetAppOntapFCP(object): self.create_fcp() if self.parameters['status'] == 'up': self.start_fcp() + elif self.parameters['status'] == 'down': + self.stop_fcp() changed = True else: if exists: