Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Sync bitbucket and GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
carchi8py committed Apr 26, 2021
1 parent 75fa13c commit f64712c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ansible_collections/netapp/cloudmanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- na_cloudmanager_cifs_server - Fix incorrect API call when is_workgroup is true
2 changes: 1 addition & 1 deletion ansible_collections/netapp/cloudmanager/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit f64712c

Please sign in to comment.