Files
distcloud/distributedcloud/dcmanager/tests/unit/manager/test_utils.py
Victor Romano 528f90afec Add subcloud redeploy option to dcmanager
This commit adds the command "subcloud redeploy" to dcmanager.
The redeploy operation is similar to "subcloud reinstall",
performing a fresh install, bootstrapping and configuring the
subcloud, but allowing the user to use either previously used
install/bootstrap/config values stored on the system controller
or new values from provided files. Since config is an optional
phase, it will only be executed if respective parameters are
provided in the current request or were provided in a previous
deployment.

Test Plan:
  Success cases:
    - PASS: Redeploy subcloud without passing any new files and
            verify the redeployment was successful and the final
            deploy state is "complete".
    - PASS: Redeploy subcloud passing new install/bootstrap/config
            files and verify the redeployment was successful and
            the final deploy state is "complete".
    - PASS: Redeploy a subcloud with a different management
            subnet and verify that the network reconfiguration
            was executed during the bootstrap phase and the
            redeployment completed successfully.
    - PASS: Redeploy a subcloud that wasn't configure by the
            "deploy config" command passing a config file and
            verify that the subcloud was redeploy and configured.
    - PASS: Redeploy a subcloud that wasn't configure by the
            "deploy config" command without passing a config file.
            and verify that the subcloud was redeployed and no
            configuration attempt was made.
    - PASS: Redeploy a subcloud passing a previous release (21.12)
            and verify the redeployment was successful and the final
            deploy state is "complete".
    - PASS: Abort each one of the three deployment phases. Verify the
            deployment was successfully aborted.
    - PASS: Resume the aborted deployment and verify the subcloud was
            successfully deployed.
    - PASS: Repeat previous tests but directly call the API (using
            CURL) instead of using the CLI.

  Failure cases:
    - PASS: Verify it's not possible to redeploy an online and/or
            managed subcloud.
    - PASS: Call the API directly, passing bmc-password and/or
            sysadmin-password as plain text as opposed to b64encoded
            and verify that the response contains the correct error
            code and message.

Story: 2010756
Task: 48496

Change-Id: I6148096909adda2b95b6bb964bc7a749ac62c20c
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
2023-08-21 17:32:50 -03:00

65 lines
2.9 KiB
Python

# Copyright (c) 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.
#
from dcmanager.common import utils
from dcmanager.tests import base
from dcmanager.tests.unit.common import fake_subcloud
from dcmanager.tests import utils as test_utils
class TestUtils(base.DCManagerTestCase):
def setUp(self):
super(TestUtils, self).setUp()
self.ctx = test_utils.dummy_context()
def test_has_network_reconfig_same_values(self):
subcloud = fake_subcloud.create_fake_subcloud(self.ctx)
payload = {"management_subnet": "192.168.101.0/24",
"management_gateway_address": "192.168.101.1",
"management_start_address": "192.168.101.2",
"management_end_address": "192.168.101.50",
"systemcontroller_gateway_address": "192.168.204.101"}
result = utils.has_network_reconfig(payload, subcloud)
self.assertFalse(result)
def test_has_network_reconfig_different_subnet(self):
subcloud = fake_subcloud.create_fake_subcloud(self.ctx)
payload = {"management_subnet": "192.168.102.0/24",
"management_gateway_address": "192.168.102.1",
"management_start_address": "192.168.102.2",
"management_end_address": "192.168.102.50"}
result = utils.has_network_reconfig(payload, subcloud)
self.assertTrue(result)
def test_has_network_reconfig_different_start_address(self):
subcloud = fake_subcloud.create_fake_subcloud(self.ctx)
payload = {"management_subnet": "192.168.101.0/24",
"management_gateway_address": "192.168.101.5",
"management_start_address": "192.168.101.7",
"management_end_address": "192.168.101.50"}
result = utils.has_network_reconfig(payload, subcloud)
self.assertTrue(result)
def test_has_network_reconfig_different_sc_gateway(self):
subcloud = fake_subcloud.create_fake_subcloud(self.ctx)
payload = {"management_subnet": "192.168.101.0/24",
"management_gateway_address": "192.168.101.1",
"management_start_address": "192.168.101.2",
"management_end_address": "192.168.101.50",
"systemcontroller_gateway_address": "192.168.204.102"}
result = utils.has_network_reconfig(payload, subcloud)
self.assertTrue(result)