Files
distcloud/distributedcloud/dcmanager/api/controllers/v1/root.py
twang4 8196e7f946 Add Subcloud Peer group management
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>
2023-09-08 15:43:31 +08:00

78 lines
3.1 KiB
Python

# Copyright (c) 2017 Ericsson AB.
# Copyright (c) 2017-2023 Wind River Systems, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import pecan
from dcmanager.api.controllers.v1 import alarm_manager
from dcmanager.api.controllers.v1 import notifications
from dcmanager.api.controllers.v1 import phased_subcloud_deploy
from dcmanager.api.controllers.v1 import subcloud_backup
from dcmanager.api.controllers.v1 import subcloud_deploy
from dcmanager.api.controllers.v1 import subcloud_group
from dcmanager.api.controllers.v1 import subcloud_peer_group
from dcmanager.api.controllers.v1 import subclouds
from dcmanager.api.controllers.v1 import sw_update_options
from dcmanager.api.controllers.v1 import sw_update_strategy
from dcmanager.api.controllers.v1 import system_peers
class Controller(object):
def _get_resource_controller(self, remainder):
if not remainder:
pecan.abort(404)
return
minor_version = remainder[-1]
remainder = remainder[:-1]
sub_controllers = dict()
if minor_version == '0':
sub_controllers["subclouds"] = subclouds.SubcloudsController
sub_controllers["subcloud-deploy"] = subcloud_deploy.\
SubcloudDeployController
sub_controllers["alarms"] = alarm_manager.SubcloudAlarmController
sub_controllers["sw-update-strategy"] = \
sw_update_strategy.SwUpdateStrategyController
sub_controllers["sw-update-options"] = \
sw_update_options.SwUpdateOptionsController
sub_controllers["subcloud-groups"] = \
subcloud_group.SubcloudGroupsController
sub_controllers["notifications"] = \
notifications.NotificationsController
sub_controllers["subcloud-backup"] = subcloud_backup.\
SubcloudBackupController
sub_controllers["phased-subcloud-deploy"] = phased_subcloud_deploy.\
PhasedSubcloudDeployController
sub_controllers["subcloud-peer-groups"] = \
subcloud_peer_group.SubcloudPeerGroupsController
sub_controllers["system-peers"] = system_peers.\
SystemPeersController
for name, ctrl in sub_controllers.items():
setattr(self, name, ctrl)
resource = remainder[0]
if resource not in sub_controllers:
pecan.abort(404)
return
remainder = remainder[1:]
return sub_controllers[resource](), remainder
@pecan.expose()
def _lookup(self, *remainder):
return self._get_resource_controller(remainder)