diff --git a/src/rhsmlib/facts/cloud_facts.py b/src/rhsmlib/facts/cloud_facts.py index 252eeaf73d..314eb3cdea 100644 --- a/src/rhsmlib/facts/cloud_facts.py +++ b/src/rhsmlib/facts/cloud_facts.py @@ -169,6 +169,11 @@ def get_gcp_facts(self): facts["gcp_project_number"] = values["google"]["compute_engine"]["project_number"] else: log.debug("GCP project_number not found in JWT token") + # zone where the machine is located + if "zone" in values["google"]["compute_engine"]: + facts["gcp_zone"] = values["google"]["compute_engine"]["zone"] + else: + log.debug("GCP zone not found in JWT token") else: log.debug("GCP google.compute_engine on found in JWT token") return facts diff --git a/test/rhsmlib_test/test_cloud_facts.py b/test/rhsmlib_test/test_cloud_facts.py index 4157d185ea..64e9210332 100644 --- a/test/rhsmlib_test/test_cloud_facts.py +++ b/test/rhsmlib_test/test_cloud_facts.py @@ -339,6 +339,8 @@ def test_get_gcp_facts(self, mock_get_metadata_from_cache, mock_write_token_to_c self.assertEqual(facts["gcp_project_id"], "fair-kingdom-308514") self.assertIn("gcp_project_number", facts) self.assertEqual(facts["gcp_project_number"], 161958465613) + self.assertIn("gcp_zone", facts) + self.assertEqual(facts["gcp_zone"], "us-east1-b") @patch('cloud_what.providers.aws.requests.Session', name='mock_session_class') def test_get_not_aws_instance(self, mock_session_class):