mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes for na_ontap_cluster_peer (#48329)
* Fixes for na_ontap_cluster_peer, incorporating review comments, version, etc.
This commit is contained in:
parent
655b27f571
commit
73348ae32d
2 changed files with 35 additions and 20 deletions
|
@ -114,6 +114,10 @@ Noteworthy module changes
|
|||
a return value called ``diff`` was returned of type ``list``. To enable proper diff output, this was changed to
|
||||
type ``dict``; the original ``list`` is returned as ``diff.differences``.
|
||||
|
||||
* The ``na_ontap_cluster_peer`` module has replaced ``source_intercluster_lif`` and ``dest_intercluster_lif`` string options with
|
||||
``source_intercluster_lifs`` and ``dest_intercluster_lifs`` list options
|
||||
|
||||
|
||||
Plugins
|
||||
=======
|
||||
|
||||
|
|
|
@ -23,14 +23,16 @@ options:
|
|||
description:
|
||||
- Whether the specified cluster peer should exist or not.
|
||||
default: present
|
||||
source_intercluster_lif:
|
||||
source_intercluster_lifs:
|
||||
description:
|
||||
- Intercluster address of the source cluster.
|
||||
- Used as peer-address in destination cluster.
|
||||
dest_intercluster_lif:
|
||||
- Intercluster addresses of the source cluster.
|
||||
- Used as peer-addresses in destination cluster.
|
||||
version_added: "2.8"
|
||||
dest_intercluster_lifs:
|
||||
description:
|
||||
- Intercluster address of the destination cluster.
|
||||
- Used as peer-address in source cluster.
|
||||
- Intercluster addresses of the destination cluster.
|
||||
- Used as peer-addresses in source cluster.
|
||||
version_added: "2.8"
|
||||
passphrase:
|
||||
description:
|
||||
- The arbitrary passphrase that matches the one given to the peer cluster.
|
||||
|
@ -57,16 +59,18 @@ version_added: "2.7"
|
|||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
|
||||
- name: Create cluster peer
|
||||
na_ontap_cluster_peer:
|
||||
state: present
|
||||
source_intercluster_lif: 1.2.3.4
|
||||
dest_intercluster_lif: 5.6.7.8
|
||||
source_intercluster_lifs: 1.2.3.4,1.2.3.5
|
||||
dest_intercluster_lifs: 1.2.3.6,1.2.3.7
|
||||
passphrase: XXXX
|
||||
hostname: "{{ netapp_hostname }}"
|
||||
username: "{{ netapp_username }}"
|
||||
password: "{{ netapp_password }}"
|
||||
dest_hostname: "{{ dest_netapp_hostname }}"
|
||||
|
||||
- name: Delete cluster peer
|
||||
na_ontap_cluster_peer:
|
||||
state: absent
|
||||
|
@ -100,8 +104,8 @@ class NetAppONTAPClusterPeer(object):
|
|||
self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
|
||||
self.argument_spec.update(dict(
|
||||
state=dict(required=False, type='str', choices=['present', 'absent'], default='present'),
|
||||
source_intercluster_lif=dict(required=False, type='str'),
|
||||
dest_intercluster_lif=dict(required=False, type='str'),
|
||||
source_intercluster_lifs=dict(required=False, type='list'),
|
||||
dest_intercluster_lifs=dict(required=False, type='list'),
|
||||
passphrase=dict(required=False, type='str', no_log=True),
|
||||
dest_hostname=dict(required=True, type='str'),
|
||||
dest_username=dict(required=False, type='str'),
|
||||
|
@ -112,7 +116,7 @@ class NetAppONTAPClusterPeer(object):
|
|||
|
||||
self.module = AnsibleModule(
|
||||
argument_spec=self.argument_spec,
|
||||
required_together=[['source_intercluster_lif', 'dest_intercluster_lif', 'passphrase']],
|
||||
required_together=[['source_intercluster_lifs', 'dest_intercluster_lifs', 'passphrase']],
|
||||
required_if=[('state', 'absent', ['source_cluster_name', 'dest_cluster_name'])],
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
@ -131,6 +135,8 @@ class NetAppONTAPClusterPeer(object):
|
|||
if self.parameters.get('dest_password'):
|
||||
self.module.params['password'] = self.parameters['dest_password']
|
||||
self.dest_server = netapp_utils.setup_na_ontap_zapi(module=self.module)
|
||||
# reset to source host connection for asup logs
|
||||
self.module.params['hostname'] = self.parameters['hostname']
|
||||
|
||||
def cluster_peer_get_iter(self, cluster):
|
||||
"""
|
||||
|
@ -142,12 +148,13 @@ class NetAppONTAPClusterPeer(object):
|
|||
query = netapp_utils.zapi.NaElement('query')
|
||||
cluster_peer_info = netapp_utils.zapi.NaElement('cluster-peer-info')
|
||||
if cluster == 'source':
|
||||
peer_lif, peer_cluster = 'dest_intercluster_lif', 'dest_cluster_name'
|
||||
peer_lifs, peer_cluster = 'dest_intercluster_lifs', 'dest_cluster_name'
|
||||
else:
|
||||
peer_lif, peer_cluster = 'source_intercluster_lif', 'source_cluster_name'
|
||||
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
||||
if self.parameters.get(peer_lif):
|
||||
peer_addresses.add_new_child('remote-inet-address', self.parameters[peer_lif])
|
||||
peer_lifs, peer_cluster = 'source_intercluster_lifs', 'source_cluster_name'
|
||||
if self.parameters.get(peer_lifs):
|
||||
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
||||
for peer in self.parameters.get(peer_lifs):
|
||||
peer_addresses.add_new_child('remote-inet-address', peer)
|
||||
cluster_peer_info.add_child_elem(peer_addresses)
|
||||
if self.parameters.get(peer_cluster):
|
||||
cluster_peer_info.add_new_child('cluster-name', self.parameters[peer_cluster])
|
||||
|
@ -206,7 +213,7 @@ class NetAppONTAPClusterPeer(object):
|
|||
def cluster_peer_create(self, cluster):
|
||||
"""
|
||||
Create a cluster peer on source or destination
|
||||
For source cluster, peer address = destination inter-cluster LIF and vice-versa
|
||||
For source cluster, peer addresses = destination inter-cluster LIFs and vice-versa
|
||||
:param cluster: type of cluster (source or destination)
|
||||
:return: None
|
||||
"""
|
||||
|
@ -214,10 +221,11 @@ class NetAppONTAPClusterPeer(object):
|
|||
'cluster-peer-create', **{'passphrase': self.parameters['passphrase']})
|
||||
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
||||
if cluster == 'source':
|
||||
server, peer_address = self.server, self.parameters['dest_intercluster_lif']
|
||||
server, peer_address = self.server, self.parameters['dest_intercluster_lifs']
|
||||
else:
|
||||
server, peer_address = self.dest_server, self.parameters['source_intercluster_lif']
|
||||
peer_addresses.add_new_child('remote-inet-address', peer_address)
|
||||
server, peer_address = self.dest_server, self.parameters['source_intercluster_lifs']
|
||||
for each in peer_address:
|
||||
peer_addresses.add_new_child('remote-inet-address', each)
|
||||
cluster_peer_create.add_child_elem(peer_addresses)
|
||||
try:
|
||||
server.invoke_successfully(cluster_peer_create, enable_tunneling=True)
|
||||
|
@ -231,6 +239,9 @@ class NetAppONTAPClusterPeer(object):
|
|||
Apply action to cluster peer
|
||||
:return: None
|
||||
"""
|
||||
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_cluster_peer", cserver)
|
||||
source = self.cluster_peer_get('source')
|
||||
destination = self.cluster_peer_get('destination')
|
||||
source_action = self.na_helper.get_cd_action(source, self.parameters)
|
||||
|
|
Loading…
Reference in a new issue