From 7cf95a4ec877149793de7fe6ef8d3d7fc516e040 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 16 Jan 2023 10:50:18 +0800 Subject: [PATCH 1/3] add PowerStore file --- delfin/common/constants.py | 1 + delfin/drivers/dell_emc/power_store/consts.py | 66 ++++ .../dell_emc/power_store/power_store.py | 24 +- .../dell_emc/power_store/rest_handler.py | 192 ++++++++++- .../dell_emc/power_store/test_power_store.py | 324 +++++++++++++++++- 5 files changed, 595 insertions(+), 12 deletions(-) diff --git a/delfin/common/constants.py b/delfin/common/constants.py index a4393dae6..57d1f5074 100644 --- a/delfin/common/constants.py +++ b/delfin/common/constants.py @@ -602,6 +602,7 @@ class FileSystemMetric: THROUGHPUT = Metrics.THROUGHPUT READ_THROUGHPUT = Metrics.READ_THROUGHPUT WRITE_THROUGHPUT = Metrics.WRITE_THROUGHPUT + RESPONSE_TIME = Metrics.RESPONSE_TIME READ_RESPONSE_TIME = Metrics.READ_RESPONSE_TIME WRITE_RESPONSE_TIME = Metrics.WRITE_RESPONSE_TIME IO_SIZE = Metrics.IO_SIZE diff --git a/delfin/drivers/dell_emc/power_store/consts.py b/delfin/drivers/dell_emc/power_store/consts.py index 8e9226a05..e334dacab 100644 --- a/delfin/drivers/dell_emc/power_store/consts.py +++ b/delfin/drivers/dell_emc/power_store/consts.py @@ -155,6 +155,7 @@ class DiskType(object): PERFORMANCE_METRICS_BY_VOLUME = 'performance_metrics_by_volume' PERFORMANCE_METRICS_BY_NODE = 'performance_metrics_by_node' PERFORMANCE_METRICS_BY_FE_FC_PORT = 'performance_metrics_by_fe_fc_port' +PERFORMANCE_METRICS_BY_FILE_SYSTEM = 'performance_metrics_by_file_system' PERFORMANCE_METRICS_INTERVAL = 'Twenty_Sec' PERF_INTERVAL = 20 @@ -452,3 +453,68 @@ class DiskType(object): "description": constants.PortMetric.WRITE_IO_SIZE.description } } +FILE_SYSTEM_CAP = { + constants.FileSystemMetric.IOPS.name: { + "unit": constants.FileSystemMetric.IOPS.unit, + "description": constants.FileSystemMetric.IOPS.description + }, + constants.FileSystemMetric.READ_IOPS.name: { + "unit": constants.FileSystemMetric.READ_IOPS.unit, + "description": constants.FileSystemMetric.READ_IOPS.description + }, + constants.FileSystemMetric.WRITE_IOPS.name: { + "unit": constants.FileSystemMetric.WRITE_IOPS.unit, + "description": constants.FileSystemMetric.WRITE_IOPS.description + }, + constants.FileSystemMetric.THROUGHPUT.name: { + "unit": constants.FileSystemMetric.THROUGHPUT.unit, + "description": constants.FileSystemMetric.THROUGHPUT.description + }, + constants.FileSystemMetric.READ_THROUGHPUT.name: { + "unit": constants.FileSystemMetric.READ_THROUGHPUT.unit, + "description": constants.FileSystemMetric.READ_THROUGHPUT.description + }, + constants.FileSystemMetric.WRITE_THROUGHPUT.name: { + "unit": constants.FileSystemMetric.WRITE_THROUGHPUT.unit, + "description": constants.FileSystemMetric.WRITE_THROUGHPUT.description + }, + constants.FileSystemMetric.RESPONSE_TIME.name: { + "unit": constants.FileSystemMetric.RESPONSE_TIME.unit, + "description": constants.FileSystemMetric.RESPONSE_TIME.description + }, + constants.FileSystemMetric.READ_RESPONSE_TIME.name: { + "unit": constants.FileSystemMetric.READ_RESPONSE_TIME.unit, + "description": + constants.FileSystemMetric.READ_RESPONSE_TIME.description + }, + constants.FileSystemMetric.WRITE_RESPONSE_TIME.name: { + "unit": constants.FileSystemMetric.WRITE_RESPONSE_TIME.unit, + "description": + constants.FileSystemMetric.WRITE_RESPONSE_TIME.description + }, + constants.FileSystemMetric.IO_SIZE.name: { + "unit": constants.FileSystemMetric.IO_SIZE.unit, + "description": constants.FileSystemMetric.IO_SIZE.description + }, + constants.FileSystemMetric.READ_IO_SIZE.name: { + "unit": constants.FileSystemMetric.READ_IO_SIZE.unit, + "description": constants.FileSystemMetric.READ_IO_SIZE.description + }, + constants.FileSystemMetric.WRITE_IO_SIZE.name: { + "unit": constants.FileSystemMetric.WRITE_IO_SIZE.unit, + "description": constants.FileSystemMetric.WRITE_IO_SIZE.description + } +} +FS_TYPE_MAP = { + 'Primary': constants.FSType.THIN, + 'Snapshot': constants.FSType.THICK +} +FS_SECURITY_MODE_MAP = { + 'Native': constants.NASSecurityMode.NATIVE, + 'UNIX': constants.NASSecurityMode.UNIX, + 'Windows': constants.NASSecurityMode.NTFS +} +POOL_MODE_MAP = { + 'Unified': constants.StorageType.UNIFIED, + 'Block optimized': constants.StorageType.BLOCK +} diff --git a/delfin/drivers/dell_emc/power_store/power_store.py b/delfin/drivers/dell_emc/power_store/power_store.py index d0e3472a6..24ff942e9 100644 --- a/delfin/drivers/dell_emc/power_store/power_store.py +++ b/delfin/drivers/dell_emc/power_store/power_store.py @@ -139,6 +139,15 @@ def collect_perf_metrics(self, context, storage_id, resource_metrics, LOG.info('The system(storage_id: %s) stop to collect port' ' performance, The length is: %s', storage_id, len(fc_port_metrics)) + if resource_metrics.get(constants.ResourceType.FILESYSTEM): + file_system_metrics = self.rest_handler.get_file_system_metrics( + storage_id, + resource_metrics.get(constants.ResourceType.FILESYSTEM), + start_time, end_time) + metrics.extend(file_system_metrics) + LOG.info('The system(storage_id: %s) stop to collect file_system ' + 'performance, The length is: %s', + storage_id, len(file_system_metrics)) return metrics @staticmethod @@ -150,7 +159,8 @@ def get_capabilities(context, filters=None): constants.ResourceType.STORAGE_POOL: consts.STORAGE_POOL_CAP, constants.ResourceType.VOLUME: consts.VOLUME_CAP, constants.ResourceType.CONTROLLER: consts.CONTROLLER_CAP, - constants.ResourceType.PORT: consts.PORT_CAP + constants.ResourceType.PORT: consts.PORT_CAP, + constants.ResourceType.FILESYSTEM: consts.FILE_SYSTEM_CAP } } @@ -171,3 +181,15 @@ def list_volume_groups(self, context): def list_masking_views(self, context): return self.rest_handler.list_masking_views(self.storage_id) + + def list_filesystems(self, context): + return self.rest_handler.list_filesystems(self.storage_id) + + def list_quotas(self, context): + return self.rest_handler.list_quotas(self.storage_id) + + def list_qtrees(self, context): + return self.rest_handler.list_qtrees(self.storage_id) + + def list_shares(self, context): + return self.rest_handler.list_shares(self.storage_id) diff --git a/delfin/drivers/dell_emc/power_store/rest_handler.py b/delfin/drivers/dell_emc/power_store/rest_handler.py index 9c189f5a5..8d0a0ff1b 100644 --- a/delfin/drivers/dell_emc/power_store/rest_handler.py +++ b/delfin/drivers/dell_emc/power_store/rest_handler.py @@ -37,7 +37,7 @@ class RestHandler(RestClient): REST_CLUSTER_URL = \ '/api/rest/cluster?select=name,compatibility_level,global_id,state,' \ 'primary_appliance_id,id,system_time&limit=2000&offset={}' - REST_APPLIANCE_URL = '/api/rest/appliance?select=id,name,model' \ + REST_APPLIANCE_URL = '/api/rest/appliance?select=id,name,model,mode' \ '&limit=2000&offset={}' REST_SOFTWARE_INSTALLED_URL = \ '/api/rest/software_installed?select=id,release_version,' \ @@ -86,11 +86,25 @@ class RestHandler(RestClient): '/api/rest/ip_pool_address?select=id,name,address,appliance_id,' \ 'node_id,purposes&limit=2000&offset={}' REST_METRICS_ARCHIVE_URL = '/api/rest/metrics_archive' - REST_FILE_SYSTEM_URL = '/api/rest/file_system' - REST_FILE_TREE_QUOTA_URL = '/api/rest/file_tree_quota' - REST_SMB_SHARE_URL = '/api/rest/smb_share' - REST_NFS_SERVER_URL = '/api/rest/nfs_server' - REST_FILE_USER_QUOTA_URL = '/api/rest/file_user_quota' + REST_FILE_SYSTEM_URL = \ + '/api/rest/file_system?select=id,name,access_policy,filesystem_type,' \ + 'size_total,size_used,nas_server_id&limit=2000&offset={}' + REST_FILE_TREE_QUOTA_URL = \ + '/api/rest/file_tree_quota?select=id,file_system_id,path,' \ + 'description,is_user_quotas_enforced,state,hard_limit,soft_limit,' \ + 'size_used&limit=2000&offset={}' + REST_SMB_SHARE_URL = \ + '/api/rest/smb_share?select=id,name,file_system_id,path' \ + '&limit=2000&offset={}' + REST_NFS_EXPORT_URL = \ + '/api/rest/nfs_export?select=id,name,description,file_system,path' \ + '&limit=2000&offset={}' + REST_NAS_SERVER_URL = \ + '/api/rest/nas_server?select=id,name&limit=2000&offset={}' + REST_FILE_USER_QUOTA_URL = \ + '/api/rest/file_user_quota?select=id,uid,hard_limit,size_used,' \ + 'soft_limit,state,tree_quota_id,unix_name,windows_name,windows_sid,' \ + 'file_system_id&limit=2000&offset={}' AUTH_KEY = 'DELL-EMC-TOKEN' def __init__(self, **kwargs): @@ -235,7 +249,8 @@ def get_storage_pools(self, storage_id): 'storage_id': storage_id, 'native_storage_pool_id': appliance_id, 'status': constants.StoragePoolStatus.NORMAL, - 'storage_type': constants.StorageType.BLOCK, + 'storage_type': consts.POOL_MODE_MAP.get( + appliance.get('mode'), constants.StorageType.BLOCK), 'total_capacity': total_capacity, 'used_capacity': used_capacity, 'free_capacity': total_capacity - used_capacity @@ -885,6 +900,26 @@ def get_fc_port_metrics(self, storage_id, resource_metrics, start_time, fc_port_metrics_list.extend(fc_port_metrics) return fc_port_metrics_list + def get_file_system_metrics(self, storage_id, resource_metrics, start_time, + end_time): + file_system_metrics_list = [] + file_systems = self.rest_call(self.REST_FILE_SYSTEM_URL) + for file_system in file_systems: + file_system_id = file_system.get('id') + file_system_name = file_system.get('name') + if not file_system_id or not file_system_name: + continue + data = {'entity': consts.PERFORMANCE_METRICS_BY_FILE_SYSTEM, + 'entity_id': file_system_id, + 'interval': consts.PERFORMANCE_METRICS_INTERVAL} + packaging_data = self.package_data(data, end_time, start_time) + file_system_metrics = self.set_metrics_data( + file_system_id, file_system_name, packaging_data, + resource_metrics, constants.ResourceType.FILESYSTEM, + storage_id) + file_system_metrics_list.extend(file_system_metrics) + return file_system_metrics_list + @staticmethod def set_metrics_data(resource_id, resource_name, packaging_data, resource_metrics, resource_type, storage_id): @@ -940,6 +975,7 @@ def package_data(self, data, end_time, start_time): continue duplicate.add(about_timestamp) cpu_utilization = perf.get('io_workload_cpu_utilization') + avg_io_size = perf.get('avg_io_size') metrics_d = { 'iops': Decimal(str(perf.get('total_iops'))).quantize( Decimal('0'), rounding="ROUND_HALF_UP"), @@ -959,7 +995,8 @@ def package_data(self, data, end_time, start_time): perf.get('avg_read_latency') / units.k, 3), "writeResponseTime": round( perf.get('avg_write_latency') / units.k, 3), - "ioSize": round(perf.get('avg_io_size') / units.Ki, 3), + "ioSize": round(perf.get('avg_size') / units.Ki, 3) if + avg_io_size is None else round(avg_io_size / units.Ki, 3), "readIoSize": round( perf.get('avg_read_size') / units.Ki, 3), "writeIoSize": round( @@ -983,3 +1020,142 @@ def get_system_time(self): timestamp = int((timestamp_s + time_difference) * units.k)\ if system_time else None return timestamp + + def list_filesystems(self, storage_id): + list_filesystems = [] + file_system_list = self.rest_call(self.REST_FILE_SYSTEM_URL) + for file_system in file_system_list: + fs_type = file_system.get('filesystem_type') + total_capacity = int(file_system.get('size_total')) + used_capacity = int(file_system.get('size_used')) + file_dict = { + 'native_filesystem_id': file_system.get('id'), + 'name': file_system.get('name'), + 'type': consts.FS_TYPE_MAP.get(fs_type, constants.FSType.THIN), + 'status': constants.FilesystemStatus.NORMAL, + 'storage_id': storage_id, + 'total_capacity': total_capacity, + 'used_capacity': used_capacity, + 'free_capacity': total_capacity - used_capacity, + 'security_mode': consts.FS_SECURITY_MODE_MAP.get( + file_system.get('access_policy'), + constants.NASSecurityMode.MIXED) + } + list_filesystems.append(file_dict) + return list_filesystems + + def list_qtrees(self, storage_id): + list_qtrees = [] + nas_dict = {} + nas_server_list = self.rest_call(self.REST_NAS_SERVER_URL) + for nas_server in nas_server_list: + nas_server_id = nas_server.get('id') + nas_server_name = nas_server.get('name') + nas_dict[nas_server_id] = nas_server_name + file_system_list = self.rest_call(self.REST_FILE_SYSTEM_URL) + for file_system in file_system_list: + file_system_id = file_system.get('id') + file_system_name = file_system.get('name') + nas_server_id = file_system.get('nas_server_id') + nas_server_name = nas_dict.get(nas_server_id) + native_qtree_id = f'{nas_server_id}{file_system_id}' + name = f'NAS Servers Name:{nas_server_name}' \ + f'@File Systems Name:{file_system_name}' + qtrees_dict = { + 'native_qtree_id': hashlib.md5( + native_qtree_id.encode()).hexdigest(), + 'name': name, + 'storage_id': storage_id, + 'native_filesystem_id': file_system_id, + 'path': name, + 'security_mode': consts.FS_SECURITY_MODE_MAP.get( + file_system.get('access_policy'), + constants.NASSecurityMode.MIXED) + } + list_qtrees.append(qtrees_dict) + return list_qtrees + + def list_quotas(self, storage_id): + list_quotas = [] + qtree_dict = self.get_qtree_id(storage_id) + tree_quota_list = self.rest_call(self.REST_FILE_TREE_QUOTA_URL) + for tree_quota in tree_quota_list: + file_system_id = tree_quota.get('file_system_id') + tree_quotas_dict = { + 'native_quota_id': tree_quota.get('id'), + 'type': constants.QuotaType.TREE, + 'storage_id': storage_id, + 'native_filesystem_id': file_system_id, + 'native_qtree_id': qtree_dict.get(file_system_id), + 'capacity_hard_limit': tree_quota.get('hard_limit'), + 'capacity_soft_limit': tree_quota.get('soft_limit'), + 'used_capacity': tree_quota.get('size_used') + } + list_quotas.append(tree_quotas_dict) + user_quota_list = self.rest_call(self.REST_FILE_USER_QUOTA_URL) + for user_quota in user_quota_list: + user_group_name = user_quota.get('unix_name') + windows_name = user_quota.get('windows_name') + windows_sid = user_quota.get('windows_sid') + uid = user_quota.get('uid') + if windows_name: + user_group_name = windows_name + if windows_sid: + user_group_name = windows_sid + if uid: + user_group_name = uid + file_system_id = user_quota.get('file_system_id') + user_quotas_dict = { + 'native_quota_id': user_quota.get('id'), + 'type': constants.QuotaType.USER, + 'storage_id': storage_id, + 'native_filesystem_id': user_quota.get('file_system_id'), + 'native_qtree_id': qtree_dict.get(file_system_id), + 'capacity_hard_limit': user_quota.get('hard_limit'), + 'capacity_soft_limit': user_quota.get('soft_limit'), + 'used_capacity': user_quota.get('size_used'), + 'user_group_name': user_group_name + } + list_quotas.append(user_quotas_dict) + return list_quotas + + def get_qtree_id(self, storage_id): + qtree_dict = {} + list_qtrees = self.list_qtrees(storage_id) + for qtrees in list_qtrees: + native_qtree_id = qtrees.get('native_qtree_id') + native_filesystem_id = qtrees.get('native_filesystem_id') + qtree_dict[native_filesystem_id] = native_qtree_id + return qtree_dict + + def list_shares(self, storage_id): + list_shares = [] + qtree_dict = self.get_qtree_id(storage_id) + nfs_list = self.rest_call(self.REST_NFS_EXPORT_URL) + for nfs in nfs_list: + file_system_id = nfs.get('file_system', {}).get('id') + nfs_dict = { + 'native_share_id': nfs.get('id'), + 'name': nfs.get('name'), + 'storage_id': storage_id, + 'native_filesystem_id': file_system_id, + 'native_qtree_id': qtree_dict.get(file_system_id), + 'protocol': constants.ShareProtocol.NFS, + 'path': nfs.get('path') + } + list_shares.append(nfs_dict) + shares_list = self.rest_call(self.REST_SMB_SHARE_URL) + for shares in shares_list: + shares_path = shares.get('path') + file_system_id = shares.get('file_system_id') + shares_dict = { + 'native_share_id': shares.get('id'), + 'name': shares.get('name'), + 'storage_id': storage_id, + 'native_filesystem_id': file_system_id, + 'native_qtree_id': qtree_dict.get(file_system_id), + 'protocol': constants.ShareProtocol.CIFS, + 'path': shares_path + } + list_shares.append(shares_dict) + return list_shares diff --git a/delfin/tests/unit/drivers/dell_emc/power_store/test_power_store.py b/delfin/tests/unit/drivers/dell_emc/power_store/test_power_store.py index 6fa91b514..1d3a7bb9e 100644 --- a/delfin/tests/unit/drivers/dell_emc/power_store/test_power_store.py +++ b/delfin/tests/unit/drivers/dell_emc/power_store/test_power_store.py @@ -815,7 +815,8 @@ constants.ResourceType.STORAGE_POOL: consts.STORAGE_POOL_CAP, constants.ResourceType.VOLUME: consts.VOLUME_CAP, constants.ResourceType.CONTROLLER: consts.CONTROLLER_CAP, - constants.ResourceType.PORT: consts.PORT_CAP + constants.ResourceType.PORT: consts.PORT_CAP, + constants.ResourceType.FILESYSTEM: consts.FILE_SYSTEM_CAP } host_info = [ { @@ -1010,6 +1011,261 @@ 'native_volume_id': '40ce0f3c-d250-4efc-b78a-1b1c768788f4', 'storage_id': '12345', 'native_storage_host_group_id': 'ea01240f-4692-44f4-817b-924efd2c8519'}] +filesystems_info = [{ + "id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "access_policy": "Native", + "default_hard_limit": 1048576, + "default_soft_limit": 1048576, + "filesystem_type": "Primary", + "locking_policy": "Advisory", + "name": "test-f", + "nas_server_id": "63996302-335c-69d7-f8cf-9e521753d873", + "size_total": 5497558138880, + "size_used": 1623195648, +}] +filesystems_data = [ + {'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'name': 'test-f', 'type': 'thin', 'status': 'normal', + 'storage_id': '12345', 'total_capacity': 5497558138880, + 'used_capacity': 1623195648, 'free_capacity': 5495934943232, + 'security_mode': 'native'}] +nas_service_info = [{ + "id": "63996302-335c-69d7-f8cf-9e521753d873", + "name": "test" +}] +quotas_tree_info = [{ + "id": "00000003-0066-0000-0100-000000000000", + "file_system_id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "path": "/ques", + "description": "", + "is_user_quotas_enforced": True, + "state": "Ok", + "hard_limit": 1048576, + "soft_limit": 1048576, + "remaining_grace_period": -1, + "size_used": 0, + "grace_period": 604800 +}] +user_quotas = [{ + "id": "00000003-0066-0000-0000-000001000000", + "uid": 1, + "hard_limit": 1048576, + "remaining_grace_period": -1, + "size_used": 0, + "soft_limit": 1048576, + "state": "Ok", + "tree_quota_id": None, + "unix_name": None, + "windows_name": None, + "windows_sid": None, + "file_system_id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "file_system": { + "id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee" + }, + "tree_quota": None +}] +nfs_info = [ + { + "id": "6399654d-dd66-0173-9886-86754c57b7ee", + "name": "nfx-test", + "description": None, + "path": "/test-f", + "is_no_SUID": False, + "file_system": { + "id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee" + } + }, + { + "id": "639969bf-cd76-c446-5b99-86754c57b7ee", + "name": "test200", + "description": None, + "path": "/f_tdjc", + "is_no_SUID": False, + "file_system": { + "id": "63996981-1381-2c75-2797-86754c57b7ee" + } + }, + { + "id": "63a2a88f-4ac8-6d08-0b89-86754c57b7ee", + "name": "nfs", + "description": None, + "path": "/fs-01", + "is_no_SUID": False, + "file_system": { + "id": "63a2a7ee-a6c5-b413-eb0a-86754c57b7ee" + } + }, + { + "id": "63a3c04f-6529-5e00-ea38-86754c57b7ee", + "name": "nfs-02", + "description": None, + "path": "/test-f01", + "is_no_SUID": False, + "file_system": { + "id": "63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee" + } + }, + { + "id": "63aea932-ec10-1ea4-c191-86754c57b7ee", + "name": "1230-nfs", + "description": None, + "path": "/1230-fs", + "is_no_SUID": False, + "file_system": { + "id": "63aea92f-5c8d-2661-c162-86754c57b7ee" + } + } +] +smb_info = [ + { + "id": "6399654d-a337-9c17-8cb5-86754c57b7ee", + "file_system_id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "description": None, + "is_ABE_enabled": True, + "is_branch_cache_enabled": True, + "is_continuous_availability_enabled": True, + "is_encryption_enabled": True, + "name": "smb-test", + "offline_availability": "Manual", + "path": "/test-f", + "umask": "022", + "file_system": { + "id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee" + } + }, + { + "id": "639969d4-742b-cdda-5593-86754c57b7ee", + "file_system_id": "63996981-1381-2c75-2797-86754c57b7ee", + "description": None, + "is_ABE_enabled": False, + "is_branch_cache_enabled": False, + "is_continuous_availability_enabled": False, + "is_encryption_enabled": False, + "name": "smb200", + "offline_availability": "None", + "path": "/f_tdjc", + "umask": "022", + "file_system": { + "id": "63996981-1381-2c75-2797-86754c57b7ee" + } + }, + { + "id": "63a3c04f-fea3-92e2-a73a-86754c57b7ee", + "file_system_id": "63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee", + "description": None, + "is_ABE_enabled": False, + "is_branch_cache_enabled": False, + "is_continuous_availability_enabled": False, + "is_encryption_enabled": False, + "name": "smb-02", + "offline_availability": "Documents", + "path": "/test-f01", + "umask": "022", + "file_system": { + "id": "63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee" + } + }, + { + "id": "63aea653-7579-e0ac-b818-86754c57b7ee", + "file_system_id": "63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee", + "description": None, + "is_ABE_enabled": False, + "is_branch_cache_enabled": False, + "is_continuous_availability_enabled": False, + "is_encryption_enabled": False, + "name": "1230-snm", + "offline_availability": "Programs", + "path": "/test-f01", + "umask": "022", + "file_system": { + "id": "63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee" + } + }, + { + "id": "63aea932-5ced-a5dc-1862-86754c57b7ee", + "file_system_id": "63aea92f-5c8d-2661-c162-86754c57b7ee", + "description": None, + "is_ABE_enabled": False, + "is_branch_cache_enabled": False, + "is_continuous_availability_enabled": False, + "is_encryption_enabled": False, + "name": "1230-smb", + "offline_availability": "None", + "path": "/1230-fs", + "umask": "022", + "file_system": { + "id": "63aea92f-5c8d-2661-c162-86754c57b7ee" + } + } +] +shares_data = [ + {'native_share_id': '6399654d-dd66-0173-9886-86754c57b7ee', + 'name': 'nfx-test', 'storage_id': '12345', + 'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'native_qtree_id': '48452a5a7a620559759631caf7d34398', + 'protocol': 'nfs', 'path': '/test-f'}, + {'native_share_id': '639969bf-cd76-c446-5b99-86754c57b7ee', + 'name': 'test200', 'storage_id': '12345', + 'native_filesystem_id': '63996981-1381-2c75-2797-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'nfs', 'path': '/f_tdjc'}, + {'native_share_id': '63a2a88f-4ac8-6d08-0b89-86754c57b7ee', + 'name': 'nfs', 'storage_id': '12345', + 'native_filesystem_id': '63a2a7ee-a6c5-b413-eb0a-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'nfs', 'path': '/fs-01'}, + {'native_share_id': '63a3c04f-6529-5e00-ea38-86754c57b7ee', + 'name': 'nfs-02', 'storage_id': '12345', + 'native_filesystem_id': '63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'nfs', + 'path': '/test-f01'}, + {'native_share_id': '63aea932-ec10-1ea4-c191-86754c57b7ee', + 'name': '1230-nfs', 'storage_id': '12345', + 'native_filesystem_id': '63aea92f-5c8d-2661-c162-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'nfs', + 'path': '/1230-fs'}, + {'native_share_id': '6399654d-a337-9c17-8cb5-86754c57b7ee', + 'name': 'smb-test', 'storage_id': '12345', + 'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'native_qtree_id': '48452a5a7a620559759631caf7d34398', + 'protocol': 'cifs', 'path': '/test-f'}, + {'native_share_id': '639969d4-742b-cdda-5593-86754c57b7ee', + 'name': 'smb200', 'storage_id': '12345', + 'native_filesystem_id': '63996981-1381-2c75-2797-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'cifs', + 'path': '/f_tdjc'}, + {'native_share_id': '63a3c04f-fea3-92e2-a73a-86754c57b7ee', + 'name': 'smb-02', 'storage_id': '12345', + 'native_filesystem_id': '63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'cifs', + 'path': '/test-f01'}, + {'native_share_id': '63aea653-7579-e0ac-b818-86754c57b7ee', + 'name': '1230-snm', 'storage_id': '12345', + 'native_filesystem_id': '63a3c04c-bcf0-9ae9-8fd2-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'cifs', + 'path': '/test-f01'}, + {'native_share_id': '63aea932-5ced-a5dc-1862-86754c57b7ee', + 'name': '1230-smb', 'storage_id': '12345', + 'native_filesystem_id': '63aea92f-5c8d-2661-c162-86754c57b7ee', + 'native_qtree_id': None, 'protocol': 'cifs', + 'path': '/1230-fs'}] +quotas_data = [ + {'native_quota_id': '00000003-0066-0000-0100-000000000000', 'type': 'tree', + 'storage_id': '12345', + 'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'native_qtree_id': '48452a5a7a620559759631caf7d34398', + 'capacity_hard_limit': 1048576, 'capacity_soft_limit': 1048576, + 'used_capacity': 0}, + {'native_quota_id': '00000003-0066-0000-0000-000001000000', 'type': 'user', + 'storage_id': '12345', + 'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'native_qtree_id': '48452a5a7a620559759631caf7d34398', + 'capacity_hard_limit': 1048576, 'capacity_soft_limit': 1048576, + 'used_capacity': 0, 'user_group_name': 1}] +qtress_data = [{'native_qtree_id': '48452a5a7a620559759631caf7d34398', + 'name': 'NAS Servers Name:test@File Systems Name:test-f', + 'storage_id': '12345', + 'native_filesystem_id': '6399654a-36d7-2ed5-2e1e-86754c57b7ee', + 'path': 'NAS Servers Name:test@File Systems Name:test-f', + 'security_mode': 'native'}] cluster_perf_info = [ { "timestamp": "2022-11-28T02:59:20Z", @@ -1266,6 +1522,43 @@ "entity": "performance_metrics_by_fe_fc_port" } ] +filesystems_perf_info = [{ + "file_system_id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "timestamp": "2022-11-28T03:00:00Z", + "read_iops": 0.0, + "write_iops": 0.0, + "total_iops": 2, + "read_bandwidth": 0.0, + "write_bandwidth": 0.0, + "total_bandwidth": 0.0, + "avg_read_latency": 1024, + "avg_write_latency": 0, + "avg_latency": 0.0, + "avg_read_size": 0, + "avg_write_size": 0, + "avg_size": 156.3, + "repeat_count": 1, + "response_definition": "performance_metrics_by_file_system", + "entity": "performance_metrics_by_file_system" +}, { + "file_system_id": "6399654a-36d7-2ed5-2e1e-86754c57b7ee", + "timestamp": "2022-11-28T03:00:20Z", + "read_iops": 0.0, + "write_iops": 0.0, + "total_iops": 0.0, + "read_bandwidth": 0.0, + "write_bandwidth": 0.0, + "total_bandwidth": 0.0, + "avg_read_latency": 0, + "avg_write_latency": 0, + "avg_latency": 0.0, + "avg_read_size": 0, + "avg_write_size": 0, + "avg_size": 0.0, + "repeat_count": 1, + "response_definition": "performance_metrics_by_file_system", + "entity": "performance_metrics_by_file_system" +}] LOG = logging.getLogger(__name__) @@ -1367,13 +1660,13 @@ def test_get_access_url(self): self.assertEqual(url, url) def test_collect_perf_metrics(self): - RestHandler.rest_call = mock.Mock( side_effect=[clusters, cluster_perf_info, appliance, appliance_perf_info, perf_volume_info, volume_perf_info, hardware_info, perf_node_info, controllers_perf_info, - perf_fc_info, fc_perf_info]) + perf_fc_info, fc_perf_info, + filesystems_info, filesystems_perf_info]) collect = self.driver.collect_perf_metrics(context, ACCESS_INFO.get( 'storage_id'), resource_metrics, 1669604280000, 1669604580000) self.assertEqual(collect[0].values.get(1669604340000), 0) @@ -1417,3 +1710,28 @@ def test_list_masking_views(self): RestHandler.rest_call = mock.Mock(side_effect=[masking_info]) masking_views = self.driver.list_masking_views(context) self.assertEqual(masking_views, masking_data) + + def test_list_filesystems(self): + RestHandler.rest_call = mock.Mock(side_effect=[filesystems_info]) + filesystems = self.driver.list_filesystems(context) + self.assertListEqual(filesystems, filesystems_data) + + def test_list_quotas(self): + RestHandler.rest_call = mock.Mock( + side_effect=[nas_service_info, filesystems_info, + quotas_tree_info, user_quotas]) + quotas = self.driver.list_quotas(context) + self.assertListEqual(quotas, quotas_data) + + def test_list_qtrees(self): + RestHandler.rest_call = mock.Mock( + side_effect=[nas_service_info, filesystems_info]) + qtrees = self.driver.list_qtrees(context) + self.assertListEqual(qtrees, qtress_data) + + def test_list_shares(self): + RestHandler.rest_call = mock.Mock( + side_effect=[nas_service_info, filesystems_info, + nfs_info, smb_info]) + shares = self.driver.list_shares(context) + self.assertListEqual(shares, shares_data) From b02ccab26b7e5a33a27a20b64ddbf5559232a14d Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 16 Jan 2023 17:22:45 +0800 Subject: [PATCH 2/3] edit file system type --- delfin/drivers/dell_emc/power_store/consts.py | 3 +-- delfin/drivers/dell_emc/power_store/rest_handler.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/delfin/drivers/dell_emc/power_store/consts.py b/delfin/drivers/dell_emc/power_store/consts.py index e334dacab..bed49de5f 100644 --- a/delfin/drivers/dell_emc/power_store/consts.py +++ b/delfin/drivers/dell_emc/power_store/consts.py @@ -506,8 +506,7 @@ class DiskType(object): } } FS_TYPE_MAP = { - 'Primary': constants.FSType.THIN, - 'Snapshot': constants.FSType.THICK + 'Primary': constants.FSType.THIN } FS_SECURITY_MODE_MAP = { 'Native': constants.NASSecurityMode.NATIVE, diff --git a/delfin/drivers/dell_emc/power_store/rest_handler.py b/delfin/drivers/dell_emc/power_store/rest_handler.py index 8d0a0ff1b..b8f2ef733 100644 --- a/delfin/drivers/dell_emc/power_store/rest_handler.py +++ b/delfin/drivers/dell_emc/power_store/rest_handler.py @@ -1026,6 +1026,8 @@ def list_filesystems(self, storage_id): file_system_list = self.rest_call(self.REST_FILE_SYSTEM_URL) for file_system in file_system_list: fs_type = file_system.get('filesystem_type') + if 'Snapshot' == fs_type: + continue total_capacity = int(file_system.get('size_total')) used_capacity = int(file_system.get('size_used')) file_dict = { From 597a42f89fc3e25a6400c90d38393afd94f4d015 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Jan 2023 18:08:00 +0800 Subject: [PATCH 3/3] edit file_system_metrics --- delfin/drivers/dell_emc/power_store/rest_handler.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/delfin/drivers/dell_emc/power_store/rest_handler.py b/delfin/drivers/dell_emc/power_store/rest_handler.py index b8f2ef733..2f7b36802 100644 --- a/delfin/drivers/dell_emc/power_store/rest_handler.py +++ b/delfin/drivers/dell_emc/power_store/rest_handler.py @@ -905,6 +905,9 @@ def get_file_system_metrics(self, storage_id, resource_metrics, start_time, file_system_metrics_list = [] file_systems = self.rest_call(self.REST_FILE_SYSTEM_URL) for file_system in file_systems: + fs_type = file_system.get('filesystem_type') + if 'Snapshot' == fs_type: + continue file_system_id = file_system.get('id') file_system_name = file_system.get('name') if not file_system_id or not file_system_name: @@ -1056,6 +1059,9 @@ def list_qtrees(self, storage_id): nas_dict[nas_server_id] = nas_server_name file_system_list = self.rest_call(self.REST_FILE_SYSTEM_URL) for file_system in file_system_list: + fs_type = file_system.get('filesystem_type') + if 'Snapshot' == fs_type: + continue file_system_id = file_system.get('id') file_system_name = file_system.get('name') nas_server_id = file_system.get('nas_server_id')