Add the argument disk_type validation in the method DecortController.account_disks

This commit is contained in:
2024-07-22 16:32:49 +03:00
parent aefc920e1a
commit 0c0fde8470
2 changed files with 12 additions and 1 deletions

View File

@@ -141,7 +141,7 @@ class DecortAccountInfo(DecortController):
), ),
type=dict( type=dict(
type='str', type='str',
choices=['B', 'D'], choices=self.DISK_TYPES,
), ),
), ),
), ),

View File

@@ -121,6 +121,8 @@ class DecortController(object):
'STOPPING', 'STOPPING',
] ]
DISK_TYPES = ['B', 'D']
RESOURCE_GROUP_STATUSES = [ RESOURCE_GROUP_STATUSES = [
'CREATED', 'CREATED',
'DELETED', 'DELETED',
@@ -2448,6 +2450,15 @@ class DecortController(object):
`/cloudapi/account/listDisks`. `/cloudapi/account/listDisks`.
""" """
if disk_type and (
not disk_type in self.DISK_TYPES
):
self.result['msg'] = (
f'{disk_type} is not valid disk type'
f' for filtering account disk list.'
)
self.amodule.fail_json(**self.result)
sort_by = None sort_by = None
if sort_by_field: if sort_by_field:
if not sort_by_field in self.FIELDS_FOR_SORTING_ACCOUNT_DISK_LIST: if not sort_by_field in self.FIELDS_FOR_SORTING_ACCOUNT_DISK_LIST: