From f64712c1b3cbda4a183e92033d48e350704283a1 Mon Sep 17 00:00:00 2001 From: Chris Archibald Date: Mon, 26 Apr 2021 16:03:32 -0400 Subject: [PATCH] Sync bitbucket and GitHub --- .../netapp/cloudmanager/README.md | 5 ++++ .../changelogs/fragments/DEVOPS-3910.yaml | 2 ++ .../netapp/cloudmanager/galaxy.yml | 2 +- .../plugins/module_utils/netapp.py | 2 +- .../modules/na_cloudmanager_cifs_server.py | 9 +++--- .../test_na_cloudmanager_cifs_server.py | 28 +++++++++++++++++++ 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 ansible_collections/netapp/cloudmanager/changelogs/fragments/DEVOPS-3910.yaml diff --git a/ansible_collections/netapp/cloudmanager/README.md b/ansible_collections/netapp/cloudmanager/README.md index e85d0acb..7b30f23b 100644 --- a/ansible_collections/netapp/cloudmanager/README.md +++ b/ansible_collections/netapp/cloudmanager/README.md @@ -29,6 +29,11 @@ https://github.com/ansible-collections/netapp/wiki # Release Notes +## 21.5.1 + +### Bug fixes + - na_cloudmanager_cifs_server: Fix incorrect API call when is_workgroup is true + ## 21.5.0 ### New Options diff --git a/ansible_collections/netapp/cloudmanager/changelogs/fragments/DEVOPS-3910.yaml b/ansible_collections/netapp/cloudmanager/changelogs/fragments/DEVOPS-3910.yaml new file mode 100644 index 00000000..0e9dd639 --- /dev/null +++ b/ansible_collections/netapp/cloudmanager/changelogs/fragments/DEVOPS-3910.yaml @@ -0,0 +1,2 @@ +bugfixes: + - na_cloudmanager_cifs_server - Fix incorrect API call when is_workgroup is true \ No newline at end of file diff --git a/ansible_collections/netapp/cloudmanager/galaxy.yml b/ansible_collections/netapp/cloudmanager/galaxy.yml index b8ef5082..81326aa7 100644 --- a/ansible_collections/netapp/cloudmanager/galaxy.yml +++ b/ansible_collections/netapp/cloudmanager/galaxy.yml @@ -9,7 +9,7 @@ namespace: netapp name: cloudmanager # The version of the collection. Must be compatible with semantic versioning -version: "21.5.0" +version: "21.5.1" # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/ansible_collections/netapp/cloudmanager/plugins/module_utils/netapp.py b/ansible_collections/netapp/cloudmanager/plugins/module_utils/netapp.py index d60d3d53..14f615d1 100644 --- a/ansible_collections/netapp/cloudmanager/plugins/module_utils/netapp.py +++ b/ansible_collections/netapp/cloudmanager/plugins/module_utils/netapp.py @@ -41,7 +41,7 @@ except ImportError: ansible_version = 'unknown' -COLLECTION_VERSION = "21.5.0" +COLLECTION_VERSION = "21.5.1" AUTH0_DOMAIN = 'netapp-cloud-account.auth0.com' AUTH0_CLIENT = 'Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC' diff --git a/ansible_collections/netapp/cloudmanager/plugins/modules/na_cloudmanager_cifs_server.py b/ansible_collections/netapp/cloudmanager/plugins/modules/na_cloudmanager_cifs_server.py index 26c5f18d..67bff7ab 100644 --- a/ansible_collections/netapp/cloudmanager/plugins/modules/na_cloudmanager_cifs_server.py +++ b/ansible_collections/netapp/cloudmanager/plugins/modules/na_cloudmanager_cifs_server.py @@ -196,7 +196,7 @@ def get_cifs_server(self): response, err, dummy = self.rest_api.send_request("GET", "%s/working-environments/%s/cifs" % ( self.rest_api.api_root_path, self.parameters['working_environment_id']), None, header=self.headers) if err is not None: - self.module.fail_json(changed=False, msg=err) + self.module.fail_json(changed=False, msg="Error on get_cifs_server: %s, %s" % (str(err), str(response))) current_cifs = dict() if response is None or len(response) == 0: return None @@ -228,16 +228,17 @@ def create_cifs_server(self): url = "%s/working-environments/%s/cifs" % (self.rest_api.api_root_path, self.parameters['working_environment_id']) if self.parameters.get('is_workgroup'): - url = url + "workgroup" + url = url + "-workgroup" + response, err, dummy = self.rest_api.send_request("POST", url, None, server, header=self.headers) if err is not None: - self.module.fail_json(changed=False, msg=err) + self.module.fail_json(changed=False, msg="Error on create_cifs_server failed: %s, %s" % (str(err), str(response))) def delete_cifs_server(self): response, err, dummy = self.rest_api.send_request("POST", "%s/working-environments/%s/delete-cifs" % ( self.rest_api.api_root_path, self.parameters['working_environment_id']), None, {}, header=self.headers) if err is not None: - self.module.fail_json(changed=False, msg=err) + self.module.fail_json(changed=False, msg="Error on delete_cifs_server: %s, %s" % (str(err), str(response))) def apply(self): current = self.get_cifs_server() diff --git a/ansible_collections/netapp/cloudmanager/tests/unit/plugins/modules/test_na_cloudmanager_cifs_server.py b/ansible_collections/netapp/cloudmanager/tests/unit/plugins/modules/test_na_cloudmanager_cifs_server.py index a0d7b389..5e435c8b 100644 --- a/ansible_collections/netapp/cloudmanager/tests/unit/plugins/modules/test_na_cloudmanager_cifs_server.py +++ b/ansible_collections/netapp/cloudmanager/tests/unit/plugins/modules/test_na_cloudmanager_cifs_server.py @@ -78,6 +78,17 @@ def set_default_args_pass_check(self): 'organizational_unit': 'CN=Computers', }) + def set_using_workgroup_args_pass_check(self): + return dict({ + 'state': 'present', + 'working_environment_id': 'VsaWorkingEnvironment-abcdefg12345', + 'client_id': 'Nw4Q2O1kdnLtvhwegGalFnodEHUfPJWh', + 'refresh_token': 'refreshToken', + 'is_workgroup': True, + 'server_name': 'abc', + 'workgroup_name': 'wk', + }) + def test_module_fail_when_required_args_missing(self): ''' required arguments are reported as errors ''' with pytest.raises(AnsibleFailJson) as exc: @@ -123,6 +134,23 @@ def test_create_cifs_server_idempotency(self, send_request, get, get_token): obj.apply() assert not exc.value.args[0]['changed'] + @patch('ansible_collections.netapp.cloudmanager.plugins.module_utils.netapp.CloudManagerRestAPI.get_token') + @patch('ansible_collections.netapp.cloudmanager.plugins.modules.na_cloudmanager_cifs_server.NetAppCloudmanagerCifsServer.get_cifs_server') + @patch('ansible_collections.netapp.cloudmanager.plugins.modules.na_cloudmanager_cifs_server.NetAppCloudmanagerCifsServer.create_cifs_server') + @patch('ansible_collections.netapp.cloudmanager.plugins.module_utils.netapp.CloudManagerRestAPI.send_request') + def test_create_cifs_server_using_workgroup_successfully(self, send_request, create, get, get_token): + set_module_args(self.set_using_workgroup_args_pass_check()) + get.return_value = None + create.return_value = None + send_request.side_effect = [({'publicId': 'id', 'svmName': 'svm_name', 'cloudProviderName': "aws", 'isHA': False}, None, 'dummy')] + get_token.return_value = ("type", "token") + obj = my_module() + obj.rest_api.api_root_path = "test_root_path" + + with pytest.raises(AnsibleExitJson) as exc: + obj.apply() + assert exc.value.args[0]['changed'] + @patch('ansible_collections.netapp.cloudmanager.plugins.module_utils.netapp.CloudManagerRestAPI.get_token') @patch('ansible_collections.netapp.cloudmanager.plugins.modules.na_cloudmanager_cifs_server.NetAppCloudmanagerCifsServer.get_cifs_server') @patch('ansible_collections.netapp.cloudmanager.plugins.modules.na_cloudmanager_cifs_server.NetAppCloudmanagerCifsServer.delete_cifs_server')