Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the issue which when quota is None report error and change filesystem used capacity #599

Merged
merged 10 commits into from
Jun 17, 2021
4 changes: 2 additions & 2 deletions delfin/drivers/dell_emc/unity/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 24 additions & 6 deletions delfin/drivers/dell_emc/unity/unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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':
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
48 changes: 27 additions & 21 deletions delfin/tests/unit/drivers/dell_emc/unity/test_emc_unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
"content": {
"id": "fs_1",
"type": 1,
"flrVersion": 0,
"flrVersion": 1,
"supportedProtocols": 2,
"health": {
"value": 5,
Expand Down Expand Up @@ -804,7 +804,7 @@
"content": {
"id": "fs_3",
"type": 1,
"flrVersion": 0,
"flrVersion": 2,
"supportedProtocols": 2,
"health": {
"value": 5,
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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 = {
Expand All @@ -1072,7 +1078,7 @@
}
qtree_result = [
{
'name': 'qtree_1',
'name': '/',
'storage_id': '12345',
'native_qtree_id': 'qtree_1',
'native_filesystem_id': 'filesystem_1',
Expand Down