Skip to content

add more location to OVH and avoid exception when location is not in the list#2123

Open
ali-corpo wants to merge 3 commits intoapache:trunkfrom
ali-corpo:ovh-fix
Open

add more location to OVH and avoid exception when location is not in the list#2123
ali-corpo wants to merge 3 commits intoapache:trunkfrom
ali-corpo:ovh-fix

Conversation

@ali-corpo
Copy link

@ali-corpo ali-corpo commented Feb 17, 2026

Description

add more location to OVH and avoid exception when location is not in the list

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 10:16
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

This PR enhances the OVH driver to support additional datacenter locations and implements graceful handling of unknown locations instead of raising exceptions.

Changes:

  • Added 17 new location entries to the LOCATIONS dictionary, including parent regions (BHS, GRA, RBX, SBG, WAW) and specific locations (CA-EAST-TOR, EU-SOUTH-MIL, EU-WEST-PAR, etc.)
  • Modified the _to_location method to use .get() for safe dictionary access and fall back to creating a basic location object when encountering unknown location codes
  • Added logging to warn when unknown locations are encountered

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
libcloud/common/ovh.py Added 17 new OVH datacenter location mappings to expand geographic coverage
libcloud/compute/drivers/ovh.py Implemented graceful fallback for unknown locations with logging support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from libcloud.compute.types import Provider, StorageVolumeState, VolumeSnapshotState
from libcloud.compute.drivers.openstack import OpenStackKeyPair, OpenStackNodeDriver

from libcloud.libcloud.utils import logging
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.

The import path is incorrect and contains a duplicate 'libcloud' segment. This should be import logging (standard library) or from libcloud.utils.logging import ... if using a custom logging utility. The current path from libcloud.libcloud.utils import logging will cause an ImportError at runtime.

Suggested change
from libcloud.libcloud.utils import logging
import logging

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove logging import and calls, drivers do not call logging.

Comment on lines +81 to +82
"UK": {"id": "UK", "name": "United Kingdom", "country": "UK"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "UK"},
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.

Using 'UK' as a country code is inconsistent with ISO 3166-1 alpha-2 standards, which uses 'GB' for the United Kingdom. However, this appears to be an existing pattern in the codebase (see line 50 with LON1). For consistency with existing entries, this may be acceptable, but consider using 'GB' for proper ISO compliance in future additions.

Suggested change
"UK": {"id": "UK", "name": "United Kingdom", "country": "UK"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "UK"},
"UK": {"id": "UK", "name": "United Kingdom", "country": "GB"},
"UK1": {"id": "UK1", "name": "United Kingdom 1", "country": "GB"},

Copilot uses AI. Check for mistakes.
Comment on lines 542 to 545
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
location = {"id": obj, "name": obj, "country": ""}
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.

The new fallback logic for unknown locations lacks test coverage. Consider adding a test case that verifies the behavior when an unknown location is encountered, ensuring that it creates a NodeLocation with the location ID as both id and name, an empty country field, and logs an appropriate warning message.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the logic behind the location being empty?
May be raising an error will be better...

location = self.connectionCls.LOCATIONS[obj]
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
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.

After fixing the import statement, you should create a module-level logger instance (e.g., logger = logging.getLogger(__name__)) and use logger.warning() instead of calling logging.warning() directly. This follows the established pattern in the codebase (see libcloud/compute/drivers/vsphere.py:53 and libcloud/common/google.py:103).

Copilot uses AI. Check for mistakes.
from libcloud.compute.types import Provider, StorageVolumeState, VolumeSnapshotState
from libcloud.compute.drivers.openstack import OpenStackKeyPair, OpenStackNodeDriver

from libcloud.libcloud.utils import logging
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove logging import and calls, drivers do not call logging.

Comment on lines 542 to 545
location = self.connectionCls.LOCATIONS.get(obj)
if not location:
logging.warning(f"Unknown location {obj} for OVH")
location = {"id": obj, "name": obj, "country": ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the logic behind the location being empty?
May be raising an error will be better...

ali-corpo and others added 2 commits February 17, 2026 16:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed logging warning for unknown OVH locations.
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