Skip to content
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

Merged
merged 26 commits into from Aug 30, 2020
Merged

New compute driver OUTSCALE #1476

merged 26 commits into from Aug 30, 2020

Conversation

tgn-outscale
Copy link
Contributor

@tgn-outscale tgn-outscale commented Jul 21, 2020

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

  • done, ready for review

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.

linaup-m and others added 12 commits July 27, 2020 14:11
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>
@Kami
Copy link
Member

Kami commented Aug 2, 2020

@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?

@tgn-outscale
Copy link
Contributor Author

Hi, @Kami, thanks for your reply

The Outscale EC2 driver is using our old API, and this implementation is using the new one.
As the old version is still in use and the new version still lacking some features, I think the EC2 version is still relevant for now.

@Kami
Copy link
Member

Kami commented Aug 14, 2020

@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.

Class which handles signing the outgoing AWS requests.
"""

def __init__(self, access_key, access_secret, version, connection):
Copy link
Member

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.

"""
action = "ReadRegions"
data = json.dumps({"DryRun": dry_run})
signer = OSCRequestSignerAlgorithmV4(access_key=self.key,
Copy link
Member

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.

action)
return requests.post(endpoint, data=data, headers=headers)

def create_public_ip(self, dry_run=False):
Copy link
Member

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.

def create_node(self,
image_id,
dry_run=False,
block_device_mapping=None,
Copy link
Member

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.

action)
return requests.post(endpoint, data=data, headers=headers)

def reboot_node(self, node_ids):
Copy link
Member

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).

action)
return requests.post(endpoint, data=data, headers=headers)

def list_nodes(self, data="{}"):
Copy link
Member

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.

action)
return requests.post(endpoint, data=data, headers=headers)

def delete_node(self, node_ids):
Copy link
Member

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.

action)
return requests.post(endpoint, data=data, headers=headers)

def list_images(self, data="{}"):
Copy link
Member

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_.

action)
return requests.post(endpoint, data=data, headers=headers)

def delete_image(self, image_id):
Copy link
Member

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.

@Kami
Copy link
Member

Kami commented Aug 14, 2020

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 ex_.

@tgn-outscale
Copy link
Contributor Author

Thanks for your review @Kami, I will make these changes and come back to you as soon as possible.

@Kami
Copy link
Member

Kami commented Aug 14, 2020

You are welcome.

If you need any additional clarification on the extension method and argument naming, please let me know.

@tgn-outscale
Copy link
Contributor Author

tgn-outscale commented Aug 25, 2020

Hello @Kami,
I have made the changes according to what you said for more compliance with the base driver.
Let me know if I missed or misunderstood anything.

website = 'http://www.outscale.com'

def __init__(self,
key: str = None,
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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.

@asfgit asfgit merged commit 86ef1f1 into apache:trunk Aug 30, 2020
@Kami
Copy link
Member

Kami commented Aug 30, 2020

@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:

  • Try to make more methods comply with the Libcloud standard API (where possible) - this would make it easier for users to switch to this driver (right now it utilizes a lot of non-standard argument names which means Libcloud code which works with other provider drivers won't work with this one). This includes both - the argument the methods take and method return values - e.g. create_node() should take name, size and image arguments and return Node instance class (and not a dictionary). Same goes for some other methods.
  • Need to add some documentation with examples to docs/compute/drivers/

@Kami Kami mentioned this pull request Aug 30, 2020
4 tasks
@tgn-outscale
Copy link
Contributor Author

Thanks for your help @Kami, I will try to implement those changes when I will find time to do so,
Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants