
Group of the current managed subclouds which are supposed to be duplicated in a peer site as secondary subclouds. This commit add subcloud-peer-group APIs of create/delete/update/show/list/ list-subclouds of a subcloud-peer-group Update setting peer-group for subcloud, Using DB of subclouds' 'peer_group_id' Column. Update subcloud update API, add peer_group parameter Usage: Add a subcloud to peer-group: dcmanager subcloud update SUBCLOUD --peer-group PEER_GROUP Remove a subcloud from peer-group: dcmanager subcloud update SUBCLOUD --peer-group none Test Plan: 1. PASS - Create a subcloud-peer-group 2. PASS - Update an existing subcloud's peer-group to a existing subcloud-peer-group successfully; 3. PASS - Verify subcloud-peer-group list-subclouds can get the expected Subcloud above successfully; 4. PASS - Update group_priority/group_state/max_subcloud_rehoming/ system_leader_id/system_leader_name of a subcloud-peer-group successfully; 5. PASS - Check can get subcloud status of a subcloud-peer-group successfully; 6. PASS - Delete a subcloud-peer-group completes successfully. 7. PASS - Delete a subcloud-peer-group while it still has subclouds associated to it. the subclouds' peer-group-id is auto set to None successfully; 8. PASS - Add a subcloud, update the peer-group-id as a non-existing subcloud-peer-group, get error message successfully; 9. PASS - Update subcloud peer group with invalid group_priority/group_state/max_subcloud_rehoming/ system_leader_id/system_leader_name Story: 2010852 Task: 48485 Change-Id: I93d0808b8cf02eba0e6f687007df42e2d2ea1848 Signed-off-by: Wang Tao <tao.wang@windriver.com>
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
#
|
|
# Copyright (c) 2023 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from dcmanager.api.policies import base
|
|
from oslo_policy import policy
|
|
|
|
POLICY_ROOT = 'dc_api:subcloud_peer_groups:%s'
|
|
|
|
|
|
_subcloud_peer_groups_rules = [
|
|
|
|
# CRUD of subcloud-peer-groups entity
|
|
policy.DocumentedRuleDefault(
|
|
name=POLICY_ROOT % 'create',
|
|
check_str='rule:' + base.ADMIN_IN_SYSTEM_PROJECTS,
|
|
description="Create subcloud peer group.",
|
|
operations=[
|
|
{
|
|
'method': 'POST',
|
|
'path': '/v1.0/subcloud-peer-groups'
|
|
}
|
|
]
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name=POLICY_ROOT % 'delete',
|
|
check_str='rule:' + base.ADMIN_IN_SYSTEM_PROJECTS,
|
|
description="Delete subcloud peer group.",
|
|
operations=[
|
|
{
|
|
'method': 'DELETE',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}'
|
|
}
|
|
]
|
|
),
|
|
policy.DocumentedRuleDefault(
|
|
name=POLICY_ROOT % 'get',
|
|
check_str='rule:' + base.ADMIN_IN_SYSTEM_PROJECTS,
|
|
description="Get Subcloud Peer Group data",
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/v1.0/subcloud-peer-groups/'
|
|
},
|
|
# Show details of a specified Subcloud Peer Group
|
|
{
|
|
'method': 'GET',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}'
|
|
},
|
|
# Show subclouds status of the subcloud-peer-group
|
|
{
|
|
'method': 'GET',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}/status'
|
|
},
|
|
# List Subclouds assigned to the given Subcloud Peer Group
|
|
{
|
|
'method': 'GET',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}/subclouds'
|
|
}
|
|
]
|
|
),
|
|
# Update a Subcloud Peer Group with specified configuration
|
|
policy.DocumentedRuleDefault(
|
|
name=POLICY_ROOT % 'modify',
|
|
check_str='rule:' + base.ADMIN_IN_SYSTEM_PROJECTS,
|
|
description="Update a Subcloud Peer Group with specified configuration",
|
|
operations=[
|
|
{
|
|
'method': 'PATCH',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}'
|
|
},
|
|
# Migrate subclouds entity of the subcloud-peer-group
|
|
{
|
|
'method': 'PATCH',
|
|
'path': '/v1.0/subcloud-peer-groups/{subcloud_peer_group}/migrate'
|
|
}
|
|
]
|
|
)
|
|
]
|
|
|
|
|
|
def list_rules():
|
|
return _subcloud_peer_groups_rules
|