diff --git a/src/rhsmlib/facts/cloud_facts.py b/src/rhsmlib/facts/cloud_facts.py index 535bb9a19f..5b141c7859 100644 --- a/src/rhsmlib/facts/cloud_facts.py +++ b/src/rhsmlib/facts/cloud_facts.py @@ -146,6 +146,11 @@ def get_azure_facts(self) -> Dict[str, str]: facts["azure_subscription_id"] = values["compute"]["subscriptionId"] if "location" in values["compute"]: facts["azure_location"] = values["compute"]["location"] + if "extendedLocation" in values["compute"]: + if "name" in values["compute"]["extendedLocation"]: + facts["azure_extended_location_name"] = values["compute"]["extendedLocation"]["name"] + if "type" in values["compute"]["extendedLocation"]: + facts["azure_extended_location_type"] = values["compute"]["extendedLocation"]["type"] return facts def get_gcp_facts(self) -> Dict[str, str]: diff --git a/test/rhsmlib/facts/test_cloud_facts.py b/test/rhsmlib/facts/test_cloud_facts.py index f868de55ac..06c4597c3f 100644 --- a/test/rhsmlib/facts/test_cloud_facts.py +++ b/test/rhsmlib/facts/test_cloud_facts.py @@ -48,6 +48,10 @@ { "compute": { "azEnvironment": "AzurePublicCloud", + "extendedLocation": { + "type": "edgeZone", + "name": "microsoftlondon" + }, "customData": "", "location": "westeurope", "name": "foo-bar", @@ -169,7 +173,12 @@ AZURE_SKU = "8.1-ci" AZURE_OFFER = "RHEL" AZURE_SUBSCRIPTION_ID = "01234567-0123-0123-0123-012345679abc" +# There is no list of valid values of locations, extended locations and +# types of extended locations. Value "microsoftlondon" probably does not +# exist at all, and it was added only for testing purpose. AZURE_LOCATION = "westeurope" +AZURE_EXTENDED_LOCATION_NAME = "microsoftlondon" +AZURE_EXTENDED_LOCATION_TYPE = "edgeZone" def mock_prepare_request(request): @@ -319,6 +328,10 @@ def test_get_azure_facts(self): self.assertEqual(facts["azure_subscription_id"], AZURE_SUBSCRIPTION_ID) self.assertIn("azure_location", facts) self.assertEqual(facts["azure_location"], AZURE_LOCATION) + self.assertIn("azure_extended_location_name", facts) + self.assertEqual(facts["azure_extended_location_name"], AZURE_EXTENDED_LOCATION_NAME) + self.assertIn("azure_extended_location_type", facts) + self.assertEqual(facts["azure_extended_location_type"], AZURE_EXTENDED_LOCATION_TYPE) @patch("cloud_what.providers.gcp.GCPCloudProvider._write_token_to_cache_file") @patch("cloud_what.providers.gcp.GCPCloudProvider._get_metadata_from_cache")