This is an automated email from the ASF dual-hosted git repository. micafer pushed a commit to branch fix/ovh_locations in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit d9c9b7673408c7c7fac68b9c03bce3fe72ab7394 Author: Miguel Caballer <[email protected]> AuthorDate: Thu Nov 12 11:46:24 2026 +0100 Fix OVH locations --- libcloud/common/ovh.py | 32 -------------------------------- libcloud/compute/drivers/ovh.py | 4 +--- libcloud/test/compute/test_ovh.py | 10 ++++++++-- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/libcloud/common/ovh.py b/libcloud/common/ovh.py index d2233c1e4..3451945fa 100644 --- a/libcloud/common/ovh.py +++ b/libcloud/common/ovh.py @@ -33,37 +33,6 @@ __all__ = ["OvhResponse", "OvhConnection"] API_HOST = "api.ovh.com" API_ROOT = "/1.0" -# From https://us.ovhcloud.com/about/company/data-centers -LOCATIONS = { - "BHS1": {"id": "BHS1", "name": "Beauharnois, Quebec 1", "country": "CA"}, - "BHS2": {"id": "BHS2", "name": "Beauharnois, Quebec 2", "country": "CA"}, - "BHS3": {"id": "BHS3", "name": "Beauharnois, Quebec 3", "country": "CA"}, - "BHS4": {"id": "BHS4", "name": "Beauharnois, Quebec 4", "country": "CA"}, - "BHS5": {"id": "BHS5", "name": "Beauharnois, Quebec 5", "country": "CA"}, - "BHS6": {"id": "BHS6", "name": "Beauharnois, Quebec 6", "country": "CA"}, - "DC1": {"id": "DC1", "name": "Paris DC1", "country": "FR"}, - "FRA1": {"id": "FRA1", "name": "Frankfurt 1", "country": "DE"}, - "GRA1": {"id": "GRA1", "name": "Gravelines 1", "country": "FR"}, - "GRA2": {"id": "GRA2", "name": "Gravelines 2", "country": "FR"}, - "GSW": {"id": "GSW", "name": "Paris GSW", "country": "FR"}, - "HIL1": {"id": "HIL1", "name": "Hillsboro, Oregon 1", "country": "US"}, - "LON1": {"id": "LON1", "name": "London 1", "country": "UK"}, - "P19": {"id": "P19", "name": "Paris P19", "country": "FR"}, - "RBX1": {"id": "RBX1", "name": "Roubaix 1", "country": "FR"}, - "RBX2": {"id": "RBX2", "name": "Roubaix 2", "country": "FR"}, - "RBX3": {"id": "RBX3", "name": "Roubaix 3", "country": "FR"}, - "RBX4": {"id": "RBX4", "name": "Roubaix 4", "country": "FR"}, - "RBX5": {"id": "RBX5", "name": "Roubaix 5", "country": "FR"}, - "RBX6": {"id": "RBX6", "name": "Roubaix 6", "country": "FR"}, - "RBX7": {"id": "RBX7", "name": "Roubaix 7", "country": "FR"}, - "SBG1": {"id": "SBG1", "name": "Strasbourg 1", "country": "FR"}, - "SBG2": {"id": "SBG2", "name": "Strasbourg 2", "country": "FR"}, - "SBG3": {"id": "SBG3", "name": "Strasbourg 3", "country": "FR"}, - "SGP1": {"id": "SGP1", "name": "Singapore 1", "country": "SG"}, - "SYD1": {"id": "SYD1", "name": "Sydney 1", "country": "AU"}, - "VIN1": {"id": "VIN1", "name": "Vint Hill, Virginia 1", "country": "US"}, - "WAW1": {"id": "WAW1", "name": "Warsaw 1", "country": "PL"}, -} DEFAULT_ACCESS_RULES = [ {"method": "GET", "path": "/*"}, {"method": "POST", "path": "/*"}, @@ -102,7 +71,6 @@ class OvhConnection(ConnectionUserAndKey): responseCls = OvhResponse timestamp = None ua = [] # type: List[str] - LOCATIONS = LOCATIONS _timedelta = None allow_insecure = True diff --git a/libcloud/compute/drivers/ovh.py b/libcloud/compute/drivers/ovh.py index 9bf73fc1c..4bea57b2c 100644 --- a/libcloud/compute/drivers/ovh.py +++ b/libcloud/compute/drivers/ovh.py @@ -543,9 +543,7 @@ class OvhNodeDriver(NodeDriver): return [self._to_volume(obj) for obj in objs] def _to_location(self, obj): - location = self.connectionCls.LOCATIONS[obj] - - return NodeLocation(driver=self, **location) + return NodeLocation(id=obj, name=obj, country="", driver=self) def _to_locations(self, objs): return [self._to_location(obj) for obj in objs] diff --git a/libcloud/test/compute/test_ovh.py b/libcloud/test/compute/test_ovh.py index d13948a1f..ce50778e4 100644 --- a/libcloud/test/compute/test_ovh.py +++ b/libcloud/test/compute/test_ovh.py @@ -199,8 +199,14 @@ class OvhTests(unittest.TestCase): self.assertRaisesRegex(BaseHTTPError, expected_msg, driver.list_nodes) def test_list_locations(self): - images = self.driver.list_locations() - self.assertTrue(len(images) > 0) + locations = self.driver.list_locations() + self.assertTrue(len(locations) > 0) + + def test_to_location_uses_region_code_as_id_and_name(self): + location = self.driver._to_location("eu-west-par") + self.assertEqual(location.id, "eu-west-par") + self.assertEqual(location.name, "eu-west-par") + self.assertEqual(location.country, "") def test_list_images(self): images = self.driver.list_images()
