distcloud/distributedcloud/dcmanager/api/controllers/v1/root.py
Gustavo Herzmann cb8737316f Add 'subcloud deploy create' command to dcmanager
This commit adds the subcloud deploy create command to dcmanager. It
accepts the same parameters as the subcloud add command, but only
performs the pre-deployment phase, where all parameters are validated
and the subcloud database entry is created. It does not perform the
install, bootstrap or config phases.

The commit does not modify the subcloud add command to use this phase
internally, this will be done in another commit, after the other
deployment phases are implemented.

Test Plan:
1. PASS - Create a subcloud using all the parameters and verify that
          the data is correctly stored in the DB;
2. PASS - Verify that the values from --install-values are correctly
          stored in the DB;
3. PASS - Verify that the values from --deploy-config and
          --bootstrap-values are are stored correctly in the
          ANSIBLE_OVERRIDES_PATH directory;
4. PASS - Verify that it's not possible to create a subcloud without
          the required parameters;
5. PASS - Verify that it's not possible to create a subcloud while
          another one with the same name or address already exists;
6. PASS - Repeat previous tests after swacting to controller-1.
7. PASS - Repeat previous tests but directly call the API (using
          CURL) instead of using the CLI;
8. PASS - Call the API directly, passing bmc-password as plain text
          as opposed to b64encoded and verify that the response
          contains the correct error code and message.

Story: 2010756
Task: 48030

Change-Id: Ia5321d08df7bec5aef1a8f90cb7292a522da9af9
Signed-off-by: Gustavo Herzmann <gustavo.herzmann@windriver.com>
2023-06-20 09:13:41 -03:00

72 lines
2.8 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 subclouds
from dcmanager.api.controllers.v1 import sw_update_options
from dcmanager.api.controllers.v1 import sw_update_strategy
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
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)