diff options
Diffstat (limited to 'ansible_collections/inspur/ispim/plugins')
130 files changed, 15571 insertions, 0 deletions
diff --git a/ansible_collections/inspur/ispim/plugins/doc_fragments/ism.py b/ansible_collections/inspur/ispim/plugins/doc_fragments/ism.py new file mode 100644 index 000000000..9e8dfc66e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/doc_fragments/ism.py @@ -0,0 +1,59 @@ +# -*- coding:utf-8 -*- + +# 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 + + +class ModuleDocFragment(object): + + # Standard files documentation fragment + DOCUMENTATION = r''' +options: + provider: + description: + - A dict object containing connection details. + type: dict + suboptions: + host: + description: + - Specifies the DNS host name or address for connecting to the remote + device over the specified transport. The value of host is used as + the destination address for the transport. + type: str + username: + description: + - Configures the username to use to authenticate the connection to + the remote device. If the value is not specified in the task, the value of environment + variable C(ANSIBLE_NET_USERNAME) will be used instead. + type: str + password: + description: + - Specifies the password to use to authenticate the connection to + the remote device. If the value is not specified in the task, the + value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead. + type: str + host: + description: + - Specifies the DNS host name or address for connecting to the remote + device over the specified transport. The value of host is used as + the destination address for the transport. + type: str + username: + description: + - Configures the username to use to authenticate the connection to + the remote device. If the value is not specified in the task, the value of environment + variable C(ANSIBLE_NET_USERNAME) will be used instead. + type: str + password: + description: + - Specifies the password to use to authenticate the connection to + the remote device. If the value is not specified in the task, the + value of environment variable C(ANSIBLE_NET_PASSWORD) will be used instead. + type: str +requirements: + - Python 3.7+ + - inspursmsdk +''' diff --git a/ansible_collections/inspur/ispim/plugins/module_utils/__init__.py b/ansible_collections/inspur/ispim/plugins/module_utils/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/module_utils/__init__.py diff --git a/ansible_collections/inspur/ispim/plugins/module_utils/ism.py b/ansible_collections/inspur/ispim/plugins/module_utils/ism.py new file mode 100644 index 000000000..e841d3c30 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/module_utils/ism.py @@ -0,0 +1,54 @@ +# -*- coding:utf-8 -*- +# Copyright (c), Inspur isib-group, 2020 + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + +try: + import ism + ism_temp = True +except ImportError: + ism_temp = False +from ansible.module_utils.basic import env_fallback +from ansible.module_utils.six import iteritems + +ism_provider_spec = { + 'host': dict(type='str'), + 'username': dict(type='str', fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])), + 'password': dict(type='str', fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True), +} +ism_argument_spec = { + 'provider': dict(type='dict', options=ism_provider_spec), +} +ism_top_spec = { + 'host': dict(type='str'), + 'username': dict(type='str'), + 'password': dict(type='str', no_log=True), +} +ism_argument_spec.update(ism_top_spec) + + +def load_params(module): + """load_params""" + provider = module.params.get('provider') or dict() + for key, value in iteritems(provider): + if key in ism_argument_spec: + if module.params.get(key) is None and value is not None: + module.params[key] = value + + +def get_connection(module): + """get_connection""" + load_params(module) + # result = dict() + # if module.check_mode: + # result['changed'] = True + # result['state'] = 'Success' + # result['message'] = module.params['subcommand'] + # else: + dict_param = module.params + if not ism_temp: + module.fail_json(msg='inspur_sdk must be installed to use this module') + result = ism.main(dict_param) + return result diff --git a/ansible_collections/inspur/ispim/plugins/modules/__init__.py b/ansible_collections/inspur/ispim/plugins/modules/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/__init__.py diff --git a/ansible_collections/inspur/ispim/plugins/modules/ad_group.py b/ansible_collections/inspur/ispim/plugins/modules/ad_group.py new file mode 100644 index 000000000..f99a8b1dc --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ad_group.py @@ -0,0 +1,158 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ad_group +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Manage active directory group information +description: + - Manage active directory group information on Inspur server. +notes: + - Does not support C(check_mode). +options: + state: + description: + - Whether the active directory group should exist or not, taking action if the state is different from what is stated. + choices: ['present', 'absent'] + default: present + type: str + name: + description: + - Group name. + type: str + required: true + domain: + description: + - Group domain. + type: str + pri: + description: + - Group privilege. + choices: ['administrator', 'user', 'operator', 'oem', 'none'] + type: str + kvm: + description: + - Kvm privilege. + choices: ['enable', 'disable'] + type: str + vm: + description: + - Vmedia privilege. + choices: ['enable', 'disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ad group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Add active directory group information" + inspur.ispim.ad_group: + state: "present" + name: "wbs" + domain: "inspur.com" + pri: "administrator" + kvm: "enable" + vm: "disable" + provider: "{{ ism }}" + + - name: "Set active directory group information" + inspur.ispim.ad_group: + state: "present" + name: "wbs" + pri: "user" + kvm: "disable" + provider: "{{ ism }}" + + - name: "Delete active directory group information" + inspur.ispim.ad_group: + state: "absent" + name: "wbs" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AD(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'editadgroup' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + state=dict(type='str', choices=['present', 'absent'], default='present'), + name=dict(type='str', required=True), + domain=dict(type='str', required=False), + pri=dict(type='str', required=False, choices=['administrator', 'user', 'operator', 'oem', 'none']), + kvm=dict(type='str', required=False, choices=['enable', 'disable']), + vm=dict(type='str', required=False, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + ad_obj = AD(argument_spec) + ad_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ad_group_info.py b/ansible_collections/inspur/ispim/plugins/modules/ad_group_info.py new file mode 100644 index 000000000..e159f7a4a --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ad_group_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ad_group_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get active directory group information +description: + - Get active directory group information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ad group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get active directory group information" + inspur.ispim.ad_group_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AD(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getadgroup' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ad_obj = AD(argument_spec) + ad_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ad_info.py b/ansible_collections/inspur/ispim/plugins/modules/ad_info.py new file mode 100644 index 000000000..fae82f514 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ad_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ad_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get active directory information +description: + - Get active directory information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ad test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get active directory information" + inspur.ispim.ad_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AD(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getad' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ad_obj = AD(argument_spec) + ad_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/adapter_info.py b/ansible_collections/inspur/ispim/plugins/modules/adapter_info.py new file mode 100644 index 000000000..5f603fca5 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/adapter_info.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: adapter_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get adapter information +description: + - Get adapter information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Adapter test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get adapter information" + inspur.ispim.adapter_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Adapter(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getnic' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + nic_result = self.results + if nic_result['State'] == "Success": + nic = nic_result['Message'][0] + sysadapter_len = nic.get('Maximum', 0) + idx = 0 + sortedRes = dict() + if sysadapter_len > 0: + nic = nic.get('NIC', []) + List = [] + while idx < sysadapter_len: + nic_info = nic[idx] + sysadapter_info = nic_info.get('Controller') + List.extend(sysadapter_info) + idx = idx + 1 + sortedRes["State"] = "Success" + sortedRes["Message"] = List + else: + sortedRes["State"] = "Failure" + sortedRes["Message"] = "cannot get information" + self.module.exit_json(**sortedRes) + else: + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + adapter_obj = Adapter(argument_spec) + adapter_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/add_ldisk.py b/ansible_collections/inspur/ispim/plugins/modules/add_ldisk.py new file mode 100644 index 000000000..9abe7bb22 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/add_ldisk.py @@ -0,0 +1,222 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: add_ldisk +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Create logical disk +description: + - Create logical disk on Inspur server. +notes: + - Does not support C(check_mode). +options: + info: + description: + - Show controller and physical drive info. + choices: ['show'] + type: str + ctrl_id: + description: + - Raid controller ID. + - Required when I(Info=None) and controller type is LSI or PMC. + type: int + level: + description: + - RAID Level, 0 - RAID0, 1 - RAID1, 5 - RAID5, 6 - RAID6, 10 - RAID10. + - Required when I(Info=None) and controller type is LSI or PMC. + choices: [0, 1, 5, 6, 10] + type: int + size: + description: + - Strip Size, 1 - 64k, 2 - 128k, 3 - 256k, 4 - 512k, 5 - 1024k. + - Required when I(Info=None) and controller type is LSI or PMC. + choices: [1, 2, 3, 4, 5] + type: int + access: + description: + - Access Policy, 1 - Read Write, 2 - Read Only, 3 - Blocked. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2, 3] + type: int + r: + description: + - Read Policy, 1 - Read Ahead, 2 - No Read Ahead. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2] + type: int + w: + description: + - Write Policy, 1 - Write Throgh, 2 - Write Back, 3 - Write caching ok if bad BBU. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2, 3] + type: int + io: + description: + - IO Policy, 1 - Direct IO, 2 - Cached IO. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2] + type: int + cache: + description: + - Drive Cache, 1 - Unchanged, 2 - Enabled,3 - Disabled. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2, 3] + type: int + init: + description: + - Init State, 1 - No Init, 2 - Quick Init, 3 - Full Init. + - Required when I(Info=None) and controller type is LSI. + choices: [1, 2, 3] + type: int + select: + description: + - Select Size, from 1 to 100. + - Required when I(Info=None) and controller type is LSI. + type: int + slot: + description: + - Slot Num,input multiple slotNumber like 0,1,2.... + - Required when I(Info=None) and controller type is LSI or PMC. + type: list + elements: int + accelerator: + description: + - Driver accelerator, 1 - 1h, 2 - 2h, 3 - 3h. + - Required when I(Info=None) and controller type is PMC. + choices: [1, 2, 3] + type: int + vname: + description: + - Virtual drive name. + - Required when I(Info=None) and controller type is PMC or server model is M7. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Add ldisk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Show pdisk information" + inspur.ispim.add_ldisk: + info: "show" + provider: "{{ ism }}" + + - name: "Add ldisk" + inspur.ispim.add_ldisk: + ctrl_id: 0 + level: 1 + size: 1 + access: 1 + r: 1 + w: 1 + io: 1 + cache: 1 + init: 2 + select: 10 + slot: 0,1 + provider: "{{ ism }}" + + - name: "Add PMC ldisk" + inspur.ispim.add_ldisk: + ctrl_id: 0 + level: 1 + size: 1 + accelerator: 1 + slot: 0,1 + vname: "test" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'addldisk' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + info=dict(type='str', required=False, choices=['show']), + ctrl_id=dict(type='int', required=False), + level=dict(type='int', required=False, choices=[0, 1, 5, 6, 10]), + size=dict(type='int', required=False, choices=[1, 2, 3, 4, 5]), + access=dict(type='int', required=False, choices=[1, 2, 3]), + r=dict(type='int', required=False, choices=[1, 2]), + w=dict(type='int', required=False, choices=[1, 2, 3]), + io=dict(type='int', required=False, choices=[1, 2]), + cache=dict(type='int', required=False, choices=[1, 2, 3]), + init=dict(type='int', required=False, choices=[1, 2, 3]), + select=dict(type='int', required=False), + slot=dict(type='list', elements='int', required=False), + accelerator=dict(type='int', required=False, choices=[1, 2, 3]), + vname=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/alert_policy_info.py b/ansible_collections/inspur/ispim/plugins/modules/alert_policy_info.py new file mode 100644 index 000000000..cae0ec859 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/alert_policy_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: alert_policy_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get alert policy +description: + - Get alert policy on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Alert test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get alert policy" + inspur.ispim.alert_policy_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getalertpolicy' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/audit_log_info.py b/ansible_collections/inspur/ispim/plugins/modules/audit_log_info.py new file mode 100644 index 000000000..c0b21ab7f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/audit_log_info.py @@ -0,0 +1,126 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: audit_log_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get BMC audit log information +description: + - Get BMC audit log information on Inspur server. +notes: + - Supports C(check_mode). +options: + log_time: + description: + - Get logs after the specified date, time should be YYYY-MM-DDTHH:MM+HH:MM, like 2019-06-27T12:30+08:00. + type: str + count: + description: + - Get the most recent log of a specified number. + type: int + audit_file: + description: + - Store logs to a file. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bmc audit log test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bmc audit log information" + inspur.ispim.audit_log_info: + log_time: "2020-06-01T12:30+08:00" + provider: "{{ ism }}" + + - name: "Get bmc audit log information" + inspur.ispim.audit_log_info: + count: 30 + provider: "{{ ism }}" + + - name: "Get bmc audit log information" + inspur.ispim.audit_log_info: + audit_file: "/home/wbs/wbs.log" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AuditLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getauditlog' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + log_time=dict(type='str', required=False), + count=dict(type='int', required=False), + audit_file=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + log_obj = AuditLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/auto_capture_info.py b/ansible_collections/inspur/ispim/plugins/modules/auto_capture_info.py new file mode 100644 index 000000000..1add6e7c1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/auto_capture_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: auto_capture_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get auto capture screen information +description: + - Get auto capture screen information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Screen test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get auto capture screen information" + inspur.ispim.auto_capture_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Screen(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getscreen' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + screen_obj = Screen(argument_spec) + screen_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/backplane_info.py b/ansible_collections/inspur/ispim/plugins/modules/backplane_info.py new file mode 100644 index 000000000..4b0711a32 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/backplane_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: backplane_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get disk backplane information +description: + - Get disk backplane information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Disk backplane test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get backplane information" + inspur.ispim.backplane_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Backplane(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getbackplane' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + back_obj = Backplane(argument_spec) + back_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/backup.py b/ansible_collections/inspur/ispim/plugins/modules/backup.py new file mode 100644 index 000000000..9584727a9 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/backup.py @@ -0,0 +1,119 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: backup +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Backup server settings +description: + - Backup server settings on Inspur server. +notes: + - Does not support C(check_mode). +options: + bak_file: + description: + - Backup file or bak folder. + required: true + type: str + item: + description: + - Export item. + - The values for M5 modules are 'all', 'network', 'service', 'ntp', 'snmptrap', 'dns', 'smtp', 'ad', 'ldap', 'user','bios'. + - The values for M6 modules are 'all', 'network', 'service', 'ntp', 'snmptrap', 'kvm', 'ipmi', 'authentication', 'syslog'. + - The values for M7 modules are 'all', 'network', 'service', 'syslog', 'ncsi'. + choices: ['all', 'network', 'service', 'ntp', 'snmptrap', 'dns', 'smtp', 'ad', 'ldap', 'user','bios', 'kvm', 'ipmi', 'authentication', 'syslog', 'ncsi'] + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Backup test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Backup server settings" + inspur.ispim.backup: + bak_file: "/home/wbs/" + item: "all" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Backup(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'backup' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + bak_file=dict(type='str', required=True), + item=dict(type='str', required=True, choices=['all', 'network', 'service', 'ntp', 'snmptrap', 'dns', 'smtp', 'ad', + 'ldap', 'user', 'bios', 'kvm', 'ipmi', 'authentication', 'syslog', 'ncsi']), + ) + argument_spec.update(ism_argument_spec) + backup_obj = Backup(argument_spec) + backup_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/bios_export.py b/ansible_collections/inspur/ispim/plugins/modules/bios_export.py new file mode 100644 index 000000000..e849c8c09 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/bios_export.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: bios_export +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Export BIOS config +description: + - Export BIOS config on Inspur server. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - Suffix is .json/.conf, FILEURI format,"/directory/filename". + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bios test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Export bios config" + inspur.ispim.bios_export: + file_url: "/home/wbs/bios.conf" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'exportbioscfg' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/bios_import.py b/ansible_collections/inspur/ispim/plugins/modules/bios_import.py new file mode 100644 index 000000000..6c90b61c3 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/bios_import.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: bios_import +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Import BIOS config +description: + - Import BIOS config on Inspur server. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - Suffix is .json/.conf, FILEURI format,"/directory/filename". + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bios test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Import bios config" + inspur.ispim.bios_import: + file_url: "/home/wbs/bios.conf" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'importbioscfg' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/bios_info.py b/ansible_collections/inspur/ispim/plugins/modules/bios_info.py new file mode 100644 index 000000000..079e0b15f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/bios_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: bios_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get BIOS setup +description: + - Get BIOS setup on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bios test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bios setup" + inspur.ispim.bios_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getbios' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/bmc_info.py b/ansible_collections/inspur/ispim/plugins/modules/bmc_info.py new file mode 100644 index 000000000..0f104f37d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/bmc_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: bmc_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get BMC information +description: + - Get BMC information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bmc info test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get BMC information" + inspur.ispim.bmc_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BMCInfo(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getbmcinfo' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + bmc_obj = BMCInfo(argument_spec) + bmc_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/boot_image_info.py b/ansible_collections/inspur/ispim/plugins/modules/boot_image_info.py new file mode 100644 index 000000000..b2e6c3360 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/boot_image_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: boot_image_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get bmc boot image information +description: + - Get bmc boot image information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Boot image test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bmc boot image information" + inspur.ispim.boot_image_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Image(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getbootimage' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + image_obj = Image(argument_spec) + image_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/boot_option_info.py b/ansible_collections/inspur/ispim/plugins/modules/boot_option_info.py new file mode 100644 index 000000000..9ca4dbfe7 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/boot_option_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: boot_option_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get BIOS boot options +description: + - Get BIOS boot options on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Boot test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bios boot option" + inspur.ispim.boot_option_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsysboot' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/clear_audit_log.py b/ansible_collections/inspur/ispim/plugins/modules/clear_audit_log.py new file mode 100644 index 000000000..3907635a1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/clear_audit_log.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: clear_audit_log +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Clear BMC audit log +description: + - Clear BMC audit log on Inspur server. +notes: + - Does not support C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Clear BMC audit log test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Clear BMC audit log " + inspur.ispim.clear_audit_log: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AuditLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'clearauditlog' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + log_obj = AuditLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/clear_event_log.py b/ansible_collections/inspur/ispim/plugins/modules/clear_event_log.py new file mode 100644 index 000000000..d971cc4c7 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/clear_event_log.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: clear_event_log +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Clear event log +description: + - Clear event log on Inspur server. +notes: + - Does not support C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Clear event log test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Clear event log" + inspur.ispim.clear_event_log: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class EventLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'cleareventlog' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + log_obj = EventLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/clear_system_log.py b/ansible_collections/inspur/ispim/plugins/modules/clear_system_log.py new file mode 100644 index 000000000..e1ed01a39 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/clear_system_log.py @@ -0,0 +1,115 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: clear_system_log +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Clear BMC system log +description: + - Clear BMC system log on Inspur server. +notes: + - Does not support C(check_mode). +options: + level: + description: + - Log level. + default: alert + choices: ['alert', 'critical', 'error', 'notice', 'warning', 'debug', 'emergency', 'info', 'all'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Clear BMC system log test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Clear BMC system log" + inspur.ispim.clear_system_log: + level: "alert" + provider: "{{ ism }}" + + - name: "Clear BMC system log" + inspur.ispim.clear_system_log: + level: "all" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SystemLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'clearsystemlog' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + level=dict(type='str', default='alert', choices=['alert', 'critical', 'error', 'notice', 'warning', 'debug', 'emergency', 'info', 'all']), + ) + argument_spec.update(ism_argument_spec) + log_obj = SystemLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/collect_blackbox.py b/ansible_collections/inspur/ispim/plugins/modules/collect_blackbox.py new file mode 100644 index 000000000..6f77e824b --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/collect_blackbox.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: collect_blackbox +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Collect blackbox log +description: + - Collect blackbox log on Inspur server. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - File download path. + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Collect blackbox test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Collect blackbox log" + inspur.ispim.collect_blackbox: + file_url: "/home/wbs/wbs.log" + provider: "{{ ism }}" + +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Blackbox(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'collectblackbox' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + log_obj = Blackbox(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/collect_log.py b/ansible_collections/inspur/ispim/plugins/modules/collect_log.py new file mode 100644 index 000000000..01cc53ac4 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/collect_log.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: collect_log +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Collect logs +description: + - Collect logs on Inspur server,it takes about 5 minutes. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - File download path or path with filename , e.g. filepath/filename.tar. + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Collect test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Collect logs" + inspur.ispim.collect_log: + file_url: "/home/wbs/test.tar" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Log(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'collect' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + log_obj = Log(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/connect_media_info.py b/ansible_collections/inspur/ispim/plugins/modules/connect_media_info.py new file mode 100644 index 000000000..ac11e124f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/connect_media_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: connect_media_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get remote images redirection information +description: + - Get remote images redirection information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Connect media test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get remote images redirection information" + inspur.ispim.connect_media_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Connect(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getconnectmedia' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + connect_obj = Connect(argument_spec) + connect_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/cpu_info.py b/ansible_collections/inspur/ispim/plugins/modules/cpu_info.py new file mode 100644 index 000000000..3f646e161 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/cpu_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: cpu_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get CPU information +description: + - Get CPU information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: CPU test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get cpu information" + inspur.ispim.cpu_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class CPU(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getcpu' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + cpu_obj = CPU(argument_spec) + cpu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/del_session.py b/ansible_collections/inspur/ispim/plugins/modules/del_session.py new file mode 100644 index 000000000..613f43389 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/del_session.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: del_session +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Delete session +description: + - Delete session on Inspur server. +notes: + - Does not support C(check_mode). +options: + sid: + description: + - Session Id , input "all" to delete all sessions. + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Delete session test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Delete session" + inspur.ispim.del_session: + sid: "223" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Session(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'delsession' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + sid=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + session_obj = Session(argument_spec) + session_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/dns_info.py b/ansible_collections/inspur/ispim/plugins/modules/dns_info.py new file mode 100644 index 000000000..a9cd52108 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/dns_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: dns_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get dns information +description: + - Get dns information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: DNS test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get dns information" + inspur.ispim.dns_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class DNS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getdns' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + dns_obj = DNS(argument_spec) + dns_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/download_auto_screenshot.py b/ansible_collections/inspur/ispim/plugins/modules/download_auto_screenshot.py new file mode 100644 index 000000000..adad8e2f8 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/download_auto_screenshot.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: download_auto_screenshot +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Download auto screenshots +description: + - Download auto screenshots on Inspur server. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - Screen capture file path. + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Screen test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Download auto screenshots" + inspur.ispim.download_auto_screenshot: + file_url: "/home/wbs/screen" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Screen(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'downscreen' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + screen_obj = Screen(argument_spec) + screen_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/download_manual_screenshot.py b/ansible_collections/inspur/ispim/plugins/modules/download_manual_screenshot.py new file mode 100644 index 000000000..9a23a2bc3 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/download_manual_screenshot.py @@ -0,0 +1,107 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: download_manual_screenshot +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Download manual screenshots +description: + - Download manual screenshots on Inspur server. +notes: + - Does not support C(check_mode). +options: + file_url: + description: + - Screen capture file path. + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Screen test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Download manual screenshots" + inspur.ispim.download_manual_screenshot: + file_url: "/home/wbs/screen" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Screen(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'downscreenmanual' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + file_url=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + screen_obj = Screen(argument_spec) + screen_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ad.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ad.py new file mode 100644 index 000000000..9fc96cef1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ad.py @@ -0,0 +1,163 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ad +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set active directory information +description: + - Set active directory information on Inspur server. +notes: + - Does not support C(check_mode). +options: + enable: + description: + - Active Directory Authentication Status. + choices: ['enable', 'disable'] + type: str + ssl_enable: + description: + - Active Directory SSL Status. + choices: ['enable', 'disable'] + type: str + name: + description: + - Secret Username. + type: str + code: + description: + - Secret Password. + type: str + timeout: + description: + - The Time Out configuration(15-300). + - Only the M5 model supports this parameter. + type: int + domain: + description: + - User Domain Name. + type: str + addr1: + description: + - Domain Controller Server Address1. + type: str + addr2: + description: + - Domain Controller Server Address2. + type: str + addr3: + description: + - Domain Controller Server Address3. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ad test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set active directory information" + inspur.ispim.edit_ad: + enable: "disable" + provider: "{{ ism }}" + + - name: "Set active directory information" + inspur.ispim.edit_ad: + enable: "enable" + name: "inspur" + code: "123456" + timeout: 120 + domain: "inspur.com" + addr1: "100.2.2.2" + addr2: "100.2.2.3" + addr3: "100.2.2.4" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class AD(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setad' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + enable=dict(type='str', required=False, choices=['enable', 'disable']), + ssl_enable=dict(type='str', required=False, choices=['enable', 'disable']), + name=dict(type='str', required=False), + code=dict(type='str', required=False), + timeout=dict(type='int', required=False), + domain=dict(type='str', required=False), + addr1=dict(type='str', required=False), + addr2=dict(type='str', required=False), + addr3=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + ad_obj = AD(argument_spec) + ad_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_alert_policy.py b/ansible_collections/inspur/ispim/plugins/modules/edit_alert_policy.py new file mode 100644 index 000000000..959af1261 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_alert_policy.py @@ -0,0 +1,155 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_alert_policy +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set alert policy +description: + - Set alert policy on Inspur server. +notes: + - Does not support C(check_mode). +options: + id: + description: + - Alert id. + - The values for M5 modules are 1,2,3. + - The values for M6 modules are 1,2,3,4. + choices: [1, 2, 3, 4] + required: true + type: int + status: + description: + - Alert policy status. + choices: ['enable', 'disable'] + type: str + type: + description: + - Alert Type. + - Only the M5 model supports this parameter. + choices: ['snmp', 'email', 'snmpdomain'] + type: str + destination: + description: + - Alert destination,when type is snmp,fill in IP; + - when type is email,fill in user name; + - when type is snmpdomain,fill in domain. + type: str + channel: + description: + - LAN Channel. + - Only the M5 model supports this parameter. + choices: ['shared', 'dedicated'] + type: str + trap_port: + description: + - SNMP trap port(1-65535). + - Only the M6 model supports this parameter. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Alert policy test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set alert policy" + inspur.ispim.edit_alert_policy: + id: 1 + status: "enable" + type: "snmp" + destination: "100.2.2.2" + channel: "shared" + provider: "{{ ism }}" + + - name: "Set alert policy" + inspur.ispim.edit_alert_policy: + id: 1 + status: "disable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setalertpolicy' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + id=dict(type='int', required=True, choices=[1, 2, 3, 4]), + status=dict(type='str', required=False, choices=['enable', 'disable']), + type=dict(type='str', required=False, choices=['snmp', 'email', 'snmpdomain']), + destination=dict(type='str', required=False), + channel=dict(type='str', required=False, choices=['shared', 'dedicated']), + trap_port=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_auto_capture.py b/ansible_collections/inspur/ispim/plugins/modules/edit_auto_capture.py new file mode 100644 index 000000000..3f17b977b --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_auto_capture.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_auto_capture +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set auto capture screen +description: + - Set auto capture screen on Inspur server. +notes: + - Does not support C(check_mode). +options: + status: + description: + - Capture status. + choices: ['enable', 'disable'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Screen test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set auto capture screen" + inspur.ispim.edit_auto_capture: + status: "enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Screen(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setscreen' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + status=dict(type='str', required=True, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + screen_obj = Screen(argument_spec) + screen_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_bios.py b/ansible_collections/inspur/ispim/plugins/modules/edit_bios.py new file mode 100644 index 000000000..d1175644f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_bios.py @@ -0,0 +1,128 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_bios +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set BIOS setup attributes +description: + - Set BIOS setup attributes on Inspur server. +notes: + - Does not support C(check_mode). +options: + attribute: + description: + - BIOS setup option. + - Required when I(file_url=None). + type: str + value: + description: + - BIOS setup option value. + - Required when I(file_url=None). + type: str + file_url: + description: + - BIOS option file.attribute must be used with value, + - Mutually exclusive with fileurl format,"/directory/filename". + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bios test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set bios setup" + inspur.ispim.edit_bios: + attribute: "VMX" + value: "Disable" + provider: "{{ ism }}" + + - name: "Set bios setup" + inspur.ispim.edit_bios: + attribute: "VMX" + value: "Enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setbios' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + attribute=dict(type='str', required=False), + value=dict(type='str', required=False), + file_url=dict(type='str', required=False) + ) + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_boot_image.py b/ansible_collections/inspur/ispim/plugins/modules/edit_boot_image.py new file mode 100644 index 000000000..084cff5f1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_boot_image.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_boot_image +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set bmc boot image +description: + - Set bmc boot image on Inspur server. +notes: + - Does not support C(check_mode). +options: + image: + description: + - BMC boot image. 0-Higher firmware version;1-Image 1;2-Image 2;3-Lower firmware version;4-Latest updated firmware;5-Not latest updated firmware. + choices: [0, 1, 2, 3, 4, 5] + type: int + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Boot image test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set bmc boot image" + inspur.ispim.edit_boot_image: + image: 2 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Image(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setbootimage' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + image=dict(type='int', required=True, choices=[0, 1, 2, 3, 4, 5]), + ) + argument_spec.update(ism_argument_spec) + image_obj = Image(argument_spec) + image_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_boot_option.py b/ansible_collections/inspur/ispim/plugins/modules/edit_boot_option.py new file mode 100644 index 000000000..a2696d327 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_boot_option.py @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_boot_option +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set BIOS boot options +description: + - Set BIOS boot options on Inspur server. +notes: + - Does not support C(check_mode). +options: + device: + description: + - Boot device. + choices: ['none', 'HDD', 'PXE', 'CD', 'BIOSSETUP'] + type: str + effective: + description: + - Effective, once or continuous. + choices: ['Once', 'Continuous'] + type: str + mode: + description: + - Boot type. + choices: ['Legacy', 'UEFI'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Boot test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set bios boot option" + inspur.ispim.edit_boot_option: + device: "PXE" + effective: "Once" + mode: "Legacy" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class BIOS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsysboot' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + device=dict(type='str', required=False, choices=['none', 'HDD', 'PXE', 'CD', 'BIOSSETUP']), + effective=dict(type='str', required=False, choices=['Once', 'Continuous']), + mode=dict(type='str', required=False, choices=['Legacy', 'UEFI']) + ) + argument_spec.update(ism_argument_spec) + bios_obj = BIOS(argument_spec) + bios_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_connect_media.py b/ansible_collections/inspur/ispim/plugins/modules/edit_connect_media.py new file mode 100644 index 000000000..78606881a --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_connect_media.py @@ -0,0 +1,126 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_connect_media +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Start/Stop virtual media Image +description: + - Start/Stop virtual media Image on Inspur server. +notes: + - Does not support C(check_mode). +options: + image_type: + description: + - Virtual media type. + - Only the M5 model supports this parameter. + choices: ['CD', 'FD', 'HD'] + type: str + required: true + op_type: + description: + - Start or stop media. + choices: ['start', 'stop'] + type: str + required: true + image_name: + description: + - Image name. + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Connect media test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set remote image redirection" + inspur.ispim.edit_connect_media: + image_type: "CD" + op_type: "start" + image_name: "aa.iso" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Connect(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setconnectmedia' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + image_type=dict(type='str', required=True, choices=['CD', 'FD', 'HD']), + op_type=dict(type='str', required=True, choices=['start', 'stop']), + image_name=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + connect_obj = Connect(argument_spec) + connect_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_dns.py b/ansible_collections/inspur/ispim/plugins/modules/edit_dns.py new file mode 100644 index 000000000..c8b481e78 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_dns.py @@ -0,0 +1,231 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_dns +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set dns information +description: + - Set dns information on Inspur server. +notes: + - Does not support C(check_mode). +options: + dns_status: + description: + - DNS status. + choices: ['enable', 'disable'] + type: str + host_cfg: + description: + - Host Settings. + choices: ['manual', 'auto'] + type: str + host_name: + description: + - Host Name. + - Required when I(host_cfg=manual). + type: str + domain_manual: + description: + - Domain Settings. + choices: ['manual', 'auto'] + type: str + domain_iface: + description: + - Network Interface,input like 'eth0_v4', 'eth0_v6', 'eth1_v4', 'eth1_v6', 'bond0_v4', 'bond0_v6'. + - Required when I(domain_manual=auto). + type: str + domain_name: + description: + - Domain Name. + - Required when I(domain_manual=manual). + type: str + dns_manual: + description: + - DNS Settings. + choices: ['manual', 'auto'] + type: str + dns_iface: + description: + - DNS Interface,input like 'eth0', 'eth1', 'bond0'. + - Required when I(dns_manual=auto). + type: str + dns_priority: + description: + - IP Priority. + - Required when I(dns_manual=auto). + choices: ['4', '6'] + type: str + dns_server1: + description: + - DNS Server1 IPv4 or IPv6 address. + - Required when I(dns_manual=manual). + type: str + dns_server2: + description: + - DNS Server2 IPv4 or IPv6 address. + - Required when I(dns_manual=manual). + type: str + dns_server3: + description: + - DNS Server3 IPv4 or IPv6 address. + - Required when I(dns_manual=manual). + type: str + register_status1: + description: + - BMC register status 1. + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + registration_method1: + description: + - Registration method 1. + - Only the M6 model supports this parameter. + - Required when I(register_status1=enable). + choices: ['nsupdate', 'dhcp', 'hostname'] + type: str + register_status2: + description: + - BMC register status 2. + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + registration_method2: + description: + - Registration method 2. + - Only the M6 model supports this parameter. + - Required when I(register_status2=enable). + choices: ['nsupdate', 'dhcp', 'hostname'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: DNS test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set dns information" + inspur.ispim.edit_dns: + dns_status: "disable" + provider: "{{ ism }}" + + - name: "Set dns information" + inspur.ispim.edit_dns: + dns_status: "enable" + host_cfg: "manual" + host_name: "123456789" + domain_manual: "auto" + domain_iface: "eth0_v4" + dns_manual: "manual" + dns_server1: "100.2.2.2" + dns_server2: "100.2.2.3" + dns_server3: "100.2.2.4" + provider: "{{ ism }}" + + - name: "Set dns information" + inspur.ispim.edit_dns: + dns_status: "enable" + host_cfg: "manual" + host_name: "123456789" + domain_manual: "manual" + domain_name: "inspur.com" + dns_manual: "auto" + dns_iface: "eth0" + dns_priority: "4" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class DNS(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setdns' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + dns_status=dict(type='str', required=False, choices=['enable', 'disable']), + host_cfg=dict(type='str', required=False, choices=['manual', 'auto']), + host_name=dict(type='str', required=False), + domain_manual=dict(type='str', required=False, choices=['manual', 'auto']), + domain_iface=dict(type='str', required=False), + domain_name=dict(type='str', required=False), + dns_manual=dict(type='str', required=False, choices=['manual', 'auto']), + dns_iface=dict(type='str', required=False), + dns_priority=dict(type='str', required=False, choices=['4', '6']), + dns_server1=dict(type='str', required=False), + dns_server2=dict(type='str', required=False), + dns_server3=dict(type='str', required=False), + register_status1=dict(type='str', required=False, choices=['enable', 'disable']), + registration_method1=dict(type='str', required=False, choices=['nsupdate', 'dhcp', 'hostname']), + register_status2=dict(type='str', required=False, choices=['enable', 'disable']), + registration_method2=dict(type='str', required=False, choices=['nsupdate', 'dhcp', 'hostname']), + ) + argument_spec.update(ism_argument_spec) + dns_obj = DNS(argument_spec) + dns_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_event_log_policy.py b/ansible_collections/inspur/ispim/plugins/modules/edit_event_log_policy.py new file mode 100644 index 000000000..9ce03b456 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_event_log_policy.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_event_log_policy +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set event log policy +description: + - Set event log policy on Inspur server. +notes: + - Does not support C(check_mode). +options: + policy: + description: + - Event Log Policy. + choices: ['Linear', 'Circular'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Event log policy test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set event log policy" + inspur.ispim.edit_event_log_policy: + policy: "Linear" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Log(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'seteventlogpolicy' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + policy=dict(type='str', required=True, choices=['Linear', 'Circular']), + ) + argument_spec.update(ism_argument_spec) + log_obj = Log(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_fan.py b/ansible_collections/inspur/ispim/plugins/modules/edit_fan.py new file mode 100644 index 000000000..689992797 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_fan.py @@ -0,0 +1,126 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_fan +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set fan information +description: + - Set fan information on Inspur server. +notes: + - Does not support C(check_mode). +options: + mode: + description: + - Control mode, Manual or Automatic ,Manual must be used with fans_peed. + choices: ['Automatic', 'Manual'] + type: str + id: + description: + - fan id 255 is for all fans,0~n. + type: int + fan_speed: + description: + - fan speed (duty ratio), range in 1 - 100. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Fan test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set fan information" + inspur.ispim.edit_fan: + mode: "Automatic" + provider: "{{ ism }}" + + - name: "Set fan information" + inspur.ispim.edit_fan: + mode: "Manual" + id: 1 + fan_speed: 80 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Fan(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'fancontrol' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + mode=dict(type='str', required=False, choices=['Automatic', 'Manual']), + id=dict(type='int', required=False), + fan_speed=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + fan_obj = Fan(argument_spec) + fan_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_fru.py b/ansible_collections/inspur/ispim/plugins/modules/edit_fru.py new file mode 100644 index 000000000..ff8ccfd31 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_fru.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_fru +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set fru settings +description: + - Set fru settings on Inspur server. +notes: + - Does not support C(check_mode). +options: + attribute: + description: + - Attribute,CP is Chassis Part Number,CS is Chassis Serial,PM is Product Manufacturer, + - PPN is Product Part Number,PS is Product Serial,PN is Product Name,PV is Product Version, + - PAT is Product Asset Tag,BM is Board Mfg,BPN is Board Product Name,BS is Board Serial, + - BP is Board Part Number. + choices: ['CP', 'CS', 'PM', 'PPN', 'PS', 'PN', 'PV','PAT', 'BM', 'BPN', 'BS', 'BP'] + required: true + type: str + value: + description: + - Set the value of attribute. + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Fru test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set Fru" + inspur.ispim.edit_fru: + attribute: "CP" + value: "Inspur" + provider: "{{ ism }}" + +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class UID(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setfru' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + attribute=dict(type='str', required=True, choices=['CP', 'CS', 'PM', 'PPN', 'PS', 'PN', 'PV', 'PAT', 'BM', 'BPN', 'BS', 'BP']), + value=dict(type='str', required=True), + ) + argument_spec.update(ism_argument_spec) + uid_obj = UID(argument_spec) + uid_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ipv4.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ipv4.py new file mode 100644 index 000000000..bda86c36d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ipv4.py @@ -0,0 +1,159 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ipv4 +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set ipv4 information +description: + - Set ipv4 information on Inspur server. +notes: + - Does not support C(check_mode). +options: + interface_name: + description: + - Set interface_name. + choices: ['eth0', 'eth1', 'bond0'] + required: true + type: str + ipv4_status: + description: + - Enable or disable IPV4. + choices: ['enable', 'disable'] + type: str + ipv4_dhcp_enable: + description: + - Enable 'Enable DHCP' to dynamically configure IPv4 address using Dynamic Host Configuration Protocol (DHCP). + choices: ['dhcp', 'static'] + type: str + ipv4_address: + description: + - If DHCP is disabled, specify a static IPv4 address to be configured for the selected interface. + - Required when I(ipv4_dhcp_enable=static). + type: str + ipv4_subnet: + description: + - If DHCP is disabled, specify a static Subnet Mask to be configured for the selected interface. + - Required when I(ipv4_dhcp_enable=static). + type: str + ipv4_gateway: + description: + - If DHCP is disabled, specify a static Default Gateway to be configured for the selected interface. + - Required when I(ipv4_dhcp_enable=static). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ipv4 test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set ipv4 information" + inspur.ispim.edit_ipv4: + interface_name: "eth0" + ipv4_status: "disable" + provider: "{{ ism }}" + + - name: "Set ipv4 information" + inspur.ispim.edit_ipv4: + interface_name: "eth0" + ipv4_status: "enable" + ipv4_dhcp_enable: "dhcp" + provider: "{{ ism }}" + + - name: "Set ipv4 information" + inspur.ispim.edit_ipv4: + interface_name: "eth0" + ipv4_status: "enable" + ipv4_dhcp_enable: "static" + ipv4_address: "100.2.36.10" + ipv4_subnet: "255.255.255.0" + ipv4_gateway: "100.2.36.1" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Network(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setipv4' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface_name=dict(type='str', required=True, choices=['eth0', 'eth1', 'bond0']), + ipv4_status=dict(type='str', required=False, choices=['enable', 'disable']), + ipv4_dhcp_enable=dict(type='str', required=False, choices=['dhcp', 'static']), + ipv4_address=dict(type='str', required=False), + ipv4_subnet=dict(type='str', required=False), + ipv4_gateway=dict(type='str', required=False), + + ) + argument_spec.update(ism_argument_spec) + net_obj = Network(argument_spec) + net_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ipv6.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ipv6.py new file mode 100644 index 000000000..1d0355aae --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ipv6.py @@ -0,0 +1,166 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ipv6 +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set ipv6 information +description: + - Set ipv6 information on Inspur server. +notes: + - Does not support C(check_mode). +options: + interface_name: + description: + - Set interface_name. + choices: ['eth0', 'eth1', 'bond0'] + required: True + type: str + ipv6_status: + description: + - Enable or disable IPV6. + choices: ['enable', 'disable'] + type: str + ipv6_dhcp_enable: + description: + - Enable 'Enable DHCP' to dynamically configure IPv6 address using Dynamic Host Configuration Protocol (DHCP). + choices: ['dhcp', 'static'] + type: str + ipv6_address: + description: + - If DHCP is disabled, specify a static IPv6 address to be configured for the selected interface. + - Required when I(ipv6_dhcp_enable=static). + type: str + ipv6_index: + description: + - Ipv6 index(0-15). + - Required when I(ipv6_dhcp_enable=static). + type: int + ipv6_prefix: + description: + - The subnet prefix length for the IPv6 settings(0-128). + - Required when I(ipv6_dhcp_enable=static). + type: int + ipv6_gateway: + description: + - If DHCP is disabled, specify a static Default Gateway to be configured for the selected interface. + - Required when I(ipv6_dhcp_enable=static). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ipv6 test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set ipv6 information" + inspur.ispim.edit_ipv6: + interface_name: "eth0" + ipv6_status: "disable" + provider: "{{ ism }}" + + - name: "Set ipv6 information" + inspur.ispim.edit_ipv6: + interface_name: "eth0" + ipv6_status: "enable" + ipv6_dhcp_enable: "dhcp" + provider: "{{ ism }}" + + - name: "Set ipv6 information" + inspur.ispim.edit_ipv6: + interface_name: "eth0" + ipv6_status: "enable" + ipv6_dhcp_enable: "static" + ipv6_address: "::ffff:100:2:36:10" + ipv6_index: 12 + ipv6_prefix: 16 + ipv6_gateway: "::" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Network(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setipv6' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface_name=dict(type='str', required=True, choices=['eth0', 'eth1', 'bond0']), + ipv6_status=dict(type='str', required=False, choices=['enable', 'disable']), + ipv6_dhcp_enable=dict(type='str', required=False, choices=['dhcp', 'static']), + ipv6_address=dict(type='str', required=False), + ipv6_index=dict(type='int', required=False), + ipv6_prefix=dict(type='int', required=False), + ipv6_gateway=dict(type='str', required=False), + + ) + argument_spec.update(ism_argument_spec) + net_obj = Network(argument_spec) + net_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_kvm.py b/ansible_collections/inspur/ispim/plugins/modules/edit_kvm.py new file mode 100644 index 000000000..7ebb88e53 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_kvm.py @@ -0,0 +1,191 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_kvm +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set KVM +description: + - Set KVM on Inspur server. +notes: + - Does not support C(check_mode). +options: + client_type: + description: + - Client Type. + - Only the M6 model supports this parameter. + choices: ['vnc', 'viewer'] + type: str + kvm_encryption: + description: + - Encrypt KVM packets. + choices: ['enable', 'disable'] + type: str + media_attach: + description: + - Two types of VM attach mode are available. + - Attach is Immediately attaches Virtual Media to the server upon bootup. + - Auto is Attaches Virtual Media to the server only when a virtual media session is started. + - Only the M5 model supports this parameter. + choices: ['attach', 'auto'] + type: str + keyboard_language: + description: + - Select the Keyboard Language. + - AD is Auto Detect, DA is Danish, NL-BE is Dutch Belgium, NL-NL is Dutch Netherland, + - GB is English UK ,US is English US, FI is Finnish, FR-BE is French Belgium, FR is French France, + - DE is German Germany, DE-CH is German Switzerland, IT is Italian, JP is Japanese, + - NO is Norwegian, PT is Portuguese, ES is Spanish, SV is Swedish, TR_F is Turkish F, TR_Q is Turkish Q. + choices: ['AD', 'DA', 'NL-BE', 'NL-NL', 'GB', 'US', 'FI', 'FR-BE', 'FR', 'DE', 'DE-CH', 'IT', 'JP', 'ON', 'PT', 'EC', 'SV', 'TR_F','TR_Q'] + type: str + retry_count: + description: + - Number of times to be retried in case a KVM failure occurs.Retry count ranges from 1 to 20. + - Only the M5 model supports this parameter. + type: int + retry_time_interval: + description: + - The Identification for retry time interval configuration (5-30) seconds. + - Only the M5 model supports this parameter. + type: int + local_monitor_off: + description: + - Server Monitor OFF Feature Status. + choices: ['enable', 'disable'] + type: str + automatic_off: + description: + - Automatically OFF Server Monitor, When KVM Launches. + choices: ['enable', 'disable'] + type: str + non_secure: + description: + - Enable/disable Non Secure Connection Type. + - Only the M6 model supports this parameter. + - Required when I(client_type=vnc). + choices: ['enable', 'disable'] + type: str + ssh_vnc: + description: + - Enable/disable VNC over SSH in BMC. + - Only the M6 model supports this parameter. + - Required when I(client_type=vnc). + choices: ['enable', 'disable'] + type: str + stunnel_vnc: + description: + - Enable/disable VNC over Stunnel in BMC. + - Only the M6 model supports this parameter. + - Required when I(client_type=vnc). + choices: ['enable', 'disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: KVM test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set KVM" + inspur.ispim.edit_kvm: + kvm_encryption: "enable" + media_attach: "auto" + keyboard_language: "AD" + retry_count: 13 + retry_time_interval: 10 + local_monitor_off: "enable" + automatic_off: "enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class KVM(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setkvm' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + client_type=dict(type='str', required=False, choices=['vnc', 'viewer']), + kvm_encryption=dict(type='str', required=False, choices=['enable', 'disable']), + media_attach=dict(type='str', required=False, choices=['attach', 'auto']), + keyboard_language=dict(type='str', required=False, + choices=['AD', 'DA', 'NL-BE', 'NL-NL', 'GB', 'US', 'FI', 'FR-BE', 'FR', + 'DE', 'DE-CH', 'IT', 'JP', 'ON', 'PT', 'EC', 'SV', 'TR_F', 'TR_Q']), + retry_count=dict(type='int', required=False), + retry_time_interval=dict(type='int', required=False), + local_monitor_off=dict(type='str', required=False, choices=['enable', 'disable']), + automatic_off=dict(type='str', required=False, choices=['enable', 'disable']), + non_secure=dict(type='str', required=False, choices=['enable', 'disable']), + ssh_vnc=dict(type='str', required=False, choices=['enable', 'disable']), + stunnel_vnc=dict(type='str', required=False, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + kvm_obj = KVM(argument_spec) + kvm_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ldap.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ldap.py new file mode 100644 index 000000000..3c94e89c9 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ldap.py @@ -0,0 +1,190 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ldap +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set ldap information +description: + - Set ldap information on Inspur server. +notes: + - Does not support C(check_mode). +options: + enable: + description: + - LDAP/E-Directory Authentication Status. + choices: ['enable', 'disable'] + type: str + encry: + description: + - Encryption Type. + choices: ['no', 'SSL', 'StartTLS'] + type: str + address: + description: + - Server Address. + type: str + server_port: + description: + - Server Port. + type: int + dn: + description: + - Bind DN. + - Bind DN is a string of 4 to 64 alpha-numeric characters; + - It must start with an alphabetical character; + - Special Symbols like dot(.), comma(,), hyphen(-), underscore(_), equal-to(=) are allowed. + type: str + code: + description: + - Password. + - Required when I(enable=enable). + type: str + base: + description: + - Search Base, + - Search base is a string of 4 to 64 alpha-numeric characters; + - It must start with an alphabetical character; + - Special Symbols like dot(.), comma(,), hyphen(-), underscore(_), equal-to(=) are allowed. + type: str + attr: + description: + - Attribute of User Login. + choices: ['cn', 'uid'] + type: str + cn: + description: + - Common name type. + - Required when I(encry=StartTLS). + choices: ['ip', 'fqdn'] + type: str + ca: + description: + - CA certificate file path. + - Required when I(encry=StartTLS). + type: str + ce: + description: + - Certificate file path. + - Required when I(encry=StartTLS). + type: str + pk: + description: + - Private Key file path. + - Required when I(encry=StartTLS). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ldap test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set ldap information" + inspur.ispim.edit_ldap: + enable: "disable" + provider: "{{ ism }}" + + - name: "Set ldap information" + inspur.ispim.edit_ldap: + enable: "enable" + encry: "SSL" + address: "100.2.2.2" + server_port: 389 + dn: "cn=manager,ou=login,dc=domain,dc=com" + code: "123456" + base: "cn=manager" + attr: "uid" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LDAP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setldap' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + enable=dict(type='str', required=False, choices=['enable', 'disable']), + encry=dict(type='str', required=False, choices=['no', 'SSL', 'StartTLS']), + address=dict(type='str', required=False), + server_port=dict(type='int', required=False), + dn=dict(type='str', required=False), + code=dict(type='str', required=False), + base=dict(type='str', required=False), + attr=dict(type='str', required=False, choices=['cn', 'uid']), + cn=dict(type='str', required=False, choices=['ip', 'fqdn']), + ca=dict(type='str', required=False), + ce=dict(type='str', required=False), + pk=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + ldap_obj = LDAP(argument_spec) + ldap_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ldisk.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ldisk.py new file mode 100644 index 000000000..88f1dd3e7 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ldisk.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ldisk +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set logical disk +description: + - Set logical disk on Inspur server. +notes: + - Does not support C(check_mode). +options: + info: + description: + - Show controller and ldisk info. + choices: ['show'] + type: str + ctrl_id: + description: + - Raid controller ID. + - Required when I(Info=None). + type: int + ldisk_id: + description: + - Logical disk ID. + - Required when I(Info=None). + type: int + option: + description: + - Set operation options fo logical disk, + - LOC is Locate Logical Drive,STL is Stop Locate LogicalDrive, + - FI is Fast Initialization,SFI is Slow/Full Initialization, + - SI is Stop Initialization,DEL is Delete LogicalDrive. + - Required when I(Info=None). + choices: ['LOC', 'STL', 'FI', 'SFI', 'SI', 'DEL'] + type: str + duration: + description: + - duration range is 1-255,physical drive under PMC raid controller. + - Required when I(option=LOC). + - Only the M6 model supports this parameter. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Edit ldisk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Show ldisk information" + inspur.ispim.edit_ldisk: + info: "show" + provider: "{{ ism }}" + + - name: "Edit ldisk" + inspur.ispim.edit_ldisk: + ctrl_id: 0 + ldisk_id: 1 + option: "LOC" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setldisk' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + info=dict(type='str', required=False, choices=['show']), + ctrl_id=dict(type='int', required=False), + ldisk_id=dict(type='int', required=False), + option=dict(type='str', required=False, choices=['LOC', 'STL', 'FI', 'SFI', 'SI', 'DEL']), + duration=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_log_setting.py b/ansible_collections/inspur/ispim/plugins/modules/edit_log_setting.py new file mode 100644 index 000000000..c46f2b275 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_log_setting.py @@ -0,0 +1,164 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_log_setting +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set bmc system and audit log setting +description: + - Set bmc system and audit log setting on Inspur server. + - Only the M5 models support this feature. +notes: + - Does not support C(check_mode). +options: + status: + description: + - System Log Status. + choices: ['enable', 'disable'] + type: str + type: + description: + - System log type. + choices: ['local', 'remote', 'both'] + type: str + file_size: + description: + - File Size(3-65535bytes), set when type is local(default 30000). + type: int + audit_status: + description: + - Audit Log Status. + choices: ['enable', 'disable'] + type: str + audit_type: + description: + - Audit log type. + choices: ['local', 'remote', 'both'] + type: str + rotate_count: + description: + - Rotate Count, set when type is local, 0-delete old files(default), 1-bak old files. + choices: [0, 1] + type: int + server_addr: + description: + - Server Address, set when type is remote. + type: str + server_port: + description: + - Server Port(0-65535), set when type is remote. + type: int + protocol_type: + description: + - Protocol Type, set when type is remote. + choices: ['UDP', 'TCP'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Edit log setting test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Edit bmc system log setting" + inspur.ispim.edit_log_setting: + status: "enable" + type: "both" + provider: "{{ ism }}" + + - name: "Edit bmc audit log setting" + inspur.ispim.edit_log_setting: + audit_status: "enable" + audit_type: "remote" + server_addr: "100.2.126.11" + server_port: "514" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LogSetting(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setbmclogsettings' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + status=dict(type='str', required=False, choices=['enable', 'disable']), + type=dict(type='str', required=False, choices=['local', 'remote', 'both']), + file_size=dict(type='int', required=False), + audit_status=dict(type='str', required=False, choices=['enable', 'disable']), + audit_type=dict(type='str', required=False, choices=['local', 'remote', 'both']), + rotate_count=dict(type='int', required=False, choices=[0, 1]), + server_addr=dict(type='str', required=False), + server_port=dict(type='int', required=False), + protocol_type=dict(type='str', required=False, choices=['UDP', 'TCP']), + ) + argument_spec.update(ism_argument_spec) + log_obj = LogSetting(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_m6_log_setting.py b/ansible_collections/inspur/ispim/plugins/modules/edit_m6_log_setting.py new file mode 100644 index 000000000..3ffe54b4b --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_m6_log_setting.py @@ -0,0 +1,174 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_m6_log_setting +version_added: "1.3.0" +author: + - WangBaoshan (@ispim) +short_description: Set bmc system and audit log setting +description: + - Set bmc system and audit log setting on Inspur server. + - Only the M6 models support this feature. +notes: + - Does not support C(check_mode). +options: + status: + description: + - System Log Status. + choices: ['enable', 'disable'] + type: str + host_tag: + description: + - System log host tag,set when I(status=enable). + choices: ['HostName', 'SerialNum', 'AssertTag'] + type: str + level: + description: + - Events Level,set when I(status=enable). + choices: ['Critical', 'Warning', 'Info'] + type: str + protocol_type: + description: + - Protocol Type,set when I(status=enable). + choices: ['UDP', 'TCP'] + type: str + server_id: + description: + - Syslog Server ID,set when I(status=enable). + choices: [0, 1, 2, 3] + type: int + server_addr: + description: + - Server Address,set when server_id is not none. + type: str + server_port: + description: + - Server Address,set when server_id is not none. + type: int + log_type: + description: + - Remote Log Type,set when server_id is not none. + choices: ['idl', 'audit', 'both'] + type: str + test: + description: + - Test remote log settings,set when server_id is not none. + default: False + type: bool +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Edit log setting test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Edit bmc system log setting" + inspur.ispim.edit_m6_log_setting: + status: "disable" + provider: "{{ ism }}" + + - name: "Edit bmc audit log setting" + inspur.ispim.edit_m6_log_setting: + status: "enable" + host_tag: "HostName" + level: "Info" + protocol_type: "TCP" + server_id: 0 + server_addr: "100.2.126.11" + server_port: 514 + log_type: "both" + provider: "{{ ism }}" + + - name: "test bmc audit log" + inspur.ispim.edit_m6_log_setting: + server_id: 0 + test: True + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LogSetting(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setbmclogcfg' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + status=dict(type='str', required=False, choices=['enable', 'disable']), + host_tag=dict(type='str', required=False, choices=['HostName', 'SerialNum', 'AssertTag']), + level=dict(type='str', required=False, choices=['Critical', 'Warning', 'Info']), + protocol_type=dict(type='str', required=False, choices=['UDP', 'TCP']), + server_id=dict(type='int', required=False, choices=[0, 1, 2, 3]), + server_addr=dict(type='str', required=False), + server_port=dict(type='int', required=False), + log_type=dict(type='str', required=False, choices=['idl', 'audit', 'both']), + test=dict(type='bool', required=False, default=False), + ) + argument_spec.update(ism_argument_spec) + log_obj = LogSetting(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_manual_capture.py b/ansible_collections/inspur/ispim/plugins/modules/edit_manual_capture.py new file mode 100644 index 000000000..b7b5c07c0 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_manual_capture.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_manual_capture +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set manual capture screen +description: + - Set manual capture screen on Inspur server. +notes: + - Does not support C(check_mode). +options: + type: + description: + - Manual type. + choices: ['capture', 'delete'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Screen test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set manual capture screen" + inspur.ispim.edit_manual_capture: + type: "capture" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Screen(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'screenmanual' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + type=dict(type='str', required=True, choices=['capture', 'delete']), + ) + argument_spec.update(ism_argument_spec) + screen_obj = Screen(argument_spec) + screen_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_media_instance.py b/ansible_collections/inspur/ispim/plugins/modules/edit_media_instance.py new file mode 100644 index 000000000..7802aedbd --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_media_instance.py @@ -0,0 +1,167 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_media_instance +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set Virtual Media Instance +description: + - Set Virtual Media Instance on Inspur server. +notes: + - Does not support C(check_mode). +options: + num_fd: + description: + - Select the number of floppy devices that support for Virtual Media redirection. + choices: [0, 1, 2, 3, 4] + type: int + num_cd: + description: + - Select the number of CD/DVD devices that support for Virtual Media redirection. + choices: [0, 1, 2, 3, 4] + type: int + num_hd: + description: + - Select the number of harddisk devices that support for Virtual Media redirection. + choices: [0, 1, 2, 3, 4] + type: int + kvm_num_fd: + description: + - Select the number of Remote KVM floppy devices that support for Virtual Media redirection. + choices: [0, 1, 2, 3, 4] + type: int + kvm_num_cd: + description: + - Select the number of Remote KVM CD/DVD devices that support for virtual Media redirection, + - The max support number of html5 KVM is 2 and java KVM is 4. + choices: [0, 1, 2, 3, 4] + type: int + kvm_num_hd: + description: + - Select the number of Remote KVM Hard disk devices to support for Virtual Media redirection. + choices: [0, 1, 2, 3, 4] + type: int + sd_media: + description: + - Check this option to enable SD Media support in BMC. + choices: ['Enable', 'Disable'] + type: str + secure_channel: + description: + - Check this option to enable encrypt media recirection packets. + - Only the M5/M6 model supports this parameter. + choices: ['Enable', 'Disable'] + type: str + power_save_mode: + description: + - Check this option to enable Power Save Mode in BMC. + choices: ['Enable', 'Disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Media instance test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set media instance" + inspur.ispim.edit_media_instance: + num_fd: 1 + num_cd: 1 + num_hd: 1 + kvm_num_fd: 1 + kvm_num_cd: 1 + kvm_num_hd: 1 + sd_media: "Enable" + secure_channel: "Enable" + power_save_mode: "Enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Instance(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setmediainstance' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + num_fd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + num_cd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + num_hd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + kvm_num_fd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + kvm_num_cd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + kvm_num_hd=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + sd_media=dict(type='str', required=False, choices=['Enable', 'Disable']), + secure_channel=dict(type='str', required=False, choices=['Enable', 'Disable']), + power_save_mode=dict(type='str', required=False, choices=['Enable', 'Disable']), + ) + argument_spec.update(ism_argument_spec) + instance_obj = Instance(argument_spec) + instance_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ncsi.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ncsi.py new file mode 100644 index 000000000..11e1b8f0d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ncsi.py @@ -0,0 +1,133 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ncsi +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set ncsi information +description: + - Set ncsi information on Inspur server. +notes: + - Does not support C(check_mode). +options: + nic_type: + description: + - Nic type. + - Only NF3280A6 and NF3180A6 model supports C(Disable) Settings, but not support C(PHY) Settings. + - M6 model only support C(OCP),C(OCP1),C(PCIE) settings. + choices: ['PHY', 'OCP','OCP1', 'PCIE', 'auto', 'Disable'] + type: str + mode: + description: + - NCSI mode, auto-Auto Failover, manual-Manual Switch. + - Only M6 model supports C(Disable) Settings + choices: ['auto', 'manual', 'Disable'] + type: str + interface_name: + description: + - Interface name, for example eth0. + - Only the M5 model supports this parameter. + type: str + channel_number: + description: + - Channel number. + choices: [0, 1, 2, 3] + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: NCSI test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set ncsi information" + inspur.ispim.edit_ncsi: + mode: "manual" + nic_type: "PCIE" + interface_name: "eth0" + channel_number: 1 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class NCSI(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setncsi' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + nic_type=dict(type='str', required=False, choices=['PHY', 'OCP', 'OCP1', 'PCIE', 'auto', 'Disable']), + mode=dict(type='str', required=False, choices=['auto', 'manual', 'Disable']), + interface_name=dict(type='str', required=False), + channel_number=dict(type='int', required=False, choices=[0, 1, 2, 3]), + ) + argument_spec.update(ism_argument_spec) + ncsi_obj = NCSI(argument_spec) + ncsi_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_network.py b/ansible_collections/inspur/ispim/plugins/modules/edit_network.py new file mode 100644 index 000000000..597e0a6ed --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_network.py @@ -0,0 +1,118 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_network +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set network information +description: + - Set netowrk information on Inspur server. +notes: + - Does not support C(check_mode). +options: + interface_name: + description: + - Set interface_name. + choices: ['eth0', 'eth1', 'bond0'] + required: true + type: str + lan_enable: + description: + - Enable or disable this interface. If disable , you cannot use this interface any more. + choices: ['enable', 'disable'] + required: true + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Network test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set network information" + inspur.ispim.edit_network: + interface_name: "eth0" + lan_enable: "enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Network(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setnetwork' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface_name=dict(type='str', required=True, choices=['eth0', 'eth1', 'bond0']), + lan_enable=dict(type='str', required=True, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + net_obj = Network(argument_spec) + net_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_network_bond.py b/ansible_collections/inspur/ispim/plugins/modules/edit_network_bond.py new file mode 100644 index 000000000..5e593617e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_network_bond.py @@ -0,0 +1,123 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_network_bond +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set network bond +description: + - Set network bond on Inspur server. +notes: + - Does not support C(check_mode). +options: + bond: + description: + - Network bond status,If VLAN is enabled for slave interfaces, then Bonding cannot be enabled. + choices: ['enable', 'disable'] + type: str + interface: + description: + - Interface name. + choices: ['shared', 'dedicated', 'both'] + type: str + auto_config: + description: + - Enable this option to configure the interfaces in service configuration automatically. + choices: ['enable', 'disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: bond test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set network bond" + inspur.ispim.edit_network_bond: + bond: "enable" + interface: "dedicated" + auto_config: "enable" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Bond(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setnetworkbond' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + bond=dict(type='str', required=False, choices=['enable', 'disable']), + interface=dict(type='str', required=False, choices=['shared', 'dedicated', 'both']), + auto_config=dict(type='str', required=False, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + bond_obj = Bond(argument_spec) + bond_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_network_link.py b/ansible_collections/inspur/ispim/plugins/modules/edit_network_link.py new file mode 100644 index 000000000..d57a4a96d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_network_link.py @@ -0,0 +1,140 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_network_link +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set network link +description: + - Set network link on Inspur server. +notes: + - Does not support C(check_mode). +options: + interface: + description: + - Interface name. + choices: ['shared', 'dedicated', 'both'] + type: str + required: true + auto_nego: + description: + - This option is enabled to allow the device to perform automatic configuration to + - achieve the best possible mode of operation(speed and duplex) over a link. + choices: ['enable', 'disable'] + type: str + link_speed: + description: + - Link speed will list all the supported capabilities of the network interface. It can be 10/100 Mbps. + - Required when I(auto_nego=disable). + choices: [10, 100] + type: int + duplex_mode: + description: + - Select any one of the following Duplex Mode. + - Required when I(auto_nego=disable). + choices: ['HALF', 'FULL'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: link test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set network link" + inspur.ispim.edit_network_link: + interface: "dedicated" + auto_nego: "enable" + provider: "{{ ism }}" + + - name: "Set network link" + inspur.ispim.edit_network_link: + interface: "dedicated" + auto_nego: "disable" + link_speed: 100 + duplex_mode: "FULL" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Link(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setnetworklink' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface=dict(type='str', required=True, choices=['shared', 'dedicated', 'both']), + auto_nego=dict(type='str', required=False, choices=['enable', 'disable']), + link_speed=dict(type='int', required=False, choices=[10, 100]), + duplex_mode=dict(type='str', required=False, choices=['HALF', 'FULL']), + ) + argument_spec.update(ism_argument_spec) + link_obj = Link(argument_spec) + link_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_ntp.py b/ansible_collections/inspur/ispim/plugins/modules/edit_ntp.py new file mode 100644 index 000000000..5984694fc --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_ntp.py @@ -0,0 +1,173 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_ntp +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set NTP +description: + - Set NTP on Inspur server. +notes: + - Does not support C(check_mode). +options: + auto_date: + description: + - Date auto synchronize. + choices: ['enable', 'disable'] + type: str + ntp_time: + description: + - NTP time(YYYYmmddHHMMSS). + - Only the M5 model supports this parameter. + type: str + time_zone: + description: + - UTC time zone,chose from {-12, -11.5, -11, ... ,11,11.5,12}. + type: str + server1: + description: + - NTP Server1(ipv4 or ipv6 or domain name), set when auto_dateis enable. + type: str + server2: + description: + - NTP Server2(ipv4 or ipv6 or domain name), set when auto_date is enable. + type: str + server3: + description: + - NTP Server3(ipv4 or ipv6 or domain name), set when auto_date is enable. + type: str + server4: + description: + - NTP Server1(ipv4 or ipv6 or domain name), set when auto_dateis enable. + type: str + server5: + description: + - NTP Server2(ipv4 or ipv6 or domain name), set when auto_date is enable. + type: str + server6: + description: + - NTP Server3(ipv4 or ipv6 or domain name), set when auto_date is enable. + type: str + syn_cycle: + description: + - NTP syn cycle(minute),sync cycle(5-1440). + type: int + max_variety: + description: + - NTP Maximum jump time(minute),max variety(1-60). + - Only the M6 model supports this parameter. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: NTP test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set ntp" + inspur.ispim.edit_ntp: + auto_date: "enable" + server2: "time.nist.gov" + provider: "{{ ism }}" + + - name: "Set ntp" + inspur.ispim.edit_ntp: + auto_date: "disable" + ntp_time: "20200609083600" + provider: "{{ ism }}" + + - name: "set ntp" + inspur.ispim.edit_ntp: + time_zone: "8" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class NTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'settime' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + auto_date=dict(type='str', required=False, choices=['enable', 'disable']), + ntp_time=dict(type='str', required=False), + time_zone=dict(type='str', required=False), + server1=dict(type='str', required=False), + server2=dict(type='str', required=False), + server3=dict(type='str', required=False), + server4=dict(type='str', required=False), + server5=dict(type='str', required=False), + server6=dict(type='str', required=False), + syn_cycle=dict(type='int', required=False), + max_variety=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + ntp_obj = NTP(argument_spec) + ntp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_pdisk.py b/ansible_collections/inspur/ispim/plugins/modules/edit_pdisk.py new file mode 100644 index 000000000..2f72742b8 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_pdisk.py @@ -0,0 +1,192 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_pdisk +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set physical disk +description: + - Set physical disk on Inspur server. +notes: + - Does not support C(check_mode). +options: + info: + description: + - Show controller and pdisk info. + choices: ['show'] + type: str + ctrl_id: + description: + - Raid controller ID. + - Required when I(Info=None). + type: int + device_id: + description: + - physical drive id. + - Required when I(Info=None). + type: int + option: + description: + - Set operation options fo physical disk, + - UG is Unconfigured Good,UB is Unconfigured Bad, + - OFF is offline,FAIL is Failed,RBD is Rebuild, + - ON is Online,JB is JBOD,ES is Drive Erase stop, + - EM is Drive Erase Simple,EN is Drive Erase Normal, + - ET is Drive Erase Through,LOC is Locate,STL is Stop Locate, + - HS is Hot spare. + - Required when I(Info=None). + - Only the M5 model supports C(HS) Settings. + choices: ['UG', 'UB', 'OFF', 'FAIL', 'RBD', 'ON', 'JB', 'ES', 'EM', 'EN', 'ET', 'LOC', 'STL', 'HS'] + type: str + action: + description: + - Action while set physical drive hotspare. + - Required when I(Info=None) and I(option=HS). + - Only the M5 model supports this parameter. + choices: ['remove', 'global', 'dedicate'] + type: str + revertible: + description: + - IsRevertible while set physical drive hotspare. + - Required when I(Info=None) and I(option=HS) and I(action=dedicate). + - Only the M5 model supports this parameter. + choices: ['yes', 'no'] + type: str + encl: + description: + - IsEnclAffinity while set physical drive hotspare. + - Required when I(Info=None) and I(option=HS) and I(action=dedicate). + - Only the M5 model supports this parameter. + choices: ['yes', 'no'] + type: str + logical_drivers: + description: + - Logical Drivers while set physical drive hotspare, input multiple Logical Drivers index like 0,1,2..... + - Required when I(Info=None) and I(option=HS) and I(action=dedicate). + - Only the M5 model supports this parameter. + type: list + elements: int + duration: + description: + - duration range is 1-255,physical drive under PMC raid controller. + - Required when I(option=LOC). + - Only the M6 model supports this parameter. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Edit pdisk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Show pdisk information" + inspur.ispim.edit_pdisk: + info: "show" + provider: "{{ ism }}" + + - name: "Edit pdisk" + inspur.ispim.edit_pdisk: + ctrl_id: 0 + device_id: 1 + option: "LOC" + provider: "{{ ism }}" + + - name: "M5 Edit pdisk" + inspur.ispim.edit_pdisk: + ctrl_id: 0 + device_id: 1 + option: "HS" + action: "dedicate" + revertible: "yes" + encl: "yes" + logical_drivers: 1 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setpdisk' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + info=dict(type='str', required=False, choices=['show']), + ctrl_id=dict(type='int', required=False), + device_id=dict(type='int', required=False), + option=dict(type='str', required=False, choices=['UG', 'UB', 'OFF', 'FAIL', 'RBD', 'ON', 'JB', 'ES', 'EM', 'EN', 'ET', 'LOC', 'STL', 'HS']), + action=dict(type='str', required=False, choices=['remove', 'global', 'dedicate']), + revertible=dict(type='str', required=False, choices=['yes', 'no']), + encl=dict(type='str', required=False, choices=['yes', 'no']), + logical_drivers=dict(type='list', elements='int', required=False), + duration=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_power_budget.py b/ansible_collections/inspur/ispim/plugins/modules/edit_power_budget.py new file mode 100644 index 000000000..902f8e97c --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_power_budget.py @@ -0,0 +1,255 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_power_budget +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set power budget information +description: + - Set power budget information on Inspur server. +notes: + - Does not support C(check_mode). +options: + range: + description: + - Range of power budget watts. + choices: ['True', 'False'] + default: False + type: bool + domain: + description: + - Domain id. + - Required when I(range=False). + choices: ['system', 'cpu'] + type: str + action: + description: + - Type to action. + - Required when I(range=False). + choices: ['add', 'delete', 'open', 'close'] + type: str + id: + description: + - Policy id. + - Required when I(range=False). + choices: [1, 2, 3, 4] + type: int + watts: + description: + - Power budget watts of add. + - Required when I(action=add). + type: int + except_action: + description: + - Except action, 0 is do nothing, 1 is send alert, 2 is shutdown system, 3 is shutdown system and send alert. + - Only the M7 model supports this parameter. + choices: [0, 1, 2, 3] + type: int + start1: + description: + - Pause period of add, start time, from 0 to 24. + type: int + end1: + description: + - Pause period of add, end time,must be greater than start time,from 0 to 24. + type: int + week1: + description: + - Pause period of add,repetition period,the input parameters are 'Mon','Tue','Wed','Thur','Fri','Sat','Sun',separated by commas,such as Mon,Wed,Fri. + type: list + elements: str + start2: + description: + - Pause period of add, start time, from 0 to 24. + type: int + end2: + description: + - Pause period of add, end time,must be greater than start time,from 0 to 24. + type: int + week2: + description: + - Pause period of add,repetition period,the input parameters are 'Mon','Tue','Wed','Thur','Fri','Sat','Sun',separated by commas,such as Mon,Wed,Fri. + type: list + elements: str + start3: + description: + - Pause period of add, start time, from 0 to 24. + type: int + end3: + description: + - Pause period of add, end time,must be greater than start time,from 0 to 24. + type: int + week3: + description: + - Pause period of add,repetition period,the input parameters are 'Mon','Tue','Wed','Thur','Fri','Sat','Sun',separated by commas,such as Mon,Wed,Fri. + type: list + elements: str + start4: + description: + - Pause period of add, start time, from 0 to 24. + type: int + end4: + description: + - Pause period of add, end time,must be greater than start time,from 0 to 24. + type: int + week4: + description: + - Pause period of add,repetition period,the input parameters are 'Mon','Tue','Wed','Thur','Fri','Sat','Sun',separated by commas,such as Mon,Wed,Fri. + type: list + elements: str + start5: + description: + - Period of add, start time, from 0 to 24. + type: int + end5: + description: + - Pause period of add, end time,must be greater than start time,from 0 to 24. + type: int + week5: + description: + - Pause period of add,repetition period,the input parameters are 'Mon','Tue','Wed','Thur','Fri','Sat','Sun',separated by commas,such as Mon,Wed,Fri. + type: list + elements: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power budget test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get power budget range" + inspur.ispim.edit_power_budget: + range: True + provider: "{{ ism }}" + + - name: "add power budget" + inspur.ispim.edit_power_budget: + action: "add" + id: 1 + watts: 1500 + start1: 2 + end1: 5 + week1: + - Mon + - Wed + - Fri + provider: "{{ ism }}" + + - name: "Set power budget status to open" + inspur.ispim.edit_power_budget: + action: "open" + id: 1 + provider: "{{ ism }}" + + - name: "Set power budget status to close" + inspur.ispim.edit_power_budget: + action: "close" + id: 1 + provider: "{{ ism }}" + + - name: "Delete power budget" + inspur.ispim.edit_power_budget: + action: "delete" + id: 1 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setpowerbudget' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + range=dict(type='bool', default=False, choices=[True, False]), + domain=dict(type='str', required=False, choices=['system', 'cpu']), + action=dict(type='str', required=False, choices=['add', 'delete', 'open', 'close']), + id=dict(type='int', required=False, choices=[1, 2, 3, 4]), + watts=dict(type='int', required=False), + except_action=dict(type='int', required=False, choices=[0, 1, 2, 3]), + start1=dict(type='int', required=False), + end1=dict(type='int', required=False), + week1=dict(type='list', elements='str', required=False), + start2=dict(type='int', required=False), + end2=dict(type='int', required=False), + week2=dict(type='list', elements='str', required=False), + start3=dict(type='int', required=False), + end3=dict(type='int', required=False), + week3=dict(type='list', elements='str', required=False), + start4=dict(type='int', required=False), + end4=dict(type='int', required=False), + week4=dict(type='list', elements='str', required=False), + start5=dict(type='int', required=False), + end5=dict(type='int', required=False), + week5=dict(type='list', elements='str', required=False), + ) + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_power_restore.py b/ansible_collections/inspur/ispim/plugins/modules/edit_power_restore.py new file mode 100644 index 000000000..bc3bbfc20 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_power_restore.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_power_restore +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set power restore information +description: + - Set power restore information on Inspur server. +notes: + - Does not support C(check_mode). +options: + option: + description: + - Set power policy option. + choices: ['on', 'off', 'restore'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power restore test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set power restore information" + inspur.ispim.edit_power_restore: + option: "on" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setpowerrestore' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + option=dict(type='str', required=True, choices=['on', 'off', 'restore']), + ) + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_power_status.py b/ansible_collections/inspur/ispim/plugins/modules/edit_power_status.py new file mode 100644 index 000000000..40bfb4324 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_power_status.py @@ -0,0 +1,110 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_power_status +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set power status information +description: + - Set power status information on Inspur server. +notes: + - Does not support C(check_mode). +options: + state: + description: + - Power status. + choices: ['On', 'ForceOff', 'ForcePowerCycle', 'ForceReset', 'GracefulShutdown'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power status test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set power status information" + inspur.ispim.edit_power_status: + state: "On" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'powercontrol' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + state=dict(type='str', required=True, choices=['On', 'ForceOff', 'ForcePowerCycle', 'ForceReset', 'GracefulShutdown']), + ) + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_preserve_config.py b/ansible_collections/inspur/ispim/plugins/modules/edit_preserve_config.py new file mode 100644 index 000000000..2a13441db --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_preserve_config.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_preserve_config +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set preserve config +description: + - Set preserve config on Inspur server. +notes: + - Does not support C(check_mode). +options: + setting: + description: + - Preserve option, all - preserve all config; none - overwrite all config; manual - manual choose. + choices: ['all', 'none', 'manual'] + type: str + required: true + override: + description: + - Configuration items that need to be retained. + - Required when I(setting=manual). + choices: ['authentication', 'dcmi', 'fru', 'hostname', 'ipmi', 'kvm', 'network', 'ntp', 'pef', + 'sdr', 'sel', 'smtp', 'snmp', 'sol', 'ssh', 'syslog', 'user'] + type: list + elements: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Preserve test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set preserve all" + inspur.ispim.edit_preserve_config: + setting: "all" + provider: "{{ ism }}" + + - name: "Set preserve none" + edit_preserve_config: + setting: "none" + provider: "{{ ism }}" + + - name: "Set preserve manual" + edit_preserve_config: + setting: "manual" + override: + - fru + - ntp + - network + - user + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Preserve(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'preserveconfig' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + setting=dict(type='str', required=True, choices=['all', 'none', 'manual']), + override=dict(type='list', elements='str', required=False, + choices=['authentication', 'dcmi', 'fru', 'hostname', 'ipmi', 'kvm', 'network', 'ntp', + 'pef', 'sdr', 'sel', 'smtp', 'snmp', 'sol', 'ssh', 'syslog', 'user']), + ) + argument_spec.update(ism_argument_spec) + pre_obj = Preserve(argument_spec) + pre_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_psu_config.py b/ansible_collections/inspur/ispim/plugins/modules/edit_psu_config.py new file mode 100644 index 000000000..e5676780b --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_psu_config.py @@ -0,0 +1,116 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_psu_config +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set psu config information +description: + - Set psu config information on Inspur server. +notes: + - Does not support C(check_mode). +options: + id: + description: + - Power id. + type: int + required: true + switch: + description: + - Power supply mode, active or standby. + choices: ['active', 'standby', 'normal'] + type: str + required: true +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Psu config test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set psu config information" + inspur.ispim.edit_psu_config: + id: 1 + switch: "active" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Psu(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setpsuconfig' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + id=dict(type='int', required=True), + switch=dict(type='str', required=True, choices=['active', 'standby', 'normal']), + ) + argument_spec.update(ism_argument_spec) + psu_obj = Psu(argument_spec) + psu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_psu_peak.py b/ansible_collections/inspur/ispim/plugins/modules/edit_psu_peak.py new file mode 100644 index 000000000..b124578ad --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_psu_peak.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_psu_peak +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set psu peak information +description: + - Set psu peak information on Inspur server. +notes: + - Does not support C(check_mode). +options: + status: + description: + - Power peak status. + choices: ['enable', 'disable'] + type: str + required: true + time: + description: + - Maximum random time, range of values(1-600), unit(second). + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Psu peak test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set psu peak information" + inspur.ispim.edit_psu_peak: + status: "disable" + provider: "{{ ism }}" + + - name: "Set psu peak information" + inspur.ispim.edit_psu_peak: + status: "enable" + time: 10 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Psu(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setpsupeak' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + status=dict(type='str', required=True, choices=['enable', 'disable']), + time=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + psu_obj = Psu(argument_spec) + psu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_restore_factory_default.py b/ansible_collections/inspur/ispim/plugins/modules/edit_restore_factory_default.py new file mode 100644 index 000000000..bd7dcb164 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_restore_factory_default.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_restore_factory_default +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set preserver config +description: + - Set preserver config on Inspur server. +notes: + - Does not support C(check_mode). +options: + mode: + description: + - Restore factory defaults mode. + choices: ['all', 'none', 'manual'] + type: str + required: true + override: + description: + - Configuration items that need to be retained. + - Required when I(mode=manual). + choices: ['authentication', 'dcmi', 'fru', 'hostname', 'ipmi', 'kvm', 'network', 'ntp', 'pef', + 'sdr', 'sel', 'smtp', 'snmp', 'sol', 'ssh', 'syslog', 'user'] + type: list + elements: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Restore default test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set restore default auto" + inspur.ispim.edit_restore_factory_default: + mode: "all" + provider: "{{ ism }}" + + - name: "Set restore default manual" + inspur.ispim.edit_restore_factory_default: + mode: "manual" + override: + - fru + - ntp + - network + - user + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Preserver(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'restorefactorydefaults' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + mode=dict(type='str', required=True, choices=['all', 'none', 'manual']), + override=dict(type='list', elements='str', required=False, + choices=['authentication', 'dcmi', 'fru', 'hostname', 'ipmi', 'kvm', 'network', 'ntp', + 'pef', 'sdr', 'sel', 'smtp', 'snmp', 'sol', 'ssh', 'syslog', 'user']), + ) + argument_spec.update(ism_argument_spec) + pre_obj = Preserver(argument_spec) + pre_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_service.py b/ansible_collections/inspur/ispim/plugins/modules/edit_service.py new file mode 100644 index 000000000..f53d7db17 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_service.py @@ -0,0 +1,150 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_service +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set service settings +description: + - Set service settings on Inspur server. +notes: + - Does not support C(check_mode). +options: + service_name: + description: + - Displays service name of the selected slot(readonly). + - The I(vnc) option is not supported in M5. + - The I(fd-media/telnet/snmp) option is not supported in M6. + choices: ['web', 'kvm', 'cd-media', 'fd-media', 'hd-media', 'ssh', 'telnet', 'solssh', 'snmp', 'vnc'] + type: str + required: true + state: + description: + - Displays the current status of the service, either active or inactive state. + - Check this option to start the inactive service. + choices: ['active', 'inactive'] + type: str + interface: + description: + - It shows the interface in which service is running. + - The user can choose any one of the available interfaces. + - Only the M5 model supports this parameter. + choices: ['eth0', 'eth1', 'both', 'bond0'] + type: str + non_secure_port: + description: + - Used to configure non secure port number for the service. + - Port value ranges from 1 to 65535. + type: int + secure_port: + description: + - Used to configure secure port number for the service. + - Port value ranges from 1 to 65535. + type: int + timeout: + description: + - Displays the session timeout value of the service. + - For web, SSH and telnet service, user can configure the session timeout value. + - Web timeout value ranges from 300 to 1800 seconds. + - SSH and Telnet timeout value ranges from 60 to 1800 seconds. + - timeout value should be in multiples of 60 seconds. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Edit service test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Edit kvm" + inspur.ispim.edit_service: + service_name: "kvm" + state: "active" + timeout: "1200" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Service(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setservice' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + service_name=dict(type='str', required=True, choices=['web', 'kvm', 'cd-media', 'fd-media', 'hd-media', 'ssh', 'telnet', 'solssh', 'snmp', 'vnc']), + state=dict(type='str', required=False, choices=['active', 'inactive']), + interface=dict(type='str', required=False, choices=['eth0', 'eth1', 'both', 'bond0']), + non_secure_port=dict(type='int', required=False), + secure_port=dict(type='int', required=False), + timeout=dict(type='int', required=False) + ) + argument_spec.update(ism_argument_spec) + service_obj = Service(argument_spec) + service_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_smtp.py b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp.py new file mode 100644 index 000000000..c993c54f9 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp.py @@ -0,0 +1,213 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_smtp +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set SMTP information +description: + - Set SMTP information on Inspur server. + - Only the M5 models support this feature. +notes: + - Does not support C(check_mode). +options: + interface: + description: + - LAN Channel,eth0 is shared,eth1 is dedicated. + choices: ['eth0', 'eth1', 'bond0'] + type: str + required: true + email: + description: + - Sender email. + type: str + primary_status: + description: + - Primary SMTP Support. + choices: ['enable', 'disable'] + type: str + primary_ip: + description: + - Primary SMTP server IP. + type: str + primary_name: + description: + - Primary SMTP server name. + type: str + primary_port: + description: + - Primary SMTP server port,The Identification for retry count configuration(1-65535). + type: int + primary_auth: + description: + - Primary SMTP server authentication. + choices: ['enable', 'disable'] + type: str + primary_username: + description: + - Primary SMTP server Username,lenth be 4 to 64 bits, + - must start with letters and cannot contain ','(comma) ':'(colon) ' '(space) ';'(semicolon) '\\'(backslash). + type: str + primary_password: + description: + - Primary SMTP server Password,lenth be 4 to 64 bits,cannot contain ' '(space). + - Required when I(primary_auth=enable). + type: str + secondary_status: + description: + - Secondary SMTP Support. + choices: ['enable', 'disable'] + type: str + secondary_ip: + description: + - Secondary SMTP server IP. + type: str + secondary_name: + description: + - Secondary SMTP server name. + type: str + secondary_port: + description: + - Secondary SMTP server port,The Identification for retry count configuration(1-65535). + type: int + secondary_auth: + description: + - S.econdary SMTP server authentication + choices: ['enable', 'disable'] + type: str + secondary_username: + description: + - Secondary SMTP server Username,lenth be 4 to 64 bits, + - must start with letters and cannot contain ','(comma) ':'(colon) ' '(space) ';'(semicolon) '\\'(backslash). + type: str + secondary_password: + description: + - Secondary SMTP server Password,lenth be 4 to 64 bits,cannot contain ' '(space). + - Required when I(secondary_auth=enable). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Smtp test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set smtp information" + inspur.ispim.edit_smtp: + interface: "eth0" + email: "inspur@Inspur.com" + primary_status: "enable" + primary_ip: "100.2.2.2" + primary_name: "inspur" + primary_auth: "disable" + provider: "{{ ism }}" + + - name: "Set smtp information" + inspur.ispim.edit_smtp: + interface: "eth0" + email: "inspur@Inspur.com" + primary_status: "enable" + primary_ip: "100.2.2.2" + primary_name: "inspur" + primary_auth: "enable" + primary_username: "test" + primary_password: my_password + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SMTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsmtp' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface=dict(type='str', required=True, choices=['eth0', 'eth1', 'bond0']), + email=dict(type='str', required=False), + primary_status=dict(type='str', required=False, choices=['enable', 'disable']), + primary_ip=dict(type='str', required=False), + primary_name=dict(type='str', required=False), + primary_port=dict(type='int', required=False), + primary_auth=dict(type='str', required=False, choices=['enable', 'disable']), + primary_username=dict(type='str', required=False), + primary_password=dict(type='str', required=False, no_log=True), + secondary_status=dict(type='str', required=False, choices=['enable', 'disable']), + secondary_ip=dict(type='str', required=False), + secondary_name=dict(type='str', required=False), + secondary_port=dict(type='int', required=False), + secondary_auth=dict(type='str', required=False, choices=['enable', 'disable']), + secondary_username=dict(type='str', required=False), + secondary_password=dict(type='str', required=False, no_log=True), + + ) + argument_spec.update(ism_argument_spec) + smtp_obj = SMTP(argument_spec) + smtp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_com.py b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_com.py new file mode 100644 index 000000000..85bf93b2f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_com.py @@ -0,0 +1,200 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_smtp_com +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set SMTP information +description: + - Set SMTP com information on Inspur server. + - Only the M6 models support this feature. +notes: + - Does not support C(check_mode). +options: + status: + description: + - SMTP Support. + choices: ['enable', 'disable'] + required: true + type: str + server_ip: + description: + - SMTP server IP. + type: str + server_port: + description: + - SMTP server port,The Identification for retry count configuration(1-65535). + type: int + server_secure_port: + description: + - SMTP server sesure port,The Identification for retry count configuration(1-65535). + type: int + email: + description: + - Sender email. + type: str + server_auth: + description: + - SMTP server authentication. + choices: ['enable', 'disable'] + type: str + server_username: + description: + - SMTP server Username,lenth be 4 to 64 bits, + - must start with letters and cannot contain ','(comma) ':'(colon) ' '(space) ';'(semicolon) '\\'(backslash). + - Required when I(server_auth=enable). + type: str + server_password: + description: + - SMTP server Password,lenth be 4 to 64 bits,cannot contain ' '(space). + - Required when I(server_auth=enable). + type: str + ssl_tls_enable: + description: + - SMTP SSLTLS Enable. + - I(ssl_tls_enable=disable), when I(star_tls_enable=enable). + choices: ['enable', 'disable'] + type: str + star_tls_enable: + description: + - SMTP STARTTLS Enable. + - I(star_tls_enable=disable), when I(ssl_tls_enable=enable). + choices: ['enable', 'disable'] + type: str + subject: + description: + - Email theme. + type: str + host_name: + description: + - Server name. + type: str + serial_number: + description: + - Serial number. + type: str + asset_tag: + description: + - product asset label, + type: str + event_level: + description: + - Events above this level will be sent. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Smtp com test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set smtp com information" + inspur.ispim.edit_smtp_com: + status: "disable" + provider: "{{ ism }}" + + - name: "Set smtp com information" + inspur.ispim.edit_smtp_com: + status: "enable" + server_ip: "100.2.2.2" + email: "inspur@Inspur.com" + server_auth: "enable" + server_username: "admin" + server_password: "1234qwer!@#$" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SMTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsmtpcom' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + status=dict(type='str', required=True, choices=['enable', 'disable']), + server_ip=dict(type='str', required=False), + server_port=dict(type='int', required=False), + server_secure_port=dict(type='int', required=False), + email=dict(type='str', required=False), + server_auth=dict(type='str', required=False, choices=['enable', 'disable']), + server_username=dict(type='str', required=False), + server_password=dict(type='str', required=False, no_log=True), + ssl_tls_enable=dict(type='str', required=False, choices=['enable', 'disable']), + star_tls_enable=dict(type='str', required=False, choices=['enable', 'disable']), + subject=dict(type='str', required=False), + host_name=dict(type='str', required=False), + serial_number=dict(type='str', required=False), + asset_tag=dict(type='str', required=False), + event_level=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + smtp_obj = SMTP(argument_spec) + smtp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_dest.py b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_dest.py new file mode 100644 index 000000000..4f0c15eb1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_smtp_dest.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_smtp_dest +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set SMTP information +description: + - Set SMTP dest information on Inspur server. + - Only the M6 models support this feature. +notes: + - Does not support C(check_mode). +options: + id: + description: + - Email destination id. + choices: [1, 2, 3, 4] + type: int + required: true + status: + description: + - Email enable. + choices: ['enable', 'disable'] + type: str + address: + description: + - Email address. + type: str + description: + description: + - Description information. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Smtp dest test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set smtp dest information" + inspur.ispim.edit_smtp_dest: + id: 1 + status: "disable" + provider: "{{ ism }}" + + - name: "Set smtp dest information" + inspur.ispim.edit_smtp_dest: + id: 1 + status: "enable" + address: "100.2.2.2" + description": "test" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SMTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsmtpdest' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + id=dict(type='int', required=True, choices=[1, 2, 3, 4]), + status=dict(type='str', required=False, choices=['enable', 'disable']), + address=dict(type='str', required=False), + description=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + smtp_obj = SMTP(argument_spec) + smtp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_snmp.py b/ansible_collections/inspur/ispim/plugins/modules/edit_snmp.py new file mode 100644 index 000000000..9c11452e4 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_snmp.py @@ -0,0 +1,188 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_snmp +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set snmp +description: + - Set snmp on Inspur server. +notes: + - Does not support C(check_mode). +options: + version: + description: + - SNMP trap version option, 0 - 'v1', 1 - 'v2c', 2 - 'v3', 3 - 'all', 4 - 'customize'. + - Only the M5 models support this feature. + choices: [0, 1, 2, 3, 4] + type: int + snmp_status: + description: + - NMP read/write status of customize, + - the input parameters are 'v1get', 'v1set', 'v2cget', 'v2cset', 'v3get', 'v3set',separated by commas,such as v1get,v1set,v2cget. + - Only the M5 models support this feature. + type: list + elements: str + community: + description: + - Community of v1/v2c or v1get/v1set/v2cget/v2cset. + - Only the M5 models support this feature. + type: str + v1status: + description: + - SNMP V1 enable. + choices: ['enable', 'disable'] + type: str + v2status: + description: + - SNMP V2 enable. + choices: ['enable', 'disable'] + type: str + v3status: + description: + - SNMP V3 enable. + choices: ['enable', 'disable'] + type: str + read_community: + description: + - Read Only Community,Community should between 1 and 16 characters. + - Only the M6 models support this feature. + type: str + read_write_community: + description: + - Read And Write Community,Community should between 1 and 16 characters. + - Only the M6 models support this feature. + type: str + v3username: + description: + - Set user name of V3 trap or v3get/v3set. + type: str + auth_protocol: + description: + - Choose authentication of V3 trap or v3get/v3set. + choices: ['NONE', 'SHA', 'MD5'] + type: str + auth_password: + description: + - Set auth password of V3 trap or v3get/v3set, + - Password is a string of 8 to 16 alpha-numeric characters. + - Required when I(auth_protocol) is either C(SHA) or C(MD5). + type: str + priv_protocol: + description: + - Choose Privacy of V3 trap or v3get/v3set. + choices: ['NONE', 'DES', 'AES'] + type: str + priv_password: + description: + - Set privacy password of V3 trap or v3get/v3set, + - password is a string of 8 to 16 alpha-numeric characters. + - Required when I(priv_protocol) is either C(DES) or C(AES). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Snmp test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set snmp get/set" + inspur.ispim.edit_snmp: + community: "test" + v3username: "Inspur" + provider: "{{ ism }}" + +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsnmp' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + version=dict(type='int', required=False, choices=[0, 1, 2, 3, 4]), + snmp_status=dict(type='list', elements='str', required=False), + community=dict(type='str', required=False), + v1status=dict(type='str', required=False, choices=['enable', 'disable']), + v2status=dict(type='str', required=False, choices=['enable', 'disable']), + v3status=dict(type='str', required=False, choices=['enable', 'disable']), + read_community=dict(type='str', required=False), + read_write_community=dict(type='str', required=False), + v3username=dict(type='str', required=False), + auth_protocol=dict(type='str', required=False, choices=['NONE', 'SHA', 'MD5']), + auth_password=dict(type='str', required=False, no_log=True), + priv_protocol=dict(type='str', required=False, choices=['NONE', 'DES', 'AES']), + priv_password=dict(type='str', required=False, no_log=True), + ) + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_snmp_trap.py b/ansible_collections/inspur/ispim/plugins/modules/edit_snmp_trap.py new file mode 100644 index 000000000..9e916cf66 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_snmp_trap.py @@ -0,0 +1,215 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_snmp_trap +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set snmp trap +description: + - Set snmp trap on Inspur server. +notes: + - Does not support C(check_mode). +options: + version: + description: + - SNMP trap version,1 is v1,2 is v2c(v2),3 is v3,0 is disable snmp trap. + - Only the M6 model supports C(0) Settings. + choices: [0, 1, 2, 3] + type: int + event_severity: + description: + - Event Severity. + choices: ['all', 'warning', 'critical'] + type: str + community: + description: + - Community of v1/v2c. + type: str + host_id: + description: + - Host id. + - Only the M6 model supports this parameter. + choices: ['HostName', 'SerialNum', 'AssertTag'] + type: str + v3username: + description: + - Set user name of V3 trap. + type: str + engine_id: + description: + - Set Engine ID of V3 trap, engine ID is a string of 10 to 48 hex characters, must even, can set NULL. + type: str + auth_protocol: + description: + - Choose authentication. + choices: ['NONE', 'SHA', 'MD5'] + type: str + auth_password: + description: + - Set auth password of V3 trap, password is a string of 8 to 16 alpha-numeric characters. + - Required when I(auth_protocol) is either C(SHA) or C(MD5). + type: str + priv_protocol: + description: + - Choose Privacy. + choices: ['NONE', 'DES', 'AES'] + type: str + priv_password: + description: + - Set privacy password of V3 trap, password is a string of 8 to 16 alpha-numeric characters. + - Required when I(priv_protocol) is either C(DES) or C(AES). + type: str + system_name: + description: + - Set system name, can set NULL. + - Only the M5 model supports this parameter. + type: str + system_id: + description: + - Set system ID, can set NULL. + - Only the M5 model supports this parameter. + type: str + location: + description: + - Set host Location, can set NULL. + - Only the M5 model supports this parameter. + type: str + contact: + description: + - Set contact, can set NULL. + - Only the M5 model supports this parameter. + type: str + os: + description: + - Set host OS, can set NULL. + - Only the M5 model supports this parameter. + type: str + trap_port: + description: + - Set SNMP trap Port(1-65535). + - Only the M5 model supports this parameter. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Trap test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set snmp trap v2c" + inspur.ispim.edit_snmp_trap: + version: 2 + event_severity: "warning" + inspur: "test" + system_name: "Inspur" + provider: "{{ ism }}" + + - name: "Set snmp trap v3" + inspur.ispim.edit_snmp_trap: + version: 3 + event_severity: "all" + v3username: "Inspur" + engine_id: "1234567890" + auth_protocol: "SHA" + auth_password: "12345678" + priv_protocol: "AES" + priv_password: "123454678" + trap_port: 162 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setsnmptrap' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + version=dict(type='int', required=False, choices=[0, 1, 2, 3]), + event_severity=dict(type='str', required=False, choices=['all', 'warning', 'critical']), + community=dict(type='str', required=False), + host_id=dict(type='str', required=False, choices=['HostName', 'SerialNum', 'AssertTag']), + v3username=dict(type='str', required=False), + engine_id=dict(type='str', required=False), + auth_protocol=dict(type='str', required=False, choices=['NONE', 'SHA', 'MD5']), + auth_password=dict(type='str', required=False, no_log=True), + priv_protocol=dict(type='str', required=False, choices=['NONE', 'DES', 'AES']), + priv_password=dict(type='str', required=False, no_log=True), + system_name=dict(type='str', required=False), + system_id=dict(type='str', required=False), + location=dict(type='str', required=False), + contact=dict(type='str', required=False), + os=dict(type='str', required=False), + trap_port=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_threshold.py b/ansible_collections/inspur/ispim/plugins/modules/edit_threshold.py new file mode 100644 index 000000000..1d3e1f09c --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_threshold.py @@ -0,0 +1,141 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_threshold +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set threshold information +description: + - Set threshold information on Inspur server. +notes: + - Does not support C(check_mode). +options: + name: + description: + - Sensor name. + type: str + required: true + lnr: + description: + - Lower non recoverable threshold,should be integer. + type: int + lc: + description: + - Lower critical threshold,should be integer. + type: int + lnc: + description: + - Lower non critical threshold,should be integer. + type: int + unc: + description: + - Up non critical threshold,should be integer. + type: int + uc: + description: + - Up critical threshold,should be integer. + type: int + unr: + description: + - Up non recoverable threshold,should be integer. + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Threshold test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set threshold information" + inspur.ispim.edit_threshold: + name: "GPU1_Temp" + uc: 94 + unc: 92 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Threshold(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setthreshold' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + name=dict(type='str', required=True), + lnr=dict(type='int', required=False), + lc=dict(type='int', required=False), + lnc=dict(type='int', required=False), + unc=dict(type='int', required=False), + uc=dict(type='int', required=False), + unr=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + threshoold_obj = Threshold(argument_spec) + threshoold_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_uid.py b/ansible_collections/inspur/ispim/plugins/modules/edit_uid.py new file mode 100644 index 000000000..264f7d099 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_uid.py @@ -0,0 +1,121 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_uid +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set UID +description: + - Set UID on Inspur server. +notes: + - Does not support C(check_mode). +options: + led: + description: + - Turn on or turn off the led. + choices: ['on', 'off'] + type: str + required: true + time: + description: + - Set led blink time(second). + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: UID test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set uid" + inspur.ispim.edit_uid: + led: "on" + time: 10 + provider: "{{ ism }}" + + - name: "Set uid" + inspur.ispim.edit_uid: + led: "off" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class UID(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setuid' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + led=dict(type='str', required=True, choices=['on', 'off']), + time=dict(type='int', required=False), + ) + argument_spec.update(ism_argument_spec) + uid_obj = UID(argument_spec) + uid_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_virtual_media.py b/ansible_collections/inspur/ispim/plugins/modules/edit_virtual_media.py new file mode 100644 index 000000000..4c9e34563 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_virtual_media.py @@ -0,0 +1,182 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_virtual_media +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set virtual media +description: + - Set virtual media on Inspur server. +notes: + - Does not support C(check_mode). +options: + local_media_support: + description: + - To enable or disable Local Media Support,check or uncheck the checkbox respectively. + - Only the M5 model supports this parameter. + choices: ['Enable', 'Disable'] + type: str + remote_media_support: + description: + - To enable or disable Remote Media support,check or uncheck the checbox respectively. + choices: ['Enable', 'Disable'] + type: str + mount_type: + description: + - Virtual mount type. + - The I(FD) option is not supported in M6. + choices: ['CD', 'FD', 'HD'] + type: str + same_settings: + description: + - Same settings with CD,0 is No,1 is Yes. + - Required when I(mount_type=0). + choices: [0, 1] + type: int + mount: + description: + - Whether to mount virtual media. + - Only the M5 model supports this parameter. + choices: ['Enable', 'Disable'] + type: str + remote_server_address: + description: + - Address of the server where the remote media images are stored. + type: str + remote_source_path: + description: + - Source path to the remote media images.. + type: str + remote_share_type: + description: + - Share Type of the remote media server either NFS or Samba(CIFS). + choices: ['nfs', 'cifs'] + type: str + remote_domain_name: + description: + - Remote Domain Name,Domain Name field is optional. + type: str + remote_user_name: + description: + - Remote User Name. + - Required when I(remote_share_type=cifs). + type: str + remote_password: + description: + - Remote Password. + - Required when I(remote_share_type=cifs). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Media test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set local media" + inspur.ispim.edit_virtual_media: + local_media_support: "Enable" + provider: "{{ ism }}" + + - name: "Set remote media" + inspur.ispim.edit_virtual_media: + remote_media_support: "Enable" + mount_type: 'CD' + same_settings: 0 + mount: "Enable" + remote_server_address: "100.2.28.203" + remote_source_path: "/data/nfs/server/" + remote_share_type: "nfs" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Media(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setvirtualmedia' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + local_media_support=dict(type='str', required=False, choices=['Enable', 'Disable']), + remote_media_support=dict(type='str', required=False, choices=['Enable', 'Disable']), + mount_type=dict(type='str', required=False, choices=['CD', 'FD', 'HD']), + same_settings=dict(type='int', required=False, choices=[0, 1]), + mount=dict(type='str', required=False, choices=['Enable', 'Disable']), + remote_server_address=dict(type='str', required=False), + remote_source_path=dict(type='str', required=False), + remote_share_type=dict(type='str', required=False, choices=['nfs', 'cifs']), + remote_domain_name=dict(type='str', required=False), + remote_user_name=dict(type='str', required=False), + remote_password=dict(type='str', required=False, no_log=True), + ) + argument_spec.update(ism_argument_spec) + media_obj = Media(argument_spec) + media_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/edit_vlan.py b/ansible_collections/inspur/ispim/plugins/modules/edit_vlan.py new file mode 100644 index 000000000..fce4ac7df --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/edit_vlan.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: edit_vlan +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Set vlan information +description: + - Set vlan information on Inspur server. +notes: + - Does not support C(check_mode). +options: + interface_name: + description: + - Set interface_name. + choices: ['eth0', 'eth1', 'bond0'] + required: true + type: str + vlan_status: + description: + - Enable or disable vlan. + choices: ['enable', 'disable'] + type: str + vlan_id: + description: + - The Identification for VLAN configuration(2-4094). + type: int + vlan_priority: + description: + - The priority for VLAN configuration(1-7). + type: int +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Vlan test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Set vlan information" + inspur.ispim.edit_vlan: + interface_name: "eth0" + vlan_status: "disable" + provider: "{{ ism }}" + + - name: "Set vlan information" + inspur.ispim.edit_vlan: + interface_name: "eth0" + vlan_status: "enable" + vlan_id: 2 + vlan_priority: 1 + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Network(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'setvlan' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + interface_name=dict(type='str', required=True, choices=['eth0', 'eth1', 'bond0']), + vlan_status=dict(type='str', required=False, choices=['enable', 'disable']), + vlan_id=dict(type='int', required=False), + vlan_priority=dict(type='int', required=False), + + ) + argument_spec.update(ism_argument_spec) + net_obj = Network(argument_spec) + net_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/event_log_info.py b/ansible_collections/inspur/ispim/plugins/modules/event_log_info.py new file mode 100644 index 000000000..2e3e179b2 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/event_log_info.py @@ -0,0 +1,126 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: event_log_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get event log information +description: + - Get event log information on Inspur server. +notes: + - Supports C(check_mode). +options: + log_time: + description: + - Get logs after the specified date, time should be YYYY-MM-DDTHH:MM+HH:MM, like 2019-06-27T12:30+08:00. + type: str + count: + description: + - Get the most recent log of a specified number. + type: int + event_file: + description: + - Store logs to a file. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Event log info test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get event log information" + inspur.ispim.event_log_info: + log_time: "2020-06-01T12:30+08:00" + provider: "{{ ism }}" + + - name: "Get event log information" + inspur.ispim.event_log_info: + count: 30 + provider: "{{ ism }}" + + - name: "Get event log information" + inspur.ispim.event_log_info: + event_file: "/home/wbs/wbs.log" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class EventLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'geteventlog' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + log_time=dict(type='str', required=False), + count=dict(type='int', required=False), + event_file=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + log_obj = EventLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/event_log_policy_info.py b/ansible_collections/inspur/ispim/plugins/modules/event_log_policy_info.py new file mode 100644 index 000000000..67d634a9d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/event_log_policy_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: event_log_policy_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get event log policy information +description: + - Get event log policy information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Event log policy test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get event log policy information" + inspur.ispim.event_log_policy_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Log(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'geteventlogpolicy' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + log_obj = Log(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/fan_info.py b/ansible_collections/inspur/ispim/plugins/modules/fan_info.py new file mode 100644 index 000000000..4afdf4048 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/fan_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: fan_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get fan information +description: + - Get fan information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Fan test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get fan information" + inspur.ispim.fan_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Fan(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getfan' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + fan_obj = Fan(argument_spec) + fan_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/fru_info.py b/ansible_collections/inspur/ispim/plugins/modules/fru_info.py new file mode 100644 index 000000000..066aa9001 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/fru_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: fru_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get fru information +description: + - Get fru information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Fru info test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get fru information" + inspur.ispim.fru_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Fru(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getfru' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + fru_obj = Fru(argument_spec) + fru_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/fw_version_info.py b/ansible_collections/inspur/ispim/plugins/modules/fw_version_info.py new file mode 100644 index 000000000..cf02fe471 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/fw_version_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: fw_version_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get firmware version information +description: + - Get firmware version information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Firmware version test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get firmware version information" + inspur.ispim.fw_version_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class FwVersion(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getfw' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + fw_obj = FwVersion(argument_spec) + fw_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/gpu_info.py b/ansible_collections/inspur/ispim/plugins/modules/gpu_info.py new file mode 100644 index 000000000..b177c57ea --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/gpu_info.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: gpu_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get GPU information +description: + - Get GPU information on Inspur server. + - Only the M6 models support this feature. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: GPU test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get gpu information" + inspur.ispim.gpu_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class CPU(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getgpu' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + cpu_obj = CPU(argument_spec) + cpu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/hard_disk_info.py b/ansible_collections/inspur/ispim/plugins/modules/hard_disk_info.py new file mode 100644 index 000000000..90732b0a4 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/hard_disk_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: hard_disk_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get hard disk information +description: + - Get hard disk information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Hard disk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get hard disk information" + inspur.ispim.hard_disk_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Harddisk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getharddisk' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + disk_obj = Harddisk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/kvm_info.py b/ansible_collections/inspur/ispim/plugins/modules/kvm_info.py new file mode 100644 index 000000000..5b77e37ca --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/kvm_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: kvm_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get KVM information +description: + - Get KVM information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: KVM test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get KVM information" + inspur.ispim.kvm_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class KVM(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getkvm' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + kvm_obj = KVM(argument_spec) + kvm_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ldap_group.py b/ansible_collections/inspur/ispim/plugins/modules/ldap_group.py new file mode 100644 index 000000000..ae969d134 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ldap_group.py @@ -0,0 +1,158 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ldap_group +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Manage ldap group information +description: + - Manage ldap group information on Inspur server. +notes: + - Does not support C(check_mode). +options: + state: + description: + - Whether the ldap group should exist or not, taking action if the state is different from what is stated. + choices: ['present', 'absent'] + default: present + type: str + name: + description: + - Group name. + type: str + required: true + base: + description: + - Search Base. + type: str + pri: + description: + - Group privilege. + choices: ['administrator', 'user', 'operator', 'oem', 'none'] + type: str + kvm: + description: + - Kvm privilege. + choices: ['enable', 'disable'] + type: str + vm: + description: + - Vmedia privilege. + choices: ['enable', 'disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ldap group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Add ldap group information" + inspur.ispim.ldap_group: + state: "present" + name: "wbs" + base: "cn=manager" + pri: "administrator" + kvm: "enable" + vm: "disable" + provider: "{{ ism }}" + + - name: "Set ldap group information" + inspur.ispim.ldap_group: + state: "present" + name: "wbs" + pri: "user" + kvm: "disable" + provider: "{{ ism }}" + + - name: "Delete ldap group information" + inspur.ispim.ldap_group: + state: "absent" + name: "wbs" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LDAP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'editldapgroup' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + state=dict(type='str', choices=['present', 'absent'], default='present'), + name=dict(type='str', required=True), + base=dict(type='str', required=False), + pri=dict(type='str', required=False, choices=['administrator', 'user', 'operator', 'oem', 'none']), + kvm=dict(type='str', required=False, choices=['enable', 'disable']), + vm=dict(type='str', required=False, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + ldap_obj = LDAP(argument_spec) + ldap_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ldap_group_info.py b/ansible_collections/inspur/ispim/plugins/modules/ldap_group_info.py new file mode 100644 index 000000000..780339baf --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ldap_group_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ldap_group_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get ldap group information +description: + - Get ldap group information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ldap group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get ldap group information" + inspur.ispim.ldap_group_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LDAP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getldapgroup' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ldap_obj = LDAP(argument_spec) + ldap_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ldap_info.py b/ansible_collections/inspur/ispim/plugins/modules/ldap_info.py new file mode 100644 index 000000000..1feb00254 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ldap_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ldap_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get ldap information +description: + - Get ldap information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ldap test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get ldap information" + inspur.ispim.ldap_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LDAP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getldap' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ldap_obj = LDAP(argument_spec) + ldap_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ldisk_info.py b/ansible_collections/inspur/ispim/plugins/modules/ldisk_info.py new file mode 100644 index 000000000..b186897bb --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ldisk_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ldisk_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get logical disks information +description: + - Get logical disks information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Ldisk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get logical disks information" + inspur.ispim.ldisk_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getldisk' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/log_setting_info.py b/ansible_collections/inspur/ispim/plugins/modules/log_setting_info.py new file mode 100644 index 000000000..bde294d3d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/log_setting_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: log_setting_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get bmc log setting information +description: + - Get bmc log setting information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bmc log setting test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bmc log setting information" + inspur.ispim.log_setting_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class LogSetting(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getbmclogsettings' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + cpu_obj = LogSetting(argument_spec) + cpu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/media_instance_info.py b/ansible_collections/inspur/ispim/plugins/modules/media_instance_info.py new file mode 100644 index 000000000..ed32d3d1b --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/media_instance_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: media_instance_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get Virtual Media Instance information +description: + - Get Virtual Media Instance information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Media instance test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get Virtual Media Instance information" + inspur.ispim.media_instance_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Instance(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getmediainstance' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + instance_obj = Instance(argument_spec) + instance_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/mem_info.py b/ansible_collections/inspur/ispim/plugins/modules/mem_info.py new file mode 100644 index 000000000..47a9f0c8f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/mem_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: mem_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get memory information +description: + - Get memory information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Memory test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get memory information" + inspur.ispim.mem_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Memory(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getmemory' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + mem_obj = Memory(argument_spec) + mem_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ncsi_info.py b/ansible_collections/inspur/ispim/plugins/modules/ncsi_info.py new file mode 100644 index 000000000..3e01d764e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ncsi_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ncsi_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get ncsi information +description: + - Get ncsi information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: NCSI test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get ncsi information" + inspur.ispim.ncsi_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class NCSI(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getncsi' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ncsi_obj = NCSI(argument_spec) + ncsi_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/network_bond_info.py b/ansible_collections/inspur/ispim/plugins/modules/network_bond_info.py new file mode 100644 index 000000000..950bf43f4 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/network_bond_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: network_bond_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get network bond information +description: + - Get network bond information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: bond test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get network bond information" + inspur.ispim.network_bond_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Bond(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getnetworkbond' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + bond_obj = Bond(argument_spec) + bond_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/network_info.py b/ansible_collections/inspur/ispim/plugins/modules/network_info.py new file mode 100644 index 000000000..e6c86ac72 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/network_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: network_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get network information +description: + - Get netowrk information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Network test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get network information" + inspur.ispim.network_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Network(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getnetwork' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + net_obj = Network(argument_spec) + net_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/network_link_info.py b/ansible_collections/inspur/ispim/plugins/modules/network_link_info.py new file mode 100644 index 000000000..2568aedcd --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/network_link_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: network_link_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get network link information +description: + - Get network link information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: link test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get network link information" + inspur.ispim.network_link_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Link(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getnetworklink' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + link_obj = Link(argument_spec) + link_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/ntp_info.py b/ansible_collections/inspur/ispim/plugins/modules/ntp_info.py new file mode 100644 index 000000000..ce5b69ddd --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/ntp_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: ntp_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get NTP information +description: + - Get NTP information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: NTP test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get ntp information" + inspur.ispim.ntp_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class NTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'gettime' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + ntp_obj = NTP(argument_spec) + ntp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/onboard_disk_info.py b/ansible_collections/inspur/ispim/plugins/modules/onboard_disk_info.py new file mode 100644 index 000000000..0590bcfd9 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/onboard_disk_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: onboard_disk_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get onboard disks information +description: + - Get onboard disks information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Onboard test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get onboard disks information" + inspur.ispim.onboard_disk_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'gethdddisk' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/pcie_info.py b/ansible_collections/inspur/ispim/plugins/modules/pcie_info.py new file mode 100644 index 000000000..9ae17aa53 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/pcie_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: pcie_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get PCIE information +description: + - Get PCIE information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: PCIE test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get PCIE information" + inspur.ispim.pcie_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class PCIE(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpcie' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + pcie_obj = PCIE(argument_spec) + pcie_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/pdisk_info.py b/ansible_collections/inspur/ispim/plugins/modules/pdisk_info.py new file mode 100644 index 000000000..4da41bf8e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/pdisk_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: pdisk_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get physical disks information +description: + - Get physical disks information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Pdisk test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get physical disks information" + inspur.ispim.pdisk_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Disk(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpdisk' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + disk_obj = Disk(argument_spec) + disk_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/power_budget_info.py b/ansible_collections/inspur/ispim/plugins/modules/power_budget_info.py new file mode 100644 index 000000000..4c6c60372 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/power_budget_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: power_budget_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get power budget information +description: + - Get power budget information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power budget test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get power budget information" + inspur.ispim.power_budget_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpowerbudget' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/power_consumption_info.py b/ansible_collections/inspur/ispim/plugins/modules/power_consumption_info.py new file mode 100644 index 000000000..979f270d5 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/power_consumption_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: power_consumption_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get power consumption information +description: + - Get power consumption information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power consumption test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get power consumption information" + inspur.ispim.power_consumption_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpowerconsumption' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/power_restore_info.py b/ansible_collections/inspur/ispim/plugins/modules/power_restore_info.py new file mode 100644 index 000000000..210eb9eb3 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/power_restore_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: power_restore_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get power restore information +description: + - Get power restore information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power restore test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get power restore information" + inspur.ispim.power_restore_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpowerrestore' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/power_status_info.py b/ansible_collections/inspur/ispim/plugins/modules/power_status_info.py new file mode 100644 index 000000000..d290a939e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/power_status_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: power_status_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get power status information +description: + - Get power status information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Power status test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get power status information" + inspur.ispim.power_status_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Power(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpowerstatus' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + power_obj = Power(argument_spec) + power_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/preserve_config_info.py b/ansible_collections/inspur/ispim/plugins/modules/preserve_config_info.py new file mode 100644 index 000000000..4979d9cbb --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/preserve_config_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: preserve_config_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get preserve config information +description: + - Get preserve config information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: preserve test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get preserve config information" + inspur.ispim.preserve_config_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Preserver(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpreserveconfig' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + pre_obj = Preserver(argument_spec) + pre_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/psu_config_info.py b/ansible_collections/inspur/ispim/plugins/modules/psu_config_info.py new file mode 100644 index 000000000..f2b34f058 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/psu_config_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: psu_config_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get psu config information +description: + - Get psu config information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Psu config test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get psu config information" + inspur.ispim.psu_config_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Psu(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpsuconfig' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + psu_obj = Psu(argument_spec) + psu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/psu_info.py b/ansible_collections/inspur/ispim/plugins/modules/psu_info.py new file mode 100644 index 000000000..a9d93fe66 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/psu_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: psu_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get psu information +description: + - Get psu information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Psu test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get psu information" + inspur.ispim.psu_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Psu(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpsu' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + psu_obj = Psu(argument_spec) + psu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/psu_peak_info.py b/ansible_collections/inspur/ispim/plugins/modules/psu_peak_info.py new file mode 100644 index 000000000..31b31c6ee --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/psu_peak_info.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: psu_peak_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get psu peak information +description: + - Get psu peak information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Psu peak test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get psu peak information" + inspur.ispim.psu_peak_info: + provider: "{{ ism }}" +''' + +RETURN = ''' + +message: + description: messages returned after module execution + returned: always + type: str +state: + description: status after module execution + returned: always + type: str +changed: + description: check to see if a change was made on the device + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Psu(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getpsupeak' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + psu_obj = Psu(argument_spec) + psu_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/raid_info.py b/ansible_collections/inspur/ispim/plugins/modules/raid_info.py new file mode 100644 index 000000000..0c39c6687 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/raid_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: raid_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get RAID/HBA card and controller information +description: + - Get RAID/HBA card and controller information information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Raid test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get raid information" + inspur.ispim.raid_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Raid(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getraid' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + raid_obj = Raid(argument_spec) + raid_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/reset_bmc.py b/ansible_collections/inspur/ispim/plugins/modules/reset_bmc.py new file mode 100644 index 000000000..85b74c9d0 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/reset_bmc.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: reset_bmc +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: BMC reset +description: + - BMC reset on Inspur server. +notes: + - Does not support C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Reset bmc test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Reset bmc" + inspur.ispim.reset_bmc: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Reset(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'resetbmc' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + reset_obj = Reset(argument_spec) + reset_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/reset_kvm.py b/ansible_collections/inspur/ispim/plugins/modules/reset_kvm.py new file mode 100644 index 000000000..b85fe3c4f --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/reset_kvm.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: reset_kvm +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: KVM reset +description: + - KVM reset on Inspur server. +notes: + - Does not support C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Reset kvm test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Reset kvm" + inspur.ispim.reset_kvm: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Reset(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'resetkvm' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + reset_obj = Reset(argument_spec) + reset_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/restore.py b/ansible_collections/inspur/ispim/plugins/modules/restore.py new file mode 100644 index 000000000..400b44617 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/restore.py @@ -0,0 +1,117 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: restore +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Restore server settings +description: + - Restore server settings on Inspur server. +notes: + - Does not support C(check_mode). +options: + bak_file: + description: + - select backup file or bak folder. + required: true + type: str + item: + description: + - select export item. + - Only the M5 model supports this parameter. + choices: ['all', 'network', 'dns', 'service', 'ntp', 'smtp', 'snmptrap', 'ad', 'ldap', 'user','bios'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Restore test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Restore server settings" + inspur.ispim.restore: + bak_file: "/home/wbs/backfile" + item: "all" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Restore(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'restore' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + bak_file=dict(type='str', required=True), + item=dict(type='str', required=False, choices=['all', 'network', 'dns', 'service', 'ntp', 'smtp', 'snmptrap', 'ad', 'ldap', 'user', 'bios']), + ) + argument_spec.update(ism_argument_spec) + restore_obj = Restore(argument_spec) + restore_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/self_test_info.py b/ansible_collections/inspur/ispim/plugins/modules/self_test_info.py new file mode 100644 index 000000000..a0d7dcf14 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/self_test_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: self_test_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get self test information +description: + - Get self test information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: self test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get self test information" + inspur.ispim.self_test_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Test(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getselftest' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + test_obj = Test(argument_spec) + test_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/sensor_info.py b/ansible_collections/inspur/ispim/plugins/modules/sensor_info.py new file mode 100644 index 000000000..5d53912e0 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/sensor_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: sensor_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get sensor information +description: + - Get sensor information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Sensor test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get sensor information" + inspur.ispim.sensor_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Sensor(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsensor' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + sensor_obj = Sensor(argument_spec) + sensor_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/server_info.py b/ansible_collections/inspur/ispim/plugins/modules/server_info.py new file mode 100644 index 000000000..81289e02c --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/server_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: server_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get server status information +description: + - Get server status information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Server test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get server status information" + inspur.ispim.server_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class ServerStatus(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getserver' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + server_obj = ServerStatus(argument_spec) + server_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/service_info.py b/ansible_collections/inspur/ispim/plugins/modules/service_info.py new file mode 100644 index 000000000..7a603c2d5 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/service_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: service_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get service information +description: + - Get service information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Service info test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get service information" + inspur.ispim.service_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Service(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getservice' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + service_obj = Service(argument_spec) + service_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/session_info.py b/ansible_collections/inspur/ispim/plugins/modules/session_info.py new file mode 100644 index 000000000..5cb195928 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/session_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: session_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get online session information +description: + - Get online session information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Session test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get session information" + inspur.ispim.session_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Session(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsessions' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + session_obj = Session(argument_spec) + session_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/smtp_info.py b/ansible_collections/inspur/ispim/plugins/modules/smtp_info.py new file mode 100644 index 000000000..6ec5cebad --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/smtp_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: smtp_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get SMTP information +description: + - Get SMTP information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Smtp test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get smtp information" + inspur.ispim.smtp_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SMTP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsmtp' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + smtp_obj = SMTP(argument_spec) + smtp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/snmp_info.py b/ansible_collections/inspur/ispim/plugins/modules/snmp_info.py new file mode 100644 index 000000000..6a15028f7 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/snmp_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: snmp_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get snmp get/set information +description: + - Get snmp get/set information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Snmp test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get snmp get/set information" + inspur.ispim.snmp_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsnmp' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/snmp_trap_info.py b/ansible_collections/inspur/ispim/plugins/modules/snmp_trap_info.py new file mode 100644 index 000000000..c3c42b5af --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/snmp_trap_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: snmp_trap_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get snmp trap information +description: + - Get snmp trap information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Trap test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get snmp trap information" + inspur.ispim.snmp_trap_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SNMP(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsnmptrap' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + snmp_obj = SNMP(argument_spec) + snmp_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/support_info.py b/ansible_collections/inspur/ispim/plugins/modules/support_info.py new file mode 100644 index 000000000..2060e7ee7 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/support_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: support_info +version_added: "1.3.0" +author: + - WangBaoshan (@ispim) +short_description: Get support information +description: + - Get the Inspur server support list information. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: support list test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get support information" + inspur.ispim.support_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Support(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'support_model' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + support_obj = Support(argument_spec) + support_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/system_log_info.py b/ansible_collections/inspur/ispim/plugins/modules/system_log_info.py new file mode 100644 index 000000000..c7da87df4 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/system_log_info.py @@ -0,0 +1,134 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: system_log_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get BMC system log information +description: + - Get BMC system log information on Inspur server. +notes: + - Supports C(check_mode). +options: + level: + description: + - Log level. + default: alert + choices: ['alert', 'critical', 'error', 'notice', 'warning', 'debug', 'emergency', 'info'] + type: str + log_time: + description: + - Get logs after the specified date, time should be YYYY-MM-DDTHH:MM+HH:MM, like 2019-06-27T12:30+08:00. + type: str + count: + description: + - Get the most recent log of a specified number. + type: int + system_file: + description: + - Store logs to a file. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Bmc system log info test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get bmc system log information" + inspur.ispim.system_log_info: + level: "alert" + log_time: "2020-06-01T12:30+08:00" + provider: "{{ ism }}" + + - name: "Get bmc system log information" + inspur.ispim.system_log_info: + count: 30 + provider: "{{ ism }}" + + - name: "Get bmc system log information" + inspur.ispim.system_log_info: + system_file: "/home/wbs/wbs.log" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class SystemLog(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getsystemlog' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + level=dict(type='str', default='alert', choices=['alert', 'critical', 'error', 'notice', 'warning', 'debug', 'emergency', 'info']), + log_time=dict(type='str', required=False), + count=dict(type='int', required=False), + system_file=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + log_obj = SystemLog(argument_spec) + log_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/temp_info.py b/ansible_collections/inspur/ispim/plugins/modules/temp_info.py new file mode 100644 index 000000000..0a7e97103 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/temp_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: temp_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get temp information +description: + - Get temp information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Temp test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get temp information" + inspur.ispim.temp_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Sensor(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'gettemp' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + sensor_obj = Sensor(argument_spec) + sensor_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/threshold_info.py b/ansible_collections/inspur/ispim/plugins/modules/threshold_info.py new file mode 100644 index 000000000..1ddbc50e3 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/threshold_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: threshold_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get threshold information +description: + - Get threshold information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Threshold test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get threshold information" + inspur.ispim.threshold_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Threshold(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getthreshold' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + threshoold_obj = Threshold(argument_spec) + threshoold_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/uid_info.py b/ansible_collections/inspur/ispim/plugins/modules/uid_info.py new file mode 100644 index 000000000..d45b25dd1 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/uid_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: uid_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get UID information +description: + - Get UID information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: UID test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get UID information" + inspur.ispim.uid_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class UID(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getuid' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + uid_obj = UID(argument_spec) + uid_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/update_cpld.py b/ansible_collections/inspur/ispim/plugins/modules/update_cpld.py new file mode 100644 index 000000000..dd04bf4cf --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/update_cpld.py @@ -0,0 +1,130 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: update_cpld +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Update CPLD +description: + - Update CPLD on Inspur server. +notes: + - Does not support C(check_mode). +options: + list: + description: + - Get cpld list. + - Only the M5 model supports this parameter. + choices: [True, False] + default: False + type: bool + id: + description: + - CPLD id. + - Required when I(list=False). + - Only the M5 model supports this parameter. + type: int + file_url: + description: + - CPLD image file path. + - Required when I(list=False). + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: CPLD test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get cpld list" + inspur.ispim.update_cpld: + list: True + provider: "{{ ism }}" + + - name: "Update cpld" + update_cpld: + id: 1 + file_url: "home/wbs/raw.bin" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class CPLD(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'updatecpld' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + list=dict(type='bool', default=False, choices=[True, False]), + id=dict(type='int', required=False), + file_url=dict(type='str', required=False), + ) + argument_spec.update(ism_argument_spec) + cpld_obj = CPLD(argument_spec) + cpld_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/update_fw.py b/ansible_collections/inspur/ispim/plugins/modules/update_fw.py new file mode 100644 index 000000000..e0090051d --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/update_fw.py @@ -0,0 +1,154 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: update_fw +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Update firmware +description: + - Update firmware on Inspur server. +notes: + - Does not support C(check_mode). +options: + url: + description: + - Firmware image url. + required: true + type: str + mode: + description: + - active mode, Manual or Auto(default). + default: Auto + choices: ['Auto', 'Manual'] + type: str + type: + description: + - Firmware type. + choices: ['BMC', 'BIOS'] + type: str + over_ride: + description: + - Reserve Configrations,0-reserve, 1-override. + default: 0 + choices: [0, 1] + type: int + has_me: + description: + - (M5-BIOS)update me or not when update bios,only work in INTEL platform,0-no,1-yes. + - Only the M5 model supports this parameter. + default: 1 + choices: [0, 1] + type: int + dual_image: + description: + - (M5)update dual image(default) or not. + - Only the M5 model supports this parameter. + default: dual + choices: ['single', 'dual'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Update fw test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "update bios" + inspur.ispim.update_fw: + url: "/home/wbs/SA5112M5_BIOS_4.1.8_Standard_20200117.bin" + type: "BIOS" + provider: "{{ ism }}" + + - name: "update bmc" + inspur.ispim.update_fw: + url: "/home/wbs/SA5112M5_BMC_4.17.7_Standard_20200430" + mode: "Auto" + type: "BMC" + dual_image: "dual" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Update(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'fwupdate' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + url=dict(type='str', required=True), + mode=dict(type='str', default='Auto', choices=['Auto', 'Manual']), + over_ride=dict(type='int', default=0, choices=[0, 1]), + type=dict(type='str', required=False, choices=['BMC', 'BIOS']), + has_me=dict(type='int', default=1, choices=[0, 1]), + dual_image=dict(type='str', default='dual', choices=['single', 'dual']), + ) + argument_spec.update(ism_argument_spec) + update_obj = Update(argument_spec) + update_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/user.py b/ansible_collections/inspur/ispim/plugins/modules/user.py new file mode 100644 index 000000000..8d27c2d20 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/user.py @@ -0,0 +1,165 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: user +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Manage user +description: + - Manage user on Inspur server. +notes: + - Does not support C(check_mode). +options: + state: + description: + - Whether the user should exist or not, taking action if the state is different from what is stated. + choices: ['present', 'absent'] + default: present + type: str + uid: + description: + - User id,The range is 1 to 16. + type: int + uname: + description: + - User name,Required when uid is None. + type: str + upass: + description: + - User password. + type: str + role_id: + description: + - user group. + - default user group 'Administrator', 'Operator', 'User'. + - use command C(user_group_info) can get all group information. + type: str + access: + description: + - User access. + choices: ['enable', 'disable'] + type: str + priv: + description: + - Other user permissions, select one or more from None/KVM/VMM/SOL. + choices: ['kvm', 'vmm', 'sol', 'none'] + type: list + elements: str + email: + description: + - User email. + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: User test + hosts: ism + no_log: true + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Add user" + inspur.ispim.user: + state: "present" + uname: "wbs" + upass: "admin" + role_id: "Administrator" + priv: "kvm,sol" + email: "wbs@inspur.com" + provider: "{{ ism }}" + + - name: "Set user" + inspur.ispim.user: + state: "present" + uname: "wbs" + upass: "12345678" + role_id: "user" + priv: "kvm,sol" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class User(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'edituser' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + state=dict(type='str', choices=['present', 'absent'], default='present'), + uid=dict(type='int', required=False), + uname=dict(type='str', required=False), + upass=dict(type='str', required=False, no_log=True), + role_id=dict(type='str', required=False), + access=dict(type='str', required=False, choices=['enable', 'disable']), + priv=dict(type='list', elements='str', required=False, choices=['kvm', 'vmm', 'sol', 'none']), + email=dict(type='str', required=False) + ) + argument_spec.update(ism_argument_spec) + user_obj = User(argument_spec) + user_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/user_group.py b/ansible_collections/inspur/ispim/plugins/modules/user_group.py new file mode 100644 index 000000000..f1e426037 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/user_group.py @@ -0,0 +1,204 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright(C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: user_group +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Manage user group +description: + - Manage user group on Inspur server. +notes: + - Does not support C(check_mode). +options: + state: + description: + - Whether the user group should exist or not, taking action if the state is different from what is stated. + choices: ['present', 'absent'] + default: present + type: str + name: + description: + - Group name. + - The range of group name for M6 model is OEM1,OEM2,OEM3,OEM4. + required: true + type: str + pri: + description: + - Group privilege. + - Required when I(state=present). + - Only the M5 model supports this parameter. + choices: ['administrator', 'operator', 'user', 'oem', 'none'] + type: str + general: + description: + - General configuration privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + power: + description: + - Power control privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + media: + description: + - Remote media configuration privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + kvm: + description: + - Remote KVM configuration privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + security: + description: + - Security configuration privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + debug: + description: + - Debug diagnose privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str + self: + description: + - Itself configuration privilege. + - Required when I(state=present). + - Only the M6 model supports this parameter. + choices: ['enable', 'disable'] + type: str +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: User group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Add user group" + inspur.ispim.user_group: + state: "present" + name: "test" + pri: "administrator" + provider: "{{ ism }}" + + - name: "Set user group" + inspur.ispim.user_group: + state: "present" + name: "test" + pri: "user" + provider: "{{ ism }}" + + - name: "Set m6 user group" + inspur.ispim.user_group: + state: "present" + name: "OEM1" + general: "enable" + kvm: "enable" + provider: "{{ ism }}" + + - name: "Delete user group" + inspur.ispim.user_group: + state: "absent" + name: "test" + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) +from ansible.module_utils.basic import AnsibleModule + + +class UserGroup(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=False) + + def run_command(self): + self.module.params['subcommand'] = 'editusergroup' + self.results = get_connection(self.module) + if self.results['State'] == 'Success': + self.results['changed'] = True + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict( + state=dict(type='str', choices=['present', 'absent'], default='present'), + name=dict(type='str', required=True), + pri=dict(type='str', required=False, choices=['administrator', 'operator', 'user', 'oem', 'none']), + general=dict(type='str', required=False, choices=['enable', 'disable']), + power=dict(type='str', required=False, choices=['enable', 'disable']), + media=dict(type='str', required=False, choices=['enable', 'disable']), + kvm=dict(type='str', required=False, choices=['enable', 'disable']), + security=dict(type='str', required=False, choices=['enable', 'disable']), + debug=dict(type='str', required=False, choices=['enable', 'disable']), + self=dict(type='str', required=False, choices=['enable', 'disable']), + ) + argument_spec.update(ism_argument_spec) + usergroup_obj = UserGroup(argument_spec) + usergroup_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/user_group_info.py b/ansible_collections/inspur/ispim/plugins/modules/user_group_info.py new file mode 100644 index 000000000..839b6db71 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/user_group_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: user_group_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get user group information +description: + - Get user group information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: User group test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get user group information" + inspur.ispim.user_group_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class UserGroup(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getusergroup' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + usergroup_obj = UserGroup(argument_spec) + usergroup_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/user_info.py b/ansible_collections/inspur/ispim/plugins/modules/user_info.py new file mode 100644 index 000000000..a250977d3 --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/user_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: user_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get user information +description: + - Get user information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: User test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get user information" + inspur.ispim.user_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class User(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getuser' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + user_obj = User(argument_spec) + user_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/virtual_media_info.py b/ansible_collections/inspur/ispim/plugins/modules/virtual_media_info.py new file mode 100644 index 000000000..b0c0f3aaf --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/virtual_media_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: virtual_media_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get Virtual Media information +description: + - Get Virtual Media information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Media test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get Virtual Media information" + inspur.ispim.virtual_media_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Media(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getvirtualmedia' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + media_obj = Media(argument_spec) + media_obj.work() + + +if __name__ == '__main__': + main() diff --git a/ansible_collections/inspur/ispim/plugins/modules/volt_info.py b/ansible_collections/inspur/ispim/plugins/modules/volt_info.py new file mode 100644 index 000000000..b2846241e --- /dev/null +++ b/ansible_collections/inspur/ispim/plugins/modules/volt_info.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- + +# Copyright (C) 2020 Inspur Inc. All Rights Reserved. +# 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 + +DOCUMENTATION = ''' +--- +module: volt_info +version_added: "1.0.0" +author: + - WangBaoshan (@ispim) +short_description: Get volt information +description: + - Get volt information on Inspur server. +notes: + - Supports C(check_mode). +options: {} +extends_documentation_fragment: + - inspur.ispim.ism +''' + +EXAMPLES = ''' +- name: Volt test + hosts: ism + connection: local + gather_facts: no + vars: + ism: + host: "{{ ansible_ssh_host }}" + username: "{{ username }}" + password: "{{ password }}" + + tasks: + + - name: "Get volt information" + inspur.ispim.volt_info: + provider: "{{ ism }}" +''' + +RETURN = ''' +message: + description: Messages returned after module execution. + returned: always + type: str +state: + description: Status after module execution. + returned: always + type: str +changed: + description: Check to see if a change was made on the device. + returned: always + type: bool +''' + +from ansible.module_utils.basic import AnsibleModule +from ansible_collections.inspur.ispim.plugins.module_utils.ism import (ism_argument_spec, get_connection) + + +class Sensor(object): + def __init__(self, argument_spec): + self.spec = argument_spec + self.module = None + self.init_module() + self.results = dict() + + def init_module(self): + """Init module object""" + + self.module = AnsibleModule( + argument_spec=self.spec, supports_check_mode=True) + + def run_command(self): + self.module.params['subcommand'] = 'getvolt' + self.results = get_connection(self.module) + + def show_result(self): + """Show result""" + self.module.exit_json(**self.results) + + def work(self): + """Worker""" + self.run_command() + self.show_result() + + +def main(): + argument_spec = dict() + argument_spec.update(ism_argument_spec) + sensor_obj = Sensor(argument_spec) + sensor_obj.work() + + +if __name__ == '__main__': + main() |