Skip to content

Commit

Permalink
feat: 1.28 Added zone GCP fact
Browse files Browse the repository at this point in the history
* Original PR: 3388
  * Original commit: 2d04f77
* Card ID: CCT-385
* Added fact about zone, where the instance is located
* Extended unit test covering this new fact
* Note: GCP does not provide any information about instance type
  • Loading branch information
jirihnidek committed Apr 23, 2024
1 parent 7aaa4b8 commit 27ccda4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rhsmlib/facts/cloud_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/rhsmlib_test/test_cloud_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 27ccda4

Please sign in to comment.