diff --git a/src/rhsmlib/facts/cloud_facts.py b/src/rhsmlib/facts/cloud_facts.py index 77e1fef6aa..30445f230b 100644 --- a/src/rhsmlib/facts/cloud_facts.py +++ b/src/rhsmlib/facts/cloud_facts.py @@ -181,6 +181,11 @@ def get_gcp_facts(self) -> Dict[str, str]: 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/facts/test_cloud_facts.py b/test/rhsmlib/facts/test_cloud_facts.py index 141680ae8d..ed78738840 100644 --- a/test/rhsmlib/facts/test_cloud_facts.py +++ b/test/rhsmlib/facts/test_cloud_facts.py @@ -349,6 +349,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):