Skip to content

Commit

Permalink
Merge pull request #132 from ImMin5/master
Browse files Browse the repository at this point in the history
Add in_used_by_count field at Disk of ComputeEngine
  • Loading branch information
ImMin5 authored Oct 24, 2024
2 parents 3e95600 + 211c823 commit f5594d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/spaceone/inventory/manager/compute_engine/disk_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,17 @@ def collect_cloud_service(self, params):
google_cloud_monitoring_filters = [
{"key": "resource.labels.device_name", "value": disk.get("name")}
]

in_used_by = self._get_in_used_by(disk.get("users", []))

disk.update(
{
"project": secret_data["project_id"],
"id": disk_id,
"zone": zone,
"region": region,
"in_used_by": self._get_in_used_by(disk.get("users", [])),
"in_used_by": in_used_by,
"in_used_by_count_display": len(in_used_by),
"source_image_display": self._get_source_image_display(disk),
"disk_type": disk_type,
"snapshot_schedule": self._get_matched_snapshot_schedule_detail(
Expand Down Expand Up @@ -183,7 +187,7 @@ def _get_matched_snapshot_schedule_detail(self, region, disk, resource_policies)
"max_retention_days_display": str(
retention.get("maxRetentionDays")
)
+ " days"
+ " days"
}
)
policy_schedule = snapshot_schedule_policy.get("schedule", {})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ query_options:
- key: data.zone
name: Availability Zone
search_key: data.zone
- key: data.in_used_by_count_display
name: In Used By Count
fields:
value:
operator: count
unit: Count
namespace_id: ns-google-cloud-ce-disk
version: '1.1'
version: '1.2'
1 change: 1 addition & 0 deletions src/spaceone/inventory/model/compute_engine/disk/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Disk(BaseResource):
read_throughput = FloatType(serialize_when_none=False)
write_throughput = FloatType(serialize_when_none=False)
in_used_by = ListType(StringType(), default=[])
in_used_by_count_display = IntType(serialize_when_none=False, default=0)
source_image_display = StringType(serialize_when_none=False)
source_image_id = StringType(
deserialize_from="sourceImageId", serialize_when_none=False
Expand Down

0 comments on commit f5594d2

Please sign in to comment.