Implement functionality of the API method `/cloudapi/account/listFlipGroups`

main
Dmitriy Smirnov 7 months ago
parent ce54341a64
commit 0ca3399026

@ -6,7 +6,7 @@
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BANS-462<br>BANS-472<br>BANS-475<br>BANS-476<br>BANS-477<br>BANS-478<br>BANS-479 | Добавлен новый модуль **decort_account_info**, который позволяет получить следующую информацию об аккаунте:<br>&bull; основная информация <br>&bull; используемые и зарезервированные ресурсы<br>&bull; ресурсные группы<br>&bull; виртуальные машины<br>&bull; внутренние сети<br>&bull; диски<br>&bull; образы |
| BANS-462<br>BANS-472<br>BANS-475<br>BANS-476<br>BANS-477<br>BANS-478<br>BANS-479<br>BANS-480 | Добавлен новый модуль **decort_account_info**, который позволяет получить следующую информацию об аккаунте:<br>&bull; основная информация <br>&bull; используемые и зарезервированные ресурсы<br>&bull; ресурсные группы<br>&bull; виртуальные машины<br>&bull; внутренние сети<br>&bull; диски<br>&bull; образы<br>&bull; группы с плавающим IP-адресом |
## Исправления

@ -33,6 +33,7 @@ class DecortAccountInfo(DecortController):
account_id=amodule.params['id'],
computes_args=self.mapped_computes_args,
disks_args=self.mapped_disks_args,
flip_groups_args=self.mapped_flip_groups_args,
images_args=self.mapped_images_args,
resource_consumption=amodule.params['resource_consumption'],
resource_groups_args=self.mapped_rg_args,
@ -176,6 +177,47 @@ class DecortAccountInfo(DecortController):
),
),
),
flip_groups=dict(
type='dict',
options=dict(
filter=dict(
type='dict',
options=dict(
ext_net_id=dict(
type='int',
),
id=dict(
type='int',
),
ip=dict(
type='str',
),
name=dict(
type='str',
),
vins_id=dict(
type='int',
),
vins_name=dict(
type='str',
),
),
),
pagination=dict(
type='dict',
options=dict(
number=dict(
type='int',
default=1,
),
size=dict(
type='int',
required=True,
),
),
),
),
),
id=dict(
type='int',
),
@ -440,6 +482,35 @@ class DecortAccountInfo(DecortController):
return mapped_args
@property
def mapped_flip_groups_args(self) -> None | dict:
"""
Map the module argument `flip_groups` to
arguments dictionary for the method
`DecortController.account_flip_groups`
(excluding for `account_id`).
"""
input_args = self.amodule.params['flip_groups']
if not input_args:
return input_args
mapped_args = {}
if input_args['filter']:
mapped_args['ext_net_id'] = input_args['filter']['ext_net_id']
mapped_args['flig_group_id'] = input_args['filter']['id']
mapped_args['flig_group_ip'] = input_args['filter']['ip']
mapped_args['flig_group_name'] = input_args['filter']['name']
mapped_args['vins_id'] = input_args['filter']['vins_id']
mapped_args['vins_name'] = input_args['filter']['vins_name']
if input_args['pagination']:
mapped_args['page_number'] =\
input_args['pagination']['number']
mapped_args['page_size'] =\
input_args['pagination']['size']
return mapped_args
@property
def mapped_images_args(self) -> None | dict:
"""

@ -2079,6 +2079,7 @@ class DecortController(object):
computes_args: None | dict = None,
disks_args: None | dict = None,
fail_if_not_found=False,
flip_groups_args: None | dict = None,
images_args: None | dict = None,
resource_consumption=False,
resource_groups_args: None | dict = None,
@ -2108,6 +2109,12 @@ class DecortController(object):
the method `self.amodule.fail_json(**self.result)` will be
called if account is not found.
@param (None | dict) flip_groups_args: If dict is
specified, then the method `self.account_flip_groups`
will be called passing founded account ID
and `**flip_groups_args`. Result of the call will
be added to account info dict (key `flip_groups`).
@param (None | dict) images_args: If dict is
specified, then the method `self.account_images`
will be called passing founded account ID
@ -2242,6 +2249,13 @@ class DecortController(object):
**images_args
)
if flip_groups_args is not None:
account_details['flip_groups'] =\
self.account_flip_groups(
account_id=account_details['id'],
**flip_groups_args
)
return account_details['id'], account_details
@waypoint
@ -2586,6 +2600,51 @@ class DecortController(object):
return images
@waypoint
def account_flip_groups(
self,
account_id: int,
ext_net_id: None | int = None,
flig_group_id: None | int = None,
flig_group_ip: None | str = None,
flig_group_name: None | str = None,
page_number: int = 1,
page_size: None | int = None,
vins_id: None | int = None,
vins_name: None | str = None,
) -> list[dict]:
"""
Implementation of functionality of the API method
`/cloudapi/account/listFlipGroups`.
"""
api_params = {
'accountId': account_id,
'byIp': flig_group_ip,
'extnetId': ext_net_id,
'flipGroupId': flig_group_id,
'name': flig_group_name,
'page': page_number if page_size else None,
'size': page_size,
'vinsId': vins_id,
'vinsName': vins_name,
}
api_resp = self.decort_api_call(
arg_req_function=requests.post,
arg_api_name='/restmachine/cloudapi/account/listFlipGroups',
arg_params=api_params,
)
flip_groups = api_resp.json()['data']
for fg in flip_groups:
fg['createdTime_readable'] = self.sec_to_dt_str(fg['createdTime'])
fg['deletedTime_readable'] = self.sec_to_dt_str(fg['deletedTime'])
fg['updatedTime_readable'] = self.sec_to_dt_str(fg['updatedTime'])
return flip_groups
###################################
# GPU resource manipulation methods
###################################

Loading…
Cancel
Save