-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Bug] Scaleway The volume is created systematically on par1 #3964
Changes from all commits
84fb82d
143ed59
ea3a559
9d8ad16
664b1e1
a81a90e
1477831
78b0566
3751b8a
7a4d381
8f5b181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- scaleway_volume - all volumes are systematically created on par1 (https://github.com/ansible-collections/community.general/pull/3964). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,11 @@ | |
description: | ||
- Name used to identify the volume. | ||
required: true | ||
project: | ||
type: str | ||
description: | ||
- Scaleway project ID to which volume belongs. | ||
version_added: 4.3.0 | ||
organization: | ||
type: str | ||
description: | ||
|
@@ -71,7 +76,7 @@ | |
name: my-volume | ||
state: present | ||
region: par1 | ||
organization: "{{ scw_org }}" | ||
project: "{{ scw_org }}" | ||
"size": 10000000000 | ||
volume_type: l_ssd | ||
register: server_creation_check_task | ||
|
@@ -93,7 +98,7 @@ | |
"export_uri": null, | ||
"id": "c675f420-cfeb-48ff-ba2a-9d2a4dbe3fcd", | ||
"name": "volume-0-3", | ||
"organization": "000a115d-2852-4b0a-9ce8-47f1134ba95a", | ||
"project": "000a115d-2852-4b0a-9ce8-47f1134ba95a", | ||
"server": null, | ||
"size": 10000000000, | ||
"volume_type": "l_ssd" | ||
|
@@ -106,31 +111,37 @@ | |
|
||
|
||
def core(module): | ||
region = module.params["region"] | ||
state = module.params['state'] | ||
name = module.params['name'] | ||
organization = module.params['organization'] | ||
project = module.params['project'] | ||
size = module.params['size'] | ||
volume_type = module.params['volume_type'] | ||
module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a bugfix? Is it related to the other bugfixes? If not, it should be a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need this part to have the scw aliases. example par1 = fr-par-1 |
||
|
||
account_api = Scaleway(module) | ||
response = account_api.get('volumes') | ||
status_code = response.status_code | ||
volumes_json = response.json | ||
|
||
if project is None: | ||
project = organization | ||
|
||
if not response.ok: | ||
module.fail_json(msg='Error getting volume [{0}: {1}]'.format( | ||
status_code, response.json['message'])) | ||
|
||
volumeByName = None | ||
for volume in volumes_json['volumes']: | ||
if volume['organization'] == organization and volume['name'] == name: | ||
if volume['project'] == project and volume['name'] == name: | ||
felixfontein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
volumeByName = volume | ||
|
||
if state in ('present',): | ||
if volumeByName is not None: | ||
module.exit_json(changed=False) | ||
|
||
payload = {'name': name, 'organization': organization, 'size': size, 'volume_type': volume_type} | ||
payload = {'name': name, 'project': project, 'size': size, 'volume_type': volume_type} | ||
|
||
response = account_api.post('/volumes', payload) | ||
|
||
|
@@ -161,13 +172,20 @@ def main(): | |
state=dict(default='present', choices=['absent', 'present']), | ||
name=dict(required=True), | ||
size=dict(type='int'), | ||
project=dict(), | ||
organization=dict(), | ||
volume_type=dict(), | ||
region=dict(required=True, choices=list(SCALEWAY_LOCATION.keys())), | ||
)) | ||
module = AnsibleModule( | ||
argument_spec=argument_spec, | ||
supports_check_mode=True, | ||
mutually_exclusive=[ | ||
('organization', 'project'), | ||
], | ||
required_one_of=[ | ||
('organization', 'project'), | ||
], | ||
) | ||
|
||
core(module) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change and will not be accepted. See #3951 for a way to do this as in a non-breaking fashion. It might also be better to rename this option to
project
and keep an alias fororganization
, if these two values mean the same to the API. @remyleone what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can indeed follow #3951 to add support for a project. I don't think it is necessary to remove organization. Also, I fail to see why you would need a region argument, instance API uses zone such as
fr-par-1
and not region such asfr-par
.par1
is deprecated and you should usefr-par-1
to talk about this zone that belongs to thefr-par
region.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the changes to support organization