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
New compute driver OUTSCALE #1476
Conversation
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
Signed-off-by: Tio Gobin <tio.gobin@outscale.com> Signed-off-by: pauline-p <pauline.piauger@gmail.com>
@tgn-outscale Thanks for the contribution and sorry for the delay. I will have a more detailed look a bit later. For now, I'm just trying to understand how this fits along with the existing Outscale driver which is based on the EC2 one? Is the EC2 based one still relevant, or should we remove it? |
Hi, @Kami, thanks for your reply The Outscale EC2 driver is using our old API, and this implementation is using the new one. |
@tgn-outscale Thanks for the clarification. It would be a good idea to also point this out in the driver documentation page inside docs/ directory. |
libcloud/common/osc.py
Outdated
Class which handles signing the outgoing AWS requests. | ||
""" | ||
|
||
def __init__(self, access_key, access_secret, version, connection): |
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.
It you get a chance, it would also be good to add type annotations for MyPy.
libcloud/compute/drivers/outscale.py
Outdated
""" | ||
action = "ReadRegions" | ||
data = json.dumps({"DryRun": dry_run}) | ||
signer = OSCRequestSignerAlgorithmV4(access_key=self.key, |
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.
Looks like the next couple of lines are duplicated across all the driver methods.
To avoid duplication it would be good to refactor that in some common method.
In addition to that, it looks like OSCRequestSignerAlgorithmV4
could also be instantiated inside the driver constructor since it doesn't seem to depend on any method specific arguments.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def create_public_ip(self, dry_run=False): |
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 which are not part of a standard Libcloud API need to be prefixed with ex_
- so ex_create_public_ip
, ex_delete_public_ip
, etc.
libcloud/compute/drivers/outscale.py
Outdated
def create_node(self, | ||
image_id, | ||
dry_run=False, | ||
block_device_mapping=None, |
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.
Argument which are not part of the Libcloud standard API (aka are not defined on the base NodeDriver class) need to be prefixed with ex_
- ex_bsu_optimized, ex_nics, etc.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def reboot_node(self, node_ids): |
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.
To comply with the libcloud standard API, this method needs to take a single node
argument which must be Node
class instance.
If you also want to support rebooting multiple notes, you should add a new extension method. For example: ex_reboot_nodes(self, node_ids)
.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def list_nodes(self, data="{}"): |
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.
To comply with the base Libcloud API, this method needs to return a list of Node
objects.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def delete_node(self, node_ids): |
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.
Same here - should take a single node
argument which represents Node
class instance.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def list_images(self, data="{}"): |
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.
Needs to return a list of NodeImage
objects. data is a non-standard argument so it needs to be prefixed with ex_
.
libcloud/compute/drivers/outscale.py
Outdated
action) | ||
return requests.post(endpoint, data=data, headers=headers) | ||
|
||
def delete_image(self, image_id): |
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.
Needs to take NodeImage
object.
I've added some in-line comments. Overall, the changes mostly look good, but the code needs a bit more work to reduce duplication and to make sure the methods and method arguments comply with the base Libcloud API - that's one of the main ideas behind Libcloud - all the provider drivers should expose the same API (where possible), so users can easily switch between different providers and non-standard methods and arguments should be prefixed with |
Thanks for your review @Kami, I will make these changes and come back to you as soon as possible. |
You are welcome. If you need any additional clarification on the extension method and argument naming, please let me know. |
… with libcloud standard provider methods
…rganised outscale driver methods order
Hello @Kami, |
website = 'http://www.outscale.com' | ||
|
||
def __init__(self, | ||
key: str = None, |
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.
Thanks for adding type annotations 👍
public_ip: str = None, | ||
public_ip_id: str = None): | ||
""" | ||
Delete instances. |
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.
Some comments are out of sync with code, but I will update / fix that when merging the pr :)
""" | ||
Create a new instance. | ||
|
||
:param ex_image_id: The ID of the OMI used to create the VM. |
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.
That's fine for now, but ideally this method would comply with the standard API in the future - this means take name, image and size arguments.
This would make it much easier for users to switch from other providers to this one without needing to change much code.
@tgn-outscale Thanks for addressing the review feedback. I merged the PR into trunk, but there are still some places which would ideally be improved in the near future:
|
Thanks for your help @Kami, I will try to implement those changes when I will find time to do so, |
Description
This PR add a new compute driver named OUTSCALE, it was added in file types.py of compute section, in a new osc.py file for authentification in common section and in a new file named outscale.py to perform actions of the OUTSCALE API using requests. See the documentation link: https://docs.outscale.com/api
This PR is a reworked version of #1345 using python requests lib instead of using outscale python sdk.
Status
Checklist (tick everything that applies)
Code linting (required, can be done after the PR checks)
Documentation (do the documentation refer to the docstring ?)
Tests
ICLA (required for bigger changes)
Happy to receive thoughs.