Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct check-mode support declaration #288

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions plugins/module_utils/oneview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2021) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -576,7 +576,7 @@ class OneViewModule(object):
ONEVIEW_VALIDATE_ETAG_ARGS = dict(
validate_etag=dict(type='bool', default=True))

def __init__(self, additional_arg_spec=None, validate_etag_support=False):
def __init__(self, additional_arg_spec=None, validate_etag_support=False, supports_check_mode=False):
"""
OneViewModuleBase constructor.

Expand All @@ -587,7 +587,7 @@ def __init__(self, additional_arg_spec=None, validate_etag_support=False):
additional_arg_spec, validate_etag_support)

self.module = AnsibleModule(
argument_spec=argument_spec, supports_check_mode=True)
argument_spec=argument_spec, supports_check_mode=supports_check_mode)

self.resource_client = None
self.current_resource = None
Expand Down Expand Up @@ -742,7 +742,6 @@ def resource_present(self, fact_name, create_method='create', parameter_to_ignor
Generic implementation of the present state for the OneView resources.

It checks if the resource needs to be created or updated.

:arg str fact_name: Name of the fact returned to the Ansible.
:arg str create_method: Function of the OneView client that will be called for resource creation.
Usually create or add.
Expand Down Expand Up @@ -912,7 +911,7 @@ class OneViewModuleBase(object):
ONEVIEW_VALIDATE_ETAG_ARGS = dict(
validate_etag=dict(type='bool', default=True))

def __init__(self, additional_arg_spec=None, validate_etag_support=False):
def __init__(self, additional_arg_spec=None, validate_etag_support=False, supports_check_mode=False):
"""
OneViewModuleBase constructor.

Expand All @@ -923,7 +922,7 @@ def __init__(self, additional_arg_spec=None, validate_etag_support=False):
additional_arg_spec, validate_etag_support)

self.module = AnsibleModule(
argument_spec=argument_spec, supports_check_mode=True)
argument_spec=argument_spec, supports_check_mode=supports_check_mode)

self._check_hpe_oneview_sdk()
self._create_oneview_client()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -68,7 +68,7 @@

class ApplianceConfigurationTimeconfigFactsModule(OneViewModule):
def __init__(self):
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')))
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')), supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_configuration_timeconfig)

def execute_module(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,7 +129,7 @@ class ApplianceDeviceSnmpV1TrapDestinationsFactsModule(OneViewModule):
)

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_device_snmp_v1_trap_destinations)

def execute_module(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,7 +129,7 @@ class ApplianceDeviceSnmpV3TrapDestinationsFactsModule(OneViewModule):
)

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_device_snmp_v3_trap_destinations)

def execute_module(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
###
# Copyright (2016-2021) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -113,7 +113,7 @@ def __init__(self):
sessionID=dict(required=False, type='str'),
params=dict(required=False, type='dict')
)
super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_device_snmp_v3_users)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_appliance_network_interface_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -100,7 +100,7 @@ class ApplianceNetworkInterfaceFactsModule(OneViewModule):
)

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_network_interfaces)

def execute_module(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,7 +65,7 @@

class ApplianceProxyConfigurationFactsModule(OneViewModule):
def __init__(self):
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')))
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')), supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_proxy_configuration)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_appliance_ssh_access_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,7 @@

class ApplianceSshAccessFactsModule(OneViewModule):
def __init__(self):
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')))
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')), supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_ssh_access)

def execute_module(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -69,7 +69,7 @@

class ApplianceTimeAndLocaleConfigurationFactsModule(OneViewModule):
def __init__(self):
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')))
super().__init__(additional_arg_spec=dict(sessionID=dict(required=False, type='str')), supports_check_mode=True)
self.set_resource_object(self.oneview_client.appliance_time_and_locale_configuration)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_certificates_server_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(self):
remote=dict(required=False, type='str'),
aliasName=dict(required=False, type='str'),
)
super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.resource_client = self.oneview_client.certificates_server

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_connection_template_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(self):
options=dict(required=False, type='list', elements='str'),
params=dict(required=False, type='dict')
)
super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.connection_templates)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_drive_enclosure_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2023) Hewlett Packard Enterprise Development LP
# Copyright (2023-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -134,7 +134,7 @@ class DriveEnclosureFactsModule(OneViewModule):
params=dict(type='dict'))

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.drive_enclosures)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_enclosure_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -166,7 +166,7 @@ class EnclosureFactsModule(OneViewModule):
argument_spec = dict(name=dict(type='str'), sessionID=dict(required=False, type='str'), options=dict(type='list', elements='str'), params=dict(type='dict'))

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.enclosures)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_enclosure_group_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -127,7 +127,7 @@ class EnclosureGroupFactsModule(OneViewModule):
)

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.enclosure_groups)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_ethernet_network_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2019) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -139,7 +139,7 @@ class EthernetNetworkFactsModule(OneViewModule):
)

def __init__(self):
super().__init__(additional_arg_spec=self.argument_spec)
super().__init__(additional_arg_spec=self.argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.ethernet_networks)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_fc_network.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(self):
required=True,
choices=['present', 'absent']))

super().__init__(additional_arg_spec=additional_arg_spec, validate_etag_support=True)
super().__init__(additional_arg_spec=additional_arg_spec, validate_etag_support=True, supports_check_mode=True)

self.set_resource_object(self.oneview_client.fc_networks)
self.connection_templates = self.oneview_client.connection_templates
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_fc_network_facts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,7 +105,7 @@ def __init__(self):
params=dict(required=False, type='dict')
)

super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)

self.resource_client = self.oneview_client.fc_networks

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_fcoe_network_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -109,7 +109,7 @@ def __init__(self):
params=dict(type='dict'),
)

super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.fcoe_networks)

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_firmware_driver_facts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
###
# Copyright (2021) Hewlett Packard Enterprise Development LP
# Copyright (2021-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -145,7 +145,7 @@ def __init__(self):
params=dict(required=False, type='dict')
)

super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.resource_client = self.oneview_client.firmware_drivers

def execute_module(self):
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/oneview_hypervisor_cluster_profile_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
# Copyright (2016-2024) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -140,7 +140,7 @@ def __init__(self):
options=dict(type='list', elements='str'),
params=dict(type='dict')
)
super().__init__(additional_arg_spec=argument_spec)
super().__init__(additional_arg_spec=argument_spec, supports_check_mode=True)
self.set_resource_object(self.oneview_client.hypervisor_cluster_profiles)

def execute_module(self):
Expand Down
Loading
Loading