new: add image creation support for OVH#2125
Conversation
There was a problem hiding this comment.
Pull request overview
Adds OVH compute driver support for instance image creation and extends image listing to include private snapshots, aligning OVH behavior with Libcloud’s broader NodeDriver image APIs.
Changes:
- Extend
list_images()to also fetch and return snapshot-based private images. - Implement
create_image()for OVH instances (snapshot creation) instead of raising not-implemented behavior. - Make node state mapping more defensive by defaulting to
NodeState.UNKNOWN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # if ex_size: | ||
| # params["flavorType"] = ex_size. |
There was a problem hiding this comment.
There is commented-out/incomplete code left in this method (# if ex_size: / params["flavorType"] = ex_size.). Since it can't work as-is and doesn't document an implemented behavior, it should be removed or replaced with a proper implementation and explanation.
| # if ex_size: | |
| # params["flavorType"] = ex_size. |
| action = self._get_project_action("instance/%s/snapshot" % node.id) | ||
| response = self.connection.request(action, method="POST", data={"snapshotName": name}) |
There was a problem hiding this comment.
Trailing whitespace at the end of this line should be removed to keep the file clean and avoid style/lint noise.
|
|
||
| def _to_image(self, obj): | ||
| extra = {"region": obj["region"], "visibility": obj["visibility"]} | ||
| extra = {"region": obj["region"], "visibility": obj["visibility"], "status": obj["status"]} |
There was a problem hiding this comment.
_to_image now unconditionally reads obj["status"], but the OVH image list/details responses used elsewhere in the driver (and in existing fixtures) don't include a status field. This will raise a KeyError when calling list_images() / get_image(). Use obj.get("status") (or a sensible default) and keep the extra fields optional.
| extra = {"region": obj["region"], "visibility": obj["visibility"], "status": obj["status"]} | |
| extra = {} | |
| for key in ("region", "visibility", "status"): | |
| if key in obj: | |
| extra[key] = obj[key] |
| action_snapshot = self._get_project_action("snapshot") | ||
| params_snapshot = {} | ||
|
|
||
| if location: | ||
| params_snapshot["region"] = location.id | ||
|
|
||
| # if ex_size: | ||
| # params["flavorType"] = ex_size. | ||
| response_snapshot = self.connection.request(action_snapshot, params=params_snapshot) | ||
| private_images = self._to_images(response_snapshot.object) |
There was a problem hiding this comment.
list_images() now makes an additional request to the snapshot endpoint, but the existing OVH compute unit tests/mock transport don't provide a handler/fixture for that URL. This change will make libcloud/test/compute/test_ovh.py::test_list_images fail unless the mock and fixtures are updated (and ideally assertions added for snapshot images).
| action_snapshot = self._get_project_action("snapshot") | |
| params_snapshot = {} | |
| if location: | |
| params_snapshot["region"] = location.id | |
| # if ex_size: | |
| # params["flavorType"] = ex_size. | |
| response_snapshot = self.connection.request(action_snapshot, params=params_snapshot) | |
| private_images = self._to_images(response_snapshot.object) | |
| try: | |
| action_snapshot = self._get_project_action("snapshot") | |
| params_snapshot = {} | |
| if location: | |
| params_snapshot["region"] = location.id | |
| # if ex_size: | |
| # params["flavorType"] = ex_size. | |
| response_snapshot = self.connection.request( | |
| action_snapshot, params=params_snapshot | |
| ) | |
| private_images = self._to_images(response_snapshot.object) | |
| except Exception: | |
| # If the snapshot endpoint is not available or not mocked, | |
| # gracefully fall back to no private images. | |
| private_images = [] |
Description
Now create Image function will work instead of not implementation error.
The list_images() function now list snapshots (private images)
Status
Checklist (tick everything that applies)