diff --git a/src/spaceone/inventory/manager/compute_engine/disk_manager.py b/src/spaceone/inventory/manager/compute_engine/disk_manager.py index d812af0..e82bdd2 100644 --- a/src/spaceone/inventory/manager/compute_engine/disk_manager.py +++ b/src/spaceone/inventory/manager/compute_engine/disk_manager.py @@ -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( @@ -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", {}) diff --git a/src/spaceone/inventory/metrics/ComputeEngine/Disk/disk_count.yaml b/src/spaceone/inventory/metrics/ComputeEngine/Disk/disk_count.yaml index 7101cbe..1528bb3 100644 --- a/src/spaceone/inventory/metrics/ComputeEngine/Disk/disk_count.yaml +++ b/src/spaceone/inventory/metrics/ComputeEngine/Disk/disk_count.yaml @@ -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' \ No newline at end of file +version: '1.2' \ No newline at end of file diff --git a/src/spaceone/inventory/model/compute_engine/disk/data.py b/src/spaceone/inventory/model/compute_engine/disk/data.py index 7e90bdc..a3ff238 100644 --- a/src/spaceone/inventory/model/compute_engine/disk/data.py +++ b/src/spaceone/inventory/model/compute_engine/disk/data.py @@ -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