Skip to content

new: add image creation support for OVH#2125

Open
ali-corpo wants to merge 1 commit intoapache:trunkfrom
ali-corpo:ovh_save_image
Open

new: add image creation support for OVH#2125
ali-corpo wants to merge 1 commit intoapache:trunkfrom
ali-corpo:ovh_save_image

Conversation

@ali-corpo
Copy link

Description

Now create Image function will work instead of not implementation error.
The list_images() function now list snapshots (private images)

Status

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

Copilot AI review requested due to automatic review settings February 17, 2026 11:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +222 to +223
# if ex_size:
# params["flavorType"] = ex_size.
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# if ex_size:
# params["flavorType"] = ex_size.

Copilot uses AI. Check for mistakes.
Comment on lines +651 to +652
action = self._get_project_action("instance/%s/snapshot" % node.id)
response = self.connection.request(action, method="POST", data={"snapshotName": name})
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace at the end of this line should be removed to keep the file clean and avoid style/lint noise.

Copilot uses AI. Check for mistakes.

def _to_image(self, obj):
extra = {"region": obj["region"], "visibility": obj["visibility"]}
extra = {"region": obj["region"], "visibility": obj["visibility"], "status": obj["status"]}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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]

Copilot uses AI. Check for mistakes.
Comment on lines +216 to +225
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)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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 = []

Copilot uses AI. Check for mistakes.
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.

2 participants