Debian Codegraph @

ansible_collections/community/general/plugins/modules/ibm_sa_pool.py

raw
1 #!/usr/bin/python
2
3 # Copyright (C) 2018 IBM CORPORATION
4 # Author(s): Tzur Eliyahu <[email protected]>
5 #
6 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
7 # SPDX-License-Identifier: GPL-3.0-or-later
8
9 from __future__ import annotations
10
11 DOCUMENTATION = r"""
12 module: ibm_sa_pool
13 short_description: Handles pools on IBM Spectrum Accelerate Family storage systems
14
15 description:
16 - This module creates or deletes pools to be used on IBM Spectrum Accelerate Family storage systems.
17 attributes:
18 check_mode:
19 support: none
20 diff_mode:
21 support: none
22
23 options:
24 pool:
25 description:
26 - Pool name.
27 required: true
28 type: str
29 state:
30 description:
31 - Pool state.
32 default: "present"
33 choices: ["present", "absent"]
34 type: str
35 size:
36 description:
37 - Pool size in GB.
38 type: str
39 snapshot_size:
40 description:
41 - Pool snapshot size in GB.
42 type: str
43 domain:
44 description:
45 - Adds the pool to the specified domain.
46 type: str
47 perf_class:
48 description:
49 - Assigns a perf_class to the pool.
50 type: str
51
52 extends_documentation_fragment:
53 - community.general._ibm_storage
54 - community.general._attributes
55
56 author:
57 - Tzur Eliyahu (@tzure)
58 """
59
60 EXAMPLES = r"""
61 - name: Create new pool.
62 community.general.ibm_sa_pool:
63 name: pool_name
64 size: 300
65 state: present
66 username: admin
67 password: secret
68 endpoints: hostdev-system
69
70 - name: Delete pool.
71 community.general.ibm_sa_pool:
72 name: pool_name
73 state: absent
74 username: admin
75 password: secret
76 endpoints: hostdev-system
77 """
78 RETURN = r"""
79 """
80
81 from ansible.module_utils.basic import AnsibleModule
82
83 from ansible_collections.community.general.plugins.module_utils._ibm_sa_utils import (
84 connect_ssl,
85 execute_pyxcli_command,
86 is_pyxcli_installed,
87 spectrum_accelerate_spec,
88 )
89
90
91 def main():
92 argument_spec = spectrum_accelerate_spec()
93 argument_spec.update(
94 dict(
95 state=dict(default="present", choices=["present", "absent"]),
96 pool=dict(required=True),
97 size=dict(),
98 snapshot_size=dict(),
99 domain=dict(),
100 perf_class=dict(),
101 )
102 )
103
104 module = AnsibleModule(argument_spec)
105
106 is_pyxcli_installed(module)
107
108 xcli_client = connect_ssl(module)
109 pool = xcli_client.cmd.pool_list(pool=module.params["pool"]).as_single_element
110 state = module.params["state"]
111
112 state_changed = False
113 if state == "present" and not pool:
114 state_changed = execute_pyxcli_command(module, "pool_create", xcli_client)
115 if state == "absent" and pool:
116 state_changed = execute_pyxcli_command(module, "pool_delete", xcli_client)
117
118 module.exit_json(changed=state_changed)
119
120
121 if __name__ == "__main__":
122 main()