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
Add support for Linode's API v4 #1504
Conversation
- Cast StorageVolume id to str - Change params in attach_volume to be in the same order as base class
Sorry for the delay. This is a relatively large PR so it will take a while to review. |
I'm interested in this new version. I tested some of the functionality of the compute driver:
I found some minor issues I will put inline. |
'migrating': NodeState.MIGRATING, | ||
'rebuilding': NodeState.UPDATING, | ||
'cloning': NodeState.MIGRATING, | ||
'restoring': NodeState.PENDING, |
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.
There is a missing state 'resizing'. I checked the API documentation and it does not appear. But I made some tests and it does exist. May be a good map value could be:
'resizing': NodeState.RECONFIGURING
libcloud/compute/drivers/linode.py
Outdated
'location': data['region'], | ||
'linode_id': data['linode_id'], | ||
'linode_label': data['linode_label'], | ||
'state': self.LINODE_VOLUME_STATES[data['status']] |
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.
filesystem_path' is an important value that is not returned in the extra fields:
'filesystem_path': data['filesystem_path']
Hi @micafer, |
Codecov Report
@@ Coverage Diff @@
## trunk #1504 +/- ##
==========================================
+ Coverage 83.00% 83.06% +0.05%
==========================================
Files 390 392 +2
Lines 83701 84667 +966
Branches 8882 8997 +115
==========================================
+ Hits 69480 70332 +852
- Misses 11222 11272 +50
- Partials 2999 3063 +64
Continue to review full report at Codecov.
|
@micafer Since you originally reviewed this PR, can you please have a look again when you get a chance? And if everything looks OK, feel free to add a CHANGELOG entry and merge it into master. |
OK, I will take a look. |
status = int(self.status) | ||
data = self.parse_body() | ||
# Use only the first error, as there'll be only one most of the time | ||
error = data['errors'][0] |
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.
Why not:
error = " ".join(data['errors'])
In this case all error messages will be returned, not only the first one.
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.
data['errors'] is a list of dictionaries so I think this will not work.
Maybe it could be something like this?
error = data['errors'][0] | |
error_list = [] | |
for error in data['errors']: | |
reason = error.get('reason') | |
# The field in the request that caused this error | |
field = error.get('field') | |
if field is not None: | |
msg = '%s-%s' % (reason, field) | |
else: | |
msg = reason | |
error_list.append(msg) | |
error_msg = ' '.join(error_list) |
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.
Yes, you are right. May be you can leave the original one. As you said in the first error is the most important one.
libcloud/compute/drivers/linode.py
Outdated
:type volume: :class:`StorageVolume` | ||
|
||
:param volume: Node to attach the volume to(required) | ||
:type volume: :class:`Node` |
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 should be:
:param node:
:type node:
libcloud/compute/drivers/linode.py
Outdated
:type volume: :class:`Node` | ||
|
||
:keyword persist_across_boots: Node to attach the volume to(required) | ||
:type volume: :class:`Node` |
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 should be:
:type persist_across_boots: bool
libcloud/compute/drivers/linode.py
Outdated
:type node: :class:`Node` | ||
|
||
:keyword address_type: Type of IP address | ||
:type address_type: `bool` |
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 should be:
:type address_type: str
libcloud/compute/drivers/linode.py
Outdated
method='POST').object | ||
return self._to_address(response) | ||
|
||
def ex_share_address(self, node, addresses=[]): |
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.
Why setting addresses as an optional keyword?
It is required to share an address.
I think it shoul be better:
def ex_share_address(self, node, addresses):
libcloud/compute/drivers/linode.py
Outdated
:type node: :class:`Node` | ||
|
||
:param size: the size of the new node | ||
:type node: :class:`NodeSize` |
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 should be:
:type size:
Adding other methods as: |
Thanks for the feedback @micafer . |
LGTM. |
Looks like that merging this "broke" automatically generated provider tables - it shows Linode DNS driver doesn't implement any methods. I believe that's related to the way driver is now structured - our table generation script only changes methods on the base class. I will work on a workaround. |
Here we go - 85d6bbb :) |
Add Linode Compute Driver for APIv4
Description
This Pull Request adds Linode Compute Driver compatible with Linode's API v4 while simultaneously supporting the previous API version.
Status
done, ready for review
Checklist (tick everything that applies)