Skip to content

Commit 7ff5289

Browse files
authored
Merge pull request cloudforet-io#82 from ImMin5/feature-fix-collect-storage-account-size-too-big
Feature fix collect storage account size too big
2 parents b79ce0c + c964dde commit 7ff5289

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

src/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.6.15
1+
v1.6.16

src/spaceone/inventory/manager/storage_accounts/instance_manager.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import datetime
2-
import time
32
import logging
3+
import time
4+
45
from spaceone.inventory.libs.manager import AzureManager
56
from spaceone.inventory.libs.schema.base import ReferenceModel
67
from spaceone.inventory.connector.storage_accounts import StorageAccountsConnector
@@ -9,7 +10,6 @@
910
from spaceone.inventory.model.storage_accounts.cloud_service_type import CLOUD_SERVICE_TYPES
1011
from spaceone.inventory.model.storage_accounts.data import *
1112

12-
1313
_LOGGER = logging.getLogger(__name__)
1414

1515

@@ -58,11 +58,11 @@ def collect_cloud_service(self, params):
5858
})
5959

6060
if storage_account_dict.get('name') is not None:
61-
container_item = self.list_blob_containers(storage_account_conn, resource_group, storage_account_dict['name'])
62-
storage_account_dict.update({
63-
'container_item': container_item,
64-
'container_count_display': len(container_item)
65-
})
61+
container_count = self.get_blob_containers_count(storage_account_conn, resource_group,
62+
storage_account_dict['name'])
63+
64+
storage_account_dict.update({'container_count_display': container_count})
65+
_LOGGER.debug(f'[collect_cloud_service] {storage_account_id} container count : {container_count}')
6666

6767
if storage_account_dict.get('routing_preference') is not None:
6868
storage_account_dict.update({
@@ -93,9 +93,9 @@ def collect_cloud_service(self, params):
9393
'instance_type': storage_account_data.sku.tier
9494
})
9595

96+
9697
# Must set_region_code method for region collection
9798
self.set_region_code(storage_account_data['location'])
98-
# _LOGGER.debug(f'[STORAGE ACCOUNT INFO] {storage_account_resource.to_primitive()}')
9999
storage_account_responses.append(StorageAccountResponse({'resource': storage_account_resource}))
100100

101101
except Exception as e:
@@ -120,7 +120,8 @@ def get_network_rule_set(self, network_rule_dict):
120120
'virtual_networks': self.get_virtual_network_names(network_rule_dict['virtual_network_rules']),
121121
'is_public_access_allowed': False
122122
})
123-
if not network_rule_dict.get('virtual_network_rules'): # if virtual_network_rules are empty, this SA is public allowable
123+
if not network_rule_dict.get(
124+
'virtual_network_rules'): # if virtual_network_rules are empty, this SA is public allowable
124125
network_rule_dict.update({
125126
'is_public_access_allowed': True
126127
})
@@ -258,3 +259,9 @@ def _get_timespan_from_now(hours):
258259
time_now = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
259260
time_now_hours_ago = time_now - datetime.timedelta(hours=hours)
260261
return "{}/{}".format(time_now_hours_ago, time_now)
262+
263+
@staticmethod
264+
def get_blob_containers_count(storage_conn, rg_name, account_name):
265+
blob_containers_obj = storage_conn.list_blob_containers(rg_name=rg_name, account_name=account_name)
266+
return len(list(blob_containers_obj))
267+

src/spaceone/inventory/model/storage_accounts/cloud_service.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@
5454
TextDyField.data_source('Internet Endpoints', 'data.routing_preference.publish_internet_endpoints')
5555
])
5656

57-
# TAB - Containers
58-
storage_account_containers = TableDynamicLayout.set_fields('Containers', 'data.container_item', fields=[
59-
TextDyField.data_source('Name', 'name'),
60-
TextDyField.data_source('Public Access Level', 'public_access'),
61-
DateTimeDyField.data_source('Last Modified', 'last_modified_time'),
62-
TextDyField.data_source('ETAG', 'etag'),
63-
TextDyField.data_source('Lease Status', 'lease_status'),
64-
TextDyField.data_source('Lease State', 'lease_state'),
65-
TextDyField.data_source('Lease Duration', 'lease_duration'),
66-
TextDyField.data_source('Encryption Score', 'default_encryption_scope')
67-
68-
])
69-
7057
# TAB - Encryption
7158
storage_account_encryption = ItemDynamicLayout.set_fields('Encryption', 'data.encryption', fields=[
7259
TextDyField.data_source('Key Source', 'key_source'),
@@ -89,8 +76,8 @@
8976
])
9077

9178
storage_account_meta = CloudServiceMeta.set_layouts(
92-
[storage_account_info_meta, storage_group_networking, storage_account_primary_endpoints, storage_account_containers,
93-
storage_account_encryption, storage_account_geo_replication])
79+
[storage_account_info_meta, storage_group_networking, storage_account_primary_endpoints, storage_account_encryption,
80+
storage_account_geo_replication])
9481

9582

9683
class StorageResource(CloudServiceResource):

0 commit comments

Comments
 (0)