bug fix: dest_hostname is required for peering a vserver in remote cluster (#54066)

* Revert "changes to clusteR"

This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80.

* Revert "changes to clusteR"

This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80.

* Revert "Revert "changes to clusteR""

This reverts commit f1104a37b4.

* Revert "Revert "changes to clusteR""

This reverts commit f1104a37b4.

* Revert "documentation changes"

This reverts commit 02c369d0414fdff492d90865c903bdade3174261.

* Gather facts

* Revert "Gather facts"

This reverts commit 67bfd54f6780818854b5e5d99db52afef89ac4f2.

* Revert "Revert "Gather facts""

This reverts commit 199c27c520bdfce1fc2dfa685dc953cb56381de2.

* Revert "Gather facts"

This reverts commit fc6d21418123d03af3cedd1903175277b1612856.

* Revert "Revert "documentation changes""

This reverts commit fffeb974104f2da047435021e0dce94311e945b1.

* bug fix
This commit is contained in:
Chris Archibald 2019-03-20 08:49:18 -07:00 committed by John R Barker
parent f329f35efd
commit 7afdc6c582

View file

@ -37,11 +37,11 @@ options:
peer_cluster:
description:
- Specifies name of the peer Cluster.
- If peer Cluster is not given, it considers local Cluster.
- Required for creating the vserver peer relationship with a remote cluster
dest_hostname:
description:
- Destination hostname or IP address.
- Required for creating the vserver peer relationship
- Required for creating the vserver peer relationship with a remote cluster
dest_username:
description:
- Destination username.
@ -111,9 +111,6 @@ class NetAppONTAPVserverPeer(object):
self.module = AnsibleModule(
argument_spec=self.argument_spec,
required_if=[
('state', 'present', ['dest_hostname'])
],
supports_check_mode=True
)
@ -207,6 +204,8 @@ class NetAppONTAPVserverPeer(object):
"""
if self.parameters.get('applications') is None:
self.module.fail_json(msg='applications parameter is missing')
if self.parameters.get('peer_cluster') is not None and self.parameters.get('dest_hostname') is None:
self.module.fail_json(msg='dest_hostname is required for peering a vserver in remote cluster')
if self.parameters.get('peer_cluster') is None:
self.parameters['peer_cluster'] = self.get_peer_cluster_name()
vserver_peer_create = netapp_utils.zapi.NaElement.create_node_with_children(
@ -235,7 +234,9 @@ class NetAppONTAPVserverPeer(object):
'vserver-peer-accept', **{'peer-vserver': self.parameters['vserver'],
'vserver': self.parameters['peer_vserver']})
try:
self.dest_server.invoke_successfully(vserver_peer_accept, enable_tunneling=True)
# accept only if the peer relationship is on a remote cluster
if self.parameters.get('dest_hostname') is not None:
self.dest_server.invoke_successfully(vserver_peer_accept, enable_tunneling=True)
except netapp_utils.zapi.NaApiError as error:
self.module.fail_json(msg='Error accepting vserver peer %s: %s'
% (self.parameters['peer_vserver'], to_native(error)),