diff --git a/delfin/drivers/dell_emc/unity/rest_handler.py b/delfin/drivers/dell_emc/unity/rest_handler.py index 10ecea856..7b5e1a9f5 100644 --- a/delfin/drivers/dell_emc/unity/rest_handler.py +++ b/delfin/drivers/dell_emc/unity/rest_handler.py @@ -216,8 +216,8 @@ def get_port_interface(self): def get_all_filesystems(self): url = '%s?%s' % (RestHandler.REST_FILESYSTEM_URL, - 'fields=id,name,health,sizeAllocated,' - 'sizeTotal,sizeUsed,isThinEnabled,pool') + 'fields=id,name,health,sizeAllocated,accessPolicy,' + 'sizeTotal,sizeUsed,isThinEnabled,pool,flrVersion') result_json = self.get_rest_info(url) return result_json diff --git a/delfin/drivers/dell_emc/unity/unity.py b/delfin/drivers/dell_emc/unity/unity.py index f4683ffa1..a497911b0 100644 --- a/delfin/drivers/dell_emc/unity/unity.py +++ b/delfin/drivers/dell_emc/unity/unity.py @@ -28,6 +28,15 @@ class UnityStorDriver(driver.StorageDriver): """UnityStorDriver implement the DELL EMC Storage driver""" HEALTH_OK = (5, 7) + FILESYSTEM_FLR_MAP = {0: constants.WORMType.NON_WORM, + 1: constants.WORMType.ENTERPRISE, + 2: constants.WORMType.COMPLIANCE + } + FILESYSTEM_SECURITY_MAP = {0: constants.NASSecurityMode.NATIVE, + 1: constants.NASSecurityMode.UNIX, + 2: constants.NASSecurityMode.NTFS + } + def __init__(self, **kwargs): super().__init__(**kwargs) self.rest_handler = rest_handler.RestHandler(**kwargs) @@ -364,6 +373,14 @@ def list_filesystems(self, context): fs_type = constants.VolumeType.THICK if content.get('isThinEnabled') is True: fs_type = constants.VolumeType.THIN + worm = UnityStorDriver.FILESYSTEM_FLR_MAP.get( + content.get('flrVersion'), + constants.WORMType.NON_WORM) + security_model = \ + UnityStorDriver.FILESYSTEM_SECURITY_MAP.get( + content.get('accessPolicy'), + constants.NASSecurityMode.NATIVE + ) fs = { 'name': content.get('name'), 'storage_id': self.storage_id, @@ -372,10 +389,11 @@ def list_filesystems(self, context): 'status': status, 'type': fs_type, 'total_capacity': int(content.get('sizeTotal')), - 'used_capacity': int(content.get('sizeAllocated')), + 'used_capacity': int(content.get('sizeUsed')), 'free_capacity': int(content.get('sizeTotal')) - int( - content.get('sizeAllocated')), - 'worm': constants.WORMType.NON_WORM + content.get('sizeUsed')), + 'worm': worm, + 'security_mode': security_model } fs_list.append(fs) return fs_list @@ -395,7 +413,7 @@ def list_qtrees(self, context): path = '/%s%s' % (content.get('filesystem').get('id'), content.get('path')) qt = { - 'name': content.get('id'), + 'name': content.get('path'), 'storage_id': self.storage_id, 'native_qtree_id': content.get('id'), 'native_filesystem_id': @@ -464,7 +482,7 @@ def get_tree_quotas(self): quota_configs = self.rest_handler.get_quota_configs() qts = self.rest_handler.get_all_qtrees() if qts is None: - return + return quotas_list qt_entries = qts.get('entries') conf_entries = quota_configs.get('entries') for quota in qt_entries: @@ -508,7 +526,7 @@ def get_user_quotas(self): quota_configs = self.rest_handler.get_quota_configs() user_qts = self.rest_handler.get_all_userquotas() if user_qts is None: - return + return quotas_list conf_entries = quota_configs.get('entries') user_entries = user_qts.get('entries') for user_quota in user_entries: diff --git a/delfin/tests/unit/drivers/dell_emc/unity/test_emc_unity.py b/delfin/tests/unit/drivers/dell_emc/unity/test_emc_unity.py index cf5d63ba1..04bbd7d03 100644 --- a/delfin/tests/unit/drivers/dell_emc/unity/test_emc_unity.py +++ b/delfin/tests/unit/drivers/dell_emc/unity/test_emc_unity.py @@ -763,7 +763,7 @@ "content": { "id": "fs_1", "type": 1, - "flrVersion": 0, + "flrVersion": 1, "supportedProtocols": 2, "health": { "value": 5, @@ -804,7 +804,7 @@ "content": { "id": "fs_3", "type": 1, - "flrVersion": 0, + "flrVersion": 2, "supportedProtocols": 2, "health": { "value": 5, @@ -991,9 +991,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 5368709120, - 'used_capacity': 283148288, - 'free_capacity': 5085560832, - 'worm': 'non_worm' + 'used_capacity': 1622450176, + 'free_capacity': 3746258944, + 'worm': 'enterprise', + 'security_mode': 'native' }, { 'name': 'ddd', 'storage_id': '12345', @@ -1002,9 +1003,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 107374182400, - 'used_capacity': 283140096, - 'free_capacity': 107091042304, - 'worm': 'non_worm' + 'used_capacity': 1620303872, + 'free_capacity': 105753878528, + 'worm': 'compliance', + 'security_mode': 'native' }, { 'name': 'fs_home', 'storage_id': '12345', @@ -1013,9 +1015,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 10737418240, - 'used_capacity': 283156480, - 'free_capacity': 10454261760, - 'worm': 'non_worm' + 'used_capacity': 1622458368, + 'free_capacity': 9114959872, + 'worm': 'non_worm', + 'security_mode': 'native' }, { 'name': 'fs_boga', 'storage_id': '12345', @@ -1024,9 +1027,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 5368709120, - 'used_capacity': 283148288, - 'free_capacity': 5085560832, - 'worm': 'non_worm' + 'used_capacity': 1622450176, + 'free_capacity': 3746258944, + 'worm': 'non_worm', + 'security_mode': 'native' }, { 'name': 'fs2', 'storage_id': '12345', @@ -1035,9 +1039,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 5368709120, - 'used_capacity': 283148288, - 'free_capacity': 5085560832, - 'worm': 'non_worm' + 'used_capacity': 1622450176, + 'free_capacity': 3746258944, + 'worm': 'non_worm', + 'security_mode': 'native' }, { 'name': 'FS_MULTI1', 'storage_id': '12345', @@ -1046,9 +1051,10 @@ 'status': 'normal', 'type': 'thin', 'total_capacity': 107374182400, - 'used_capacity': 283140096, - 'free_capacity': 107091042304, - 'worm': 'non_worm' + 'used_capacity': 1620303872, + 'free_capacity': 105753878528, + 'worm': 'non_worm', + 'security_mode': 'native' } ] GET_ALL_QTREE = { @@ -1072,7 +1078,7 @@ } qtree_result = [ { - 'name': 'qtree_1', + 'name': '/', 'storage_id': '12345', 'native_qtree_id': 'qtree_1', 'native_filesystem_id': 'filesystem_1',