-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Initial commit for Scaleway Compute #38285
Conversation
compute_api.module.fail_json(msg="Error while checking if attributes should be changed") | ||
|
||
|
||
def server_change_attributes(): |
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 function is being worked on.
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.
Done;
Would you suggest using an object containing the different methods? Pro: it would avoid passing the compute_api object around. Cons: This class might get quite big... |
) | ||
|
||
|
||
def print_warning(compute_api, msg): |
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.
Not sure if module.debug
should be used instead.
return self.status_code in (200, 201, 202, 204) | ||
|
||
|
||
class ScalewayComputeAPI(object): |
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 class should be moved to module_utils/scaleway.py
and reused by scaleway_sshkey
module.
return self.send("UPDATE", path, data, headers) | ||
|
||
|
||
def is_present(compute_api, server): |
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 method is unused and must be removed.
|
||
if wait: | ||
print_warning(compute_api, "(create_server) Wait is enabled") | ||
wait_to_complete_state_transition(compute_api=compute_api, server=target_server) |
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.
test of wait
parameter could be moved inside the wait_to_complete_state_transition
method.
return response | ||
|
||
|
||
def start_server(compute_api, server): |
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.
methods start_server
/stop_server
/restart_server
are almost the same and could be factorized.
|
||
if not query_results: | ||
changed = True | ||
if compute_api.module.check_mode: |
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.
Here and below: I would prefer using something like return changed, ...
than calling compute_api.module.exit_json
because the caller calls exit_json
anyway.
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.
Done.
msg = 'Error while stopping server [{0}: {1}]'.format(response.status_code, response.json) | ||
compute_api.module.fail_json(msg=msg) | ||
|
||
return changed, {"status": "stopped"} |
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.
Should not a string be used instead of {"status": "stopped"}
(the same for restart_strategy
method) (because dict is used as msg
parameter there) ?
required=True, | ||
), | ||
image=dict(required=True), | ||
name=dict(), |
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.
In the module documentation name
is required.
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.
A default name will be provided if a name is missing, therefore, it's not a required parameter. I've fixed the documentation.
+1 the the feedback from @pilou- and other than that I think the code looks good. Please let me know when it's complete (no longer a Work In Progress) and I'm happy to provide a final review. |
09108b3
to
5281a87
Compare
The test
|
5281a87
to
dfec9e4
Compare
dfec9e4
to
279b203
Compare
279b203
to
b786850
Compare
@maxamillion I think the patch is ready for its final review :) |
The test
The test
The test
The test
|
b786850
to
9d6d44e
Compare
9d6d44e
to
9476ca0
Compare
SUMMARY
This PR adds support for the Scaleway Compute API.
It can create, start, stop, restart and destroy Scaleway Compute instances.
It also got a playbook to test the different steps.
ISSUE TYPE
COMPONENT NAME
scaleway_compute
ANSIBLE VERSION