Initial commit

This commit is contained in:
Ansible Core Team 2020-03-09 09:11:07 +00:00
commit aebc1b03fd
4861 changed files with 812621 additions and 0 deletions

View file

@ -0,0 +1,161 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or
# https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_domain
short_description: Manages domains on IBM Spectrum Accelerate Family storage systems
description:
- "This module can be used to add domains to or removes them from IBM Spectrum Accelerate Family storage systems."
options:
domain:
description:
- Name of the domain to be managed.
required: true
state:
description:
- The desired state of the domain.
required: true
default: "present"
choices: [ "present", "absent" ]
ldap_id:
description:
- ldap id to add to the domain.
required: false
size:
description:
- Size of the domain.
required: false
hard_capacity:
description:
- Hard capacity of the domain.
required: false
soft_capacity:
description:
- Soft capacity of the domain.
required: false
max_cgs:
description:
- Number of max cgs.
required: false
max_dms:
description:
- Number of max dms.
required: false
max_mirrors:
description:
- Number of max_mirrors.
required: false
max_pools:
description:
- Number of max_pools.
required: false
max_volumes:
description:
- Number of max_volumes.
required: false
perf_class:
description:
- Add the domain to a performance class.
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Define new domain.
ibm_sa_domain:
domain: domain_name
size: domain_size
state: present
username: admin
password: secret
endpoints: hostdev-system
- name: Delete domain.
ibm_sa_domain:
domain: domain_name
state: absent
username: admin
password: secret
endpoints: hostdev-system
'''
RETURN = '''
msg:
description: module return status.
returned: as needed
type: str
sample: "domain 'domain_name' created successfully."
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import execute_pyxcli_command, \
connect_ssl, spectrum_accelerate_spec, is_pyxcli_installed
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
domain=dict(required=True),
size=dict(),
max_dms=dict(),
max_cgs=dict(),
ldap_id=dict(),
max_mirrors=dict(),
max_pools=dict(),
max_volumes=dict(),
perf_class=dict(),
hard_capacity=dict(),
soft_capacity=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
domain = xcli_client.cmd.domain_list(
domain=module.params['domain']).as_single_element
state = module.params['state']
state_changed = False
msg = 'Domain \'{0}\''.format(module.params['domain'])
if state == 'present' and not domain:
state_changed = execute_pyxcli_command(
module, 'domain_create', xcli_client)
msg += " created successfully."
elif state == 'absent' and domain:
state_changed = execute_pyxcli_command(
module, 'domain_delete', xcli_client)
msg += " deleted successfully."
else:
msg += " state unchanged."
module.exit_json(changed=state_changed, msg=msg)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,123 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_host
short_description: Adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems.
description:
- "This module adds hosts to or removes them from IBM Spectrum Accelerate Family storage systems."
options:
host:
description:
- Host name.
required: true
state:
description:
- Host state.
required: true
default: "present"
choices: [ "present", "absent" ]
cluster:
description:
- The name of the cluster to include the host.
required: false
domain:
description:
- The domains the cluster will be attached to.
To include more than one domain,
separate domain names with commas.
To include all existing domains, use an asterisk ("*").
required: false
iscsi_chap_name:
description:
- The host's CHAP name identifier
required: false
iscsi_chap_secret:
description:
- The password of the initiator used to
authenticate to the system when CHAP is enable
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Define new host.
ibm_sa_host:
host: host_name
state: present
username: admin
password: secret
endpoints: hostdev-system
- name: Delete host.
ibm_sa_host:
host: host_name
state: absent
username: admin
password: secret
endpoints: hostdev-system
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import execute_pyxcli_command, \
connect_ssl, spectrum_accelerate_spec, is_pyxcli_installed
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
host=dict(required=True),
cluster=dict(),
domain=dict(),
iscsi_chap_name=dict(),
iscsi_chap_secret=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
host = xcli_client.cmd.host_list(
host=module.params['host']).as_single_element
state = module.params['state']
state_changed = False
if state == 'present' and not host:
state_changed = execute_pyxcli_command(
module, 'host_define', xcli_client)
elif state == 'absent' and host:
state_changed = execute_pyxcli_command(
module, 'host_delete', xcli_client)
module.exit_json(changed=state_changed)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,132 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_host_ports
short_description: Add host ports on IBM Spectrum Accelerate Family storage systems.
description:
- "This module adds ports to or removes them from the hosts
on IBM Spectrum Accelerate Family storage systems."
options:
host:
description:
- Host name.
required: true
state:
description:
- Host ports state.
required: true
default: "present"
choices: [ "present", "absent" ]
iscsi_name:
description:
- iSCSI initiator name.
required: false
fcaddress:
description:
- Fiber channel address.
required: false
num_of_visible_targets:
description:
- Number of visible targets.
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Add ports for host.
ibm_sa_host_ports:
host: test_host
iscsi_name: iqn.1994-05.com***
username: admin
password: secret
endpoints: hostdev-system
state: present
- name: Remove ports for host.
ibm_sa_host_ports:
host: test_host
iscsi_name: iqn.1994-05.com***
username: admin
password: secret
endpoints: hostdev-system
state: absent
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import (execute_pyxcli_command, connect_ssl,
spectrum_accelerate_spec, is_pyxcli_installed)
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
host=dict(required=True),
iscsi_name=dict(),
fcaddress=dict(),
num_of_visible_targets=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
# required args
ports = []
try:
ports = xcli_client.cmd.host_list_ports(
host=module.params.get('host')).as_list
except Exception:
pass
state = module.params['state']
port_exists = False
ports = [port.get('port_name') for port in ports]
fc_ports = (module.params.get('fcaddress')
if module.params.get('fcaddress') else [])
iscsi_ports = (module.params.get('iscsi_name')
if module.params.get('iscsi_name') else [])
for port in ports:
if port in iscsi_ports or port in fc_ports:
port_exists = True
break
state_changed = False
if state == 'present' and not port_exists:
state_changed = execute_pyxcli_command(
module, 'host_add_port', xcli_client)
if state == 'absent' and port_exists:
state_changed = execute_pyxcli_command(
module, 'host_remove_port', xcli_client)
module.exit_json(changed=state_changed)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,120 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_pool
short_description: Handles pools on IBM Spectrum Accelerate Family storage systems.
description:
- "This module creates or deletes pools to be used on IBM Spectrum Accelerate Family storage systems"
options:
pool:
description:
- Pool name.
required: true
state:
description:
- Pool state.
required: true
default: "present"
choices: [ "present", "absent" ]
size:
description:
- Pool size in GB
required: false
snapshot_size:
description:
- Pool snapshot size in GB
required: false
domain:
description:
- Adds the pool to the specified domain.
required: false
perf_class:
description:
- Assigns a perf_class to the pool.
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Create new pool.
ibm_sa_pool:
name: pool_name
size: 300
state: present
username: admin
password: secret
endpoints: hostdev-system
- name: Delete pool.
ibm_sa_pool:
name: pool_name
state: absent
username: admin
password: secret
endpoints: hostdev-system
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import execute_pyxcli_command, \
connect_ssl, spectrum_accelerate_spec, is_pyxcli_installed
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
pool=dict(required=True),
size=dict(),
snapshot_size=dict(),
domain=dict(),
perf_class=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
pool = xcli_client.cmd.pool_list(
pool=module.params['pool']).as_single_element
state = module.params['state']
state_changed = False
if state == 'present' and not pool:
state_changed = execute_pyxcli_command(
module, 'pool_create', xcli_client)
if state == 'absent' and pool:
state_changed = execute_pyxcli_command(
module, 'pool_delete', xcli_client)
module.exit_json(changed=state_changed)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,112 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_vol
short_description: Handle volumes on IBM Spectrum Accelerate Family storage systems.
description:
- "This module creates or deletes volumes to be used on IBM Spectrum Accelerate Family storage systems."
options:
vol:
description:
- Volume name.
required: true
pool:
description:
- Volume pool.
required: false
state:
description:
- Volume state.
required: true
default: "present"
choices: [ "present", "absent" ]
size:
description:
- Volume size.
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Create a new volume.
ibm_sa_vol:
vol: volume_name
pool: pool_name
size: 17
state: present
username: admin
password: secret
endpoints: hostdev-system
- name: Delete an existing volume.
ibm_sa_vol:
vol: volume_name
state: absent
username: admin
password: secret
endpoints: hostdev-system
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import execute_pyxcli_command, \
connect_ssl, spectrum_accelerate_spec, is_pyxcli_installed
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
vol=dict(required=True),
pool=dict(),
size=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
# required args
volume = xcli_client.cmd.vol_list(
vol=module.params.get('vol')).as_single_element
state = module.params['state']
state_changed = False
if state == 'present' and not volume:
state_changed = execute_pyxcli_command(
module, 'vol_create', xcli_client)
elif state == 'absent' and volume:
state_changed = execute_pyxcli_command(
module, 'vol_delete', xcli_client)
module.exit_json(changed=state_changed)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,140 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 IBM CORPORATION
# Author(s): Tzur Eliyahu <tzure@il.ibm.com>
#
# GNU General Public License v3.0+ (see COPYING or
# https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'metadata_version': '1.1'}
DOCUMENTATION = '''
---
module: ibm_sa_vol_map
short_description: Handles volume mapping on IBM Spectrum Accelerate Family storage systems.
description:
- "This module maps volumes to or unmaps them from the hosts on
IBM Spectrum Accelerate Family storage systems."
options:
vol:
description:
- Volume name.
required: true
state:
default: "present"
choices: [ "present", "absent" ]
description:
- When the state is present the volume is mapped.
When the state is absent, the volume is meant to be unmapped.
required: true
cluster:
description:
- Maps the volume to a cluster.
required: false
host:
description:
- Maps the volume to a host.
required: false
lun:
description:
- The LUN identifier.
required: false
override:
description:
- Overrides the existing volume mapping.
required: false
extends_documentation_fragment:
- community.general.ibm_storage
author:
- Tzur Eliyahu (@tzure)
'''
EXAMPLES = '''
- name: Map volume to host.
ibm_sa_vol_map:
vol: volume_name
lun: 1
host: host_name
username: admin
password: secret
endpoints: hostdev-system
state: present
- name: Map volume to cluster.
ibm_sa_vol_map:
vol: volume_name
lun: 1
cluster: cluster_name
username: admin
password: secret
endpoints: hostdev-system
state: present
- name: Unmap volume.
ibm_sa_vol_map:
host: host_name
username: admin
password: secret
endpoints: hostdev-system
state: absent
'''
RETURN = '''
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ibm_sa_utils import (execute_pyxcli_command,
connect_ssl, spectrum_accelerate_spec, is_pyxcli_installed)
def main():
argument_spec = spectrum_accelerate_spec()
argument_spec.update(
dict(
state=dict(default='present', choices=['present', 'absent']),
vol=dict(required=True),
lun=dict(),
cluster=dict(),
host=dict(),
override=dict()
)
)
module = AnsibleModule(argument_spec)
is_pyxcli_installed(module)
xcli_client = connect_ssl(module)
# required args
mapping = False
try:
mapped_hosts = xcli_client.cmd.vol_mapping_list(
vol=module.params.get('vol')).as_list
for host in mapped_hosts:
if host['host'] == module.params.get("host", ""):
mapping = True
except Exception:
pass
state = module.params['state']
state_changed = False
if state == 'present' and not mapping:
state_changed = execute_pyxcli_command(module, 'map_vol', xcli_client)
if state == 'absent' and mapping:
state_changed = execute_pyxcli_command(
module, 'unmap_vol', xcli_client)
module.exit_json(changed=state_changed)
if __name__ == '__main__':
main()