diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-18 05:52:35 +0000 |
commit | 7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch) | |
tree | efb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/netapp/storagegrid/plugins | |
parent | Releasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff) | |
download | ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip |
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/netapp/storagegrid/plugins')
15 files changed, 134 insertions, 189 deletions
diff --git a/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp.py b/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp.py index 9892ae7b5..eaa7836a5 100644 --- a/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp.py +++ b/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp.py @@ -30,20 +30,9 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import json -import mimetypes -import os -import random +from ansible.module_utils.basic import missing_required_lib -from pprint import pformat -from ansible.module_utils import six -from ansible.module_utils.basic import AnsibleModule, missing_required_lib -from ansible.module_utils.six.moves.urllib.error import HTTPError, URLError -from ansible.module_utils.urls import open_url -from ansible.module_utils.api import basic_auth_argument_spec -from ansible.module_utils._text import to_native - -COLLECTION_VERSION = "21.11.1" +COLLECTION_VERSION = "21.12.0" try: import requests @@ -52,13 +41,6 @@ try: except ImportError: HAS_REQUESTS = False -import ssl - -try: - from urlparse import urlparse, urlunparse -except ImportError: - from urllib.parse import urlparse, urlunparse - POW2_BYTE_MAP = dict( # Here, 1 kb = 1024 @@ -76,7 +58,6 @@ POW2_BYTE_MAP = dict( def na_storagegrid_host_argument_spec(): - return dict( api_url=dict(required=True, type="str"), validate_certs=dict(required=False, type="bool", default=True), diff --git a/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp_module.py b/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp_module.py index f562938cf..4cbf55c2f 100644 --- a/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp_module.py +++ b/ansible_collections/netapp/storagegrid/plugins/module_utils/netapp_module.py @@ -34,8 +34,6 @@ from copy import deepcopy __metaclass__ = type -import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils - def cmp(obj1, obj2): """ @@ -79,14 +77,14 @@ class NetAppModule(object): return self.parameters def get_cd_action(self, current, desired): - """ takes a desired state and a current state, and return an action: - create, delete, None - eg: - is_present = 'absent' - some_object = self.get_object(source) - if some_object is not None: - is_present = 'present' - action = cd_action(current=is_present, desired = self.desired.state()) + """takes a desired state and a current state, and return an action: + create, delete, None + eg: + is_present = 'absent' + some_object = self.get_object(source) + if some_object is not None: + is_present = 'present' + action = cd_action(current=is_present, desired = self.desired.state()) """ if "state" in desired: desired_state = desired["state"] @@ -121,19 +119,19 @@ class NetAppModule(object): @staticmethod def check_keys(current, desired): - ''' TODO: raise an error if keys do not match - with the exception of: - new_name, state in desired - ''' + """TODO: raise an error if keys do not match + with the exception of: + new_name, state in desired + """ def is_rename_action(self, source, target): - """ takes a source and target object, and returns True - if a rename is required - eg: - source = self.get_object(source_name) - target = self.get_object(target_name) - action = is_rename_action(source, target) - :return: None for error, True for rename action, False otherwise + """takes a source and target object, and returns True + if a rename is required + eg: + source = self.get_object(source_name) + target = self.get_object(target_name) + action = is_rename_action(source, target) + :return: None for error, True for rename action, False otherwise """ if source is None and target is None: # error, do nothing @@ -155,14 +153,14 @@ class NetAppModule(object): @staticmethod def compare_lists(current, desired, get_list_diff): - ''' compares two lists and return a list of elements that are either the desired elements or elements that are - modified from the current state depending on the get_list_diff flag - :param: current: current item attribute in ONTAP - :param: desired: attributes from playbook - :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute - :return: list of attributes to be modified - :rtype: list - ''' + """compares two lists and return a list of elements that are either the desired elements or elements that are + modified from the current state depending on the get_list_diff flag + :param: current: current item attribute in ONTAP + :param: desired: attributes from playbook + :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute + :return: list of attributes to be modified + :rtype: list + """ current_copy = deepcopy(current) desired_copy = deepcopy(desired) @@ -192,19 +190,19 @@ class NetAppModule(object): return None def get_modified_attributes(self, current, desired, get_list_diff=False): - ''' takes two dicts of attributes and return a dict of attributes that are - not in the current state - It is expected that all attributes of interest are listed in current and - desired. - :param: current: current attributes on StorageGRID - :param: desired: attributes from playbook - :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute - :return: dict of attributes to be modified - :rtype: dict - NOTE: depending on the attribute, the caller may need to do a modify or a - different operation (eg move volume if the modified attribute is an - aggregate name) - ''' + """takes two dicts of attributes and return a dict of attributes that are + not in the current state + It is expected that all attributes of interest are listed in current and + desired. + :param: current: current attributes on StorageGRID + :param: desired: attributes from playbook + :param: get_list_diff: specifies whether to have a diff of desired list w.r.t current list for an attribute + :return: dict of attributes to be modified + :rtype: dict + NOTE: depending on the attribute, the caller may need to do a modify or a + different operation (eg move volume if the modified attribute is an + aggregate name) + """ # if the object does not exist, we can't modify it modified = {} if current is None: @@ -217,7 +215,9 @@ class NetAppModule(object): for key, value in current.items(): if key in desired and desired[key] is not None: if isinstance(value, list): - modified_list = self.compare_lists(value, desired[key], get_list_diff) # get modified list from current and desired + modified_list = self.compare_lists( + value, desired[key], get_list_diff + ) # get modified list from current and desired if modified_list is not None: modified[key] = modified_list elif isinstance(value, dict): @@ -228,7 +228,9 @@ class NetAppModule(object): try: result = cmp(value, desired[key]) except TypeError as exc: - raise TypeError("%s, key: %s, value: %s, desired: %s" % (repr(exc), key, repr(value), repr(desired[key]))) + raise TypeError( + "%s, key: %s, value: %s, desired: %s" % (repr(exc), key, repr(value), repr(desired[key])) + ) else: if result != 0: modified[key] = desired[key] diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_account.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_account.py index 88943c082..a800a8c67 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_account.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_account.py @@ -39,6 +39,11 @@ options: - Name of the tenant. - Required for create or modify operation. type: str + description: + description: + - Additional identifying information for the tenant account. + type: str + version_added: 21.12.0 account_id: description: - Account Id of the tenant. @@ -63,6 +68,11 @@ options: description: - Allows tenant to use platform services features such as CloudMirror. type: bool + allow_select_object_content: + description: + - Allows tenant to use the S3 SelectObjectContent API to filter and retrieve object data. + type: bool + version_added: 21.12.0 root_access_group: description: - Existing federated group to have initial Root Access permissions for the tenant. @@ -177,13 +187,20 @@ class SgGridAccount(object): self.argument_spec = netapp_utils.na_storagegrid_host_argument_spec() self.argument_spec.update( dict( - state=dict(required=False, type="str", choices=["present", "absent"], default="present"), + state=dict( + required=False, + type="str", + choices=["present", "absent"], + default="present", + ), name=dict(required=False, type="str"), + description=dict(required=False, type="str"), account_id=dict(required=False, type="str"), protocol=dict(required=False, choices=["s3", "swift"]), management=dict(required=False, type="bool", default=True), use_own_identity_source=dict(required=False, type="bool"), allow_platform_services=dict(required=False, type="bool"), + allow_select_object_content=dict(required=False, type="bool"), root_access_group=dict(required=False, type="str"), quota_size=dict(required=False, type="int", default=0), quota_size_unit=dict( @@ -203,9 +220,7 @@ class SgGridAccount(object): type="str", ), password=dict(required=False, type="str", no_log=True), - update_password=dict( - default="on_create", choices=["on_create", "always"] - ), + update_password=dict(default="on_create", choices=["on_create", "always"]), ) ) @@ -232,12 +247,17 @@ class SgGridAccount(object): self.parameters = self.na_helper.set_parameters(self.module.params) # Calling generic SG rest_api class self.rest_api = SGRestAPI(self.module) + # Get API version + self.rest_api.get_sg_product_version() # Checking for the parameters passed and create new parameters list self.data = {} self.data["name"] = self.parameters["name"] self.data["capabilities"] = [self.parameters["protocol"]] + if self.parameters.get("description") is not None: + self.data["description"] = self.parameters["description"] + if self.parameters.get("password") is not None: self.data["password"] = self.parameters["password"] @@ -248,28 +268,19 @@ class SgGridAccount(object): self.data["policy"] = {} if "use_own_identity_source" in self.parameters: - self.data["policy"]["useAccountIdentitySource"] = self.parameters[ - "use_own_identity_source" - ] + self.data["policy"]["useAccountIdentitySource"] = self.parameters["use_own_identity_source"] if "allow_platform_services" in self.parameters: - self.data["policy"]["allowPlatformServices"] = self.parameters[ - "allow_platform_services" - ] + self.data["policy"]["allowPlatformServices"] = self.parameters["allow_platform_services"] if self.parameters.get("root_access_group") is not None: self.data["grantRootAccessToGroup"] = self.parameters["root_access_group"] if self.parameters["quota_size"] > 0: self.parameters["quota_size"] = ( - self.parameters["quota_size"] - * netapp_utils.POW2_BYTE_MAP[ - self.parameters["quota_size_unit"] - ] + self.parameters["quota_size"] * netapp_utils.POW2_BYTE_MAP[self.parameters["quota_size_unit"]] ) - self.data["policy"]["quotaObjectBytes"] = self.parameters[ - "quota_size" - ] + self.data["policy"]["quotaObjectBytes"] = self.parameters["quota_size"] elif self.parameters["quota_size"] == 0: self.data["policy"]["quotaObjectBytes"] = None @@ -277,19 +288,31 @@ class SgGridAccount(object): if self.parameters.get("password") is not None: self.pw_change["password"] = self.parameters["password"] + if "allow_select_object_content" in self.parameters: + self.rest_api.fail_if_not_sg_minimum_version("S3 SelectObjectContent API", 11, 6) + self.data["policy"]["allowSelectObjectContent"] = self.parameters["allow_select_object_content"] + def get_tenant_account_id(self): # Check if tenant account exists # Return tenant account info if found, or None - api = "api/v3/grid/accounts?limit=350" + api = "api/v3/grid/accounts" + params = {"limit": 20} + params["marker"] = "" - list_accounts, error = self.rest_api.get(api) + while params["marker"] is not None: + list_accounts, error = self.rest_api.get(api, params) - if error: - self.module.fail_json(msg=error) + if error: + self.module.fail_json(msg=error) - for account in list_accounts.get("data"): - if account["name"] == self.parameters["name"]: - return account["id"] + if len(list_accounts.get("data")) > 0: + for account in list_accounts["data"]: + if account["name"] == self.parameters["name"]: + return account["id"] + # Set marker to last element + params["marker"] = list_accounts["data"][-1]["id"] + else: + params["marker"] = None return None @@ -351,62 +374,18 @@ class SgGridAccount(object): tenant_account = None if self.parameters.get("account_id"): - tenant_account = self.get_tenant_account( - self.parameters["account_id"] - ) + tenant_account = self.get_tenant_account(self.parameters["account_id"]) else: tenant_account_id = self.get_tenant_account_id() if tenant_account_id: tenant_account = self.get_tenant_account(tenant_account_id) - cd_action = self.na_helper.get_cd_action( - tenant_account, self.parameters - ) + cd_action = self.na_helper.get_cd_action(tenant_account, self.parameters) if cd_action is None and self.parameters["state"] == "present": # let's see if we need to update parameters - update = False - - capability_diff = [ - i - for i in self.data["capabilities"] - + tenant_account["capabilities"] - if i not in self.data["capabilities"] - or i not in tenant_account["capabilities"] - ] - - if self.parameters["quota_size"] > 0: - if ( - tenant_account["policy"]["quotaObjectBytes"] - != self.parameters["quota_size"] - ): - update = True - elif ( - self.parameters["quota_size"] == 0 - and tenant_account["policy"]["quotaObjectBytes"] is not None - ): - update = True - - if ( - "use_own_identity_source" in self.parameters - and tenant_account["policy"]["useAccountIdentitySource"] - != self.parameters["use_own_identity_source"] - ): - update = True - - elif ( - "allow_platform_services" in self.parameters - and tenant_account["policy"]["allowPlatformServices"] - != self.parameters["allow_platform_services"] - ): - update = True - - elif capability_diff: - update = True - - if update: - self.na_helper.changed = True + modify = self.na_helper.get_modified_attributes(tenant_account, self.data) result_message = "" resp_data = tenant_account @@ -423,7 +402,7 @@ class SgGridAccount(object): resp_data = self.create_tenant_account() result_message = "Tenant Account created" - else: + elif modify: resp_data = self.update_tenant_account(tenant_account["id"]) result_message = "Tenant Account updated" @@ -441,9 +420,7 @@ class SgGridAccount(object): results = [result_message, "Tenant Account root password updated"] result_message = "; ".join(filter(None, results)) - self.module.exit_json( - changed=self.na_helper.changed, msg=result_message, resp=resp_data - ) + self.module.exit_json(changed=self.na_helper.changed, msg=result_message, resp=resp_data) def main(): diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_certificate.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_certificate.py index 97f9ab972..4b0aa64bf 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_certificate.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_certificate.py @@ -89,8 +89,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_client_certificate.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_client_certificate.py index aa381b397..a8c36a3df 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_client_certificate.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_client_certificate.py @@ -105,8 +105,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_group.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_group.py index 60592c609..fba212228 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_group.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_group.py @@ -153,7 +153,6 @@ resp: } """ -import json import re import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils @@ -210,7 +209,10 @@ class SgGridGroup(object): "object_metadata": "objectMetadata", "root_access": "rootAccess", } - self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True,) + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True, + ) self.na_helper = NetAppModule() diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_ha_group.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_ha_group.py index c99719c6d..8420620b4 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_ha_group.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_ha_group.py @@ -150,8 +150,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_identity_federation.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_identity_federation.py index 729cf4545..b1d3292e1 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_identity_federation.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_identity_federation.py @@ -164,9 +164,6 @@ resp: } """ -import json -import re - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule @@ -218,7 +215,10 @@ class SgGridIdentityFederation: "ldap_group_uuid_attribute": "ldapGroupUUIDAttribute", "ca_cert": "caCert", } - self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True,) + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True, + ) self.na_helper = NetAppModule() diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_traffic_classes.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_traffic_classes.py index 9901a3e00..842148135 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_traffic_classes.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_traffic_classes.py @@ -196,8 +196,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_user.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_user.py index 521d4f566..f93942508 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_user.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_grid_user.py @@ -102,10 +102,8 @@ resp: } """ -import json import re - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_container.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_container.py index da9663184..6ca94e821 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_container.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_container.py @@ -130,8 +130,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_group.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_group.py index d13a7559a..1fd27fda0 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_group.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_group.py @@ -70,7 +70,6 @@ options: s3_policy: description: - StorageGRID S3 Group Policy. - default: "" type: json """ @@ -255,10 +254,16 @@ class SgOrgGroup(object): update = False if self.parameters.get("management_policy"): - if org_group.get("policies") is None or org_group.get("policies", {}).get("management") != self.data["policies"]["management"]: + if ( + org_group.get("policies") is None + or org_group.get("policies", {}).get("management") != self.data["policies"]["management"] + ): update = True if self.parameters.get("s3_policy"): - if org_group.get("policies") is None or org_group.get("policies", {}).get("s3") != self.data["policies"]["s3"]: + if ( + org_group.get("policies") is None + or org_group.get("policies", {}).get("s3") != self.data["policies"]["s3"] + ): update = True if update: diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_identity_federation.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_identity_federation.py index 4b6811cd6..f192b8343 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_identity_federation.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_identity_federation.py @@ -164,9 +164,6 @@ resp: } """ -import json -import re - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule @@ -218,7 +215,10 @@ class SgOrgIdentityFederation: "ldap_group_uuid_attribute": "ldapGroupUUIDAttribute", "ca_cert": "caCert", } - self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True,) + self.module = AnsibleModule( + argument_spec=self.argument_spec, + supports_check_mode=True, + ) self.na_helper = NetAppModule() diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user.py index 455ffa345..436e1f2c3 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user.py @@ -102,10 +102,8 @@ resp: } """ -import json import re - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import ( @@ -133,9 +131,7 @@ class SgOrgUser(object): member_of=dict(required=False, type="list", elements="str"), disable=dict(required=False, type="bool"), password=dict(required=False, type="str", no_log=True), - update_password=dict( - default="on_create", choices=["on_create", "always"] - ), + update_password=dict(default="on_create", choices=["on_create", "always"]), ) ) @@ -169,9 +165,7 @@ class SgOrgUser(object): re_local_user.match(self.parameters["unique_name"]) is None and re_fed_user.match(self.parameters["unique_name"]) is None ): - self.module.fail_json( - msg="unique_name must begin with 'user/' or 'federated-user/'" - ) + self.module.fail_json(msg="unique_name must begin with 'user/' or 'federated-user/'") self.pw_change = {} if self.parameters.get("password") is not None: @@ -254,13 +248,9 @@ class SgOrgUser(object): if self.parameters.get("member_of"): org_groups = self.get_org_groups() try: - self.data["memberOf"] = [ - org_groups[x] for x in self.parameters["member_of"] - ] + self.data["memberOf"] = [org_groups[x] for x in self.parameters["member_of"]] except KeyError as e: - self.module.fail_json( - msg="Invalid unique_group supplied: '%s' not found" % e.args[0] - ) + self.module.fail_json(msg="Invalid unique_group supplied: '%s' not found" % e.args[0]) cd_action = self.na_helper.get_cd_action(org_user, self.parameters) @@ -279,9 +269,7 @@ class SgOrgUser(object): if member_of_diff: update = True - if self.parameters.get("disable") is not None and self.parameters[ - "disable" - ] != org_user.get("disable"): + if self.parameters.get("disable") is not None and self.parameters["disable"] != org_user.get("disable"): update = True if update: @@ -318,9 +306,7 @@ class SgOrgUser(object): results = [result_message, "Org User password updated"] result_message = "; ".join(filter(None, results)) - self.module.exit_json( - changed=self.na_helper.changed, msg=result_message, resp=resp_data - ) + self.module.exit_json(changed=self.na_helper.changed, msg=result_message, resp=resp_data) def main(): diff --git a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user_s3_key.py b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user_s3_key.py index 0de396eb7..f04dc9337 100644 --- a/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user_s3_key.py +++ b/ansible_collections/netapp/storagegrid/plugins/modules/na_sg_org_user_s3_key.py @@ -74,8 +74,6 @@ resp: } """ -import json - import ansible_collections.netapp.storagegrid.plugins.module_utils.netapp as netapp_utils from ansible.module_utils.basic import AnsibleModule from ansible_collections.netapp.storagegrid.plugins.module_utils.netapp_module import NetAppModule @@ -135,7 +133,10 @@ class SgOrgUserS3Key(object): api = "api/v3/org/users/current-user/s3-access-keys/%s" % access_key if user_id: - api = "api/v3/org/users/%s/s3-access-keys/%s" % (user_id, access_key,) + api = "api/v3/org/users/%s/s3-access-keys/%s" % ( + user_id, + access_key, + ) response, error = self.rest_api.get(api) @@ -162,7 +163,10 @@ class SgOrgUserS3Key(object): api = "api/v3/org/users/current-user/s3-access-keys" if user_id: - api = "api/v3/org/users/%s/s3-access-keys/%s" % (user_id, access_key,) + api = "api/v3/org/users/%s/s3-access-keys/%s" % ( + user_id, + access_key, + ) self.data = None response, error = self.rest_api.delete(api, self.data) |