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
|
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``.
|
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
|
Plugins
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,16 @@ options:
|
||||||
description:
|
description:
|
||||||
- Whether the specified cluster peer should exist or not.
|
- Whether the specified cluster peer should exist or not.
|
||||||
default: present
|
default: present
|
||||||
source_intercluster_lif:
|
source_intercluster_lifs:
|
||||||
description:
|
description:
|
||||||
- Intercluster address of the source cluster.
|
- Intercluster addresses of the source cluster.
|
||||||
- Used as peer-address in destination cluster.
|
- Used as peer-addresses in destination cluster.
|
||||||
dest_intercluster_lif:
|
version_added: "2.8"
|
||||||
|
dest_intercluster_lifs:
|
||||||
description:
|
description:
|
||||||
- Intercluster address of the destination cluster.
|
- Intercluster addresses of the destination cluster.
|
||||||
- Used as peer-address in source cluster.
|
- Used as peer-addresses in source cluster.
|
||||||
|
version_added: "2.8"
|
||||||
passphrase:
|
passphrase:
|
||||||
description:
|
description:
|
||||||
- The arbitrary passphrase that matches the one given to the peer cluster.
|
- The arbitrary passphrase that matches the one given to the peer cluster.
|
||||||
|
@ -57,16 +59,18 @@ version_added: "2.7"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
|
|
||||||
- name: Create cluster peer
|
- name: Create cluster peer
|
||||||
na_ontap_cluster_peer:
|
na_ontap_cluster_peer:
|
||||||
state: present
|
state: present
|
||||||
source_intercluster_lif: 1.2.3.4
|
source_intercluster_lifs: 1.2.3.4,1.2.3.5
|
||||||
dest_intercluster_lif: 5.6.7.8
|
dest_intercluster_lifs: 1.2.3.6,1.2.3.7
|
||||||
passphrase: XXXX
|
passphrase: XXXX
|
||||||
hostname: "{{ netapp_hostname }}"
|
hostname: "{{ netapp_hostname }}"
|
||||||
username: "{{ netapp_username }}"
|
username: "{{ netapp_username }}"
|
||||||
password: "{{ netapp_password }}"
|
password: "{{ netapp_password }}"
|
||||||
dest_hostname: "{{ dest_netapp_hostname }}"
|
dest_hostname: "{{ dest_netapp_hostname }}"
|
||||||
|
|
||||||
- name: Delete cluster peer
|
- name: Delete cluster peer
|
||||||
na_ontap_cluster_peer:
|
na_ontap_cluster_peer:
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -100,8 +104,8 @@ class NetAppONTAPClusterPeer(object):
|
||||||
self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
|
self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
|
||||||
self.argument_spec.update(dict(
|
self.argument_spec.update(dict(
|
||||||
state=dict(required=False, type='str', choices=['present', 'absent'], default='present'),
|
state=dict(required=False, type='str', choices=['present', 'absent'], default='present'),
|
||||||
source_intercluster_lif=dict(required=False, type='str'),
|
source_intercluster_lifs=dict(required=False, type='list'),
|
||||||
dest_intercluster_lif=dict(required=False, type='str'),
|
dest_intercluster_lifs=dict(required=False, type='list'),
|
||||||
passphrase=dict(required=False, type='str', no_log=True),
|
passphrase=dict(required=False, type='str', no_log=True),
|
||||||
dest_hostname=dict(required=True, type='str'),
|
dest_hostname=dict(required=True, type='str'),
|
||||||
dest_username=dict(required=False, type='str'),
|
dest_username=dict(required=False, type='str'),
|
||||||
|
@ -112,7 +116,7 @@ class NetAppONTAPClusterPeer(object):
|
||||||
|
|
||||||
self.module = AnsibleModule(
|
self.module = AnsibleModule(
|
||||||
argument_spec=self.argument_spec,
|
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'])],
|
required_if=[('state', 'absent', ['source_cluster_name', 'dest_cluster_name'])],
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -131,6 +135,8 @@ class NetAppONTAPClusterPeer(object):
|
||||||
if self.parameters.get('dest_password'):
|
if self.parameters.get('dest_password'):
|
||||||
self.module.params['password'] = self.parameters['dest_password']
|
self.module.params['password'] = self.parameters['dest_password']
|
||||||
self.dest_server = netapp_utils.setup_na_ontap_zapi(module=self.module)
|
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):
|
def cluster_peer_get_iter(self, cluster):
|
||||||
"""
|
"""
|
||||||
|
@ -142,12 +148,13 @@ class NetAppONTAPClusterPeer(object):
|
||||||
query = netapp_utils.zapi.NaElement('query')
|
query = netapp_utils.zapi.NaElement('query')
|
||||||
cluster_peer_info = netapp_utils.zapi.NaElement('cluster-peer-info')
|
cluster_peer_info = netapp_utils.zapi.NaElement('cluster-peer-info')
|
||||||
if cluster == 'source':
|
if cluster == 'source':
|
||||||
peer_lif, peer_cluster = 'dest_intercluster_lif', 'dest_cluster_name'
|
peer_lifs, peer_cluster = 'dest_intercluster_lifs', 'dest_cluster_name'
|
||||||
else:
|
else:
|
||||||
peer_lif, peer_cluster = 'source_intercluster_lif', 'source_cluster_name'
|
peer_lifs, peer_cluster = 'source_intercluster_lifs', 'source_cluster_name'
|
||||||
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
if self.parameters.get(peer_lifs):
|
||||||
if self.parameters.get(peer_lif):
|
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
||||||
peer_addresses.add_new_child('remote-inet-address', self.parameters[peer_lif])
|
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)
|
cluster_peer_info.add_child_elem(peer_addresses)
|
||||||
if self.parameters.get(peer_cluster):
|
if self.parameters.get(peer_cluster):
|
||||||
cluster_peer_info.add_new_child('cluster-name', self.parameters[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):
|
def cluster_peer_create(self, cluster):
|
||||||
"""
|
"""
|
||||||
Create a cluster peer on source or destination
|
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)
|
:param cluster: type of cluster (source or destination)
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
@ -214,10 +221,11 @@ class NetAppONTAPClusterPeer(object):
|
||||||
'cluster-peer-create', **{'passphrase': self.parameters['passphrase']})
|
'cluster-peer-create', **{'passphrase': self.parameters['passphrase']})
|
||||||
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
peer_addresses = netapp_utils.zapi.NaElement('peer-addresses')
|
||||||
if cluster == 'source':
|
if cluster == 'source':
|
||||||
server, peer_address = self.server, self.parameters['dest_intercluster_lif']
|
server, peer_address = self.server, self.parameters['dest_intercluster_lifs']
|
||||||
else:
|
else:
|
||||||
server, peer_address = self.dest_server, self.parameters['source_intercluster_lif']
|
server, peer_address = self.dest_server, self.parameters['source_intercluster_lifs']
|
||||||
peer_addresses.add_new_child('remote-inet-address', peer_address)
|
for each in peer_address:
|
||||||
|
peer_addresses.add_new_child('remote-inet-address', each)
|
||||||
cluster_peer_create.add_child_elem(peer_addresses)
|
cluster_peer_create.add_child_elem(peer_addresses)
|
||||||
try:
|
try:
|
||||||
server.invoke_successfully(cluster_peer_create, enable_tunneling=True)
|
server.invoke_successfully(cluster_peer_create, enable_tunneling=True)
|
||||||
|
@ -231,6 +239,9 @@ class NetAppONTAPClusterPeer(object):
|
||||||
Apply action to cluster peer
|
Apply action to cluster peer
|
||||||
:return: None
|
: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')
|
source = self.cluster_peer_get('source')
|
||||||
destination = self.cluster_peer_get('destination')
|
destination = self.cluster_peer_get('destination')
|
||||||
source_action = self.na_helper.get_cd_action(source, self.parameters)
|
source_action = self.na_helper.get_cd_action(source, self.parameters)
|
||||||
|
|
Loading…
Reference in a new issue