Raphael Lima afd50d27ec Orchestrator manager and worker processes skeleton
This commit creates the skeleton for the redesign of dcmanager's
orchestrator to a manager and worker process.

Test plan:
Note: The test plan had to be executed in a limited manner as the
services were not created. Therefore, the processing was setup using
threads and calling the worker class directly instead of using an RPC
call.
1. PASS: Create a kube-rootca-strategy for two subclouds and apply.
   Verify they complete the orchestration successfully and the
   strategy's state is updated afterwards.
2. PASS: Verify that the manager's monitoring starts after the apply
   request and stops once the strategy is set to a finished state, i.e.
   failed, complete or aborted.
3. PASS: Verify that the manager's strategy deletion actives the
   monitoring thread and destroys the strategy once the steps are
   deleted.
4. PASS: Run an orchestration without the worker manager setup and
   verify that it can complete and abort successfully.
5. PASS: Apply an orchestration, restart the service and verify that the
   manager's monitoring is restarted as well.

Story: 2011311
Task: 51670

Change-Id: I19592a50c47c5a0608e6e95a915b71423bcd97df
Signed-off-by: Raphael Lima <Raphael.Lima@windriver.com>
2025-03-21 11:43:34 -03:00

59 lines
2.4 KiB
Python

#
# Copyright (c) 2023-2025 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from dccommon.drivers.openstack import vim
from dcmanager.common import consts
from dcmanager.orchestrator.cache.shared_cache_repository import SharedCacheRepository
from dcmanager.orchestrator.states.software.apply_vim_software_strategy import (
ApplyVIMSoftwareStrategyState,
)
from dcmanager.orchestrator.states.software.create_vim_software_strategy import (
CreateVIMSoftwareStrategyState,
)
from dcmanager.orchestrator.states.software.finish_strategy import FinishStrategyState
from dcmanager.orchestrator.states.software.install_license import InstallLicenseState
from dcmanager.orchestrator.states.software.pre_check import PreCheckState
from dcmanager.orchestrator.strategies.base import BaseStrategy
class SoftwareStrategy(BaseStrategy):
"""Software orchestration strategy"""
# every state in sw deploy orchestration should have an operator
STATE_OPERATORS = {
consts.STRATEGY_STATE_SW_PRE_CHECK: PreCheckState,
consts.STRATEGY_STATE_SW_INSTALL_LICENSE: InstallLicenseState,
consts.STRATEGY_STATE_SW_CREATE_VIM_STRATEGY: CreateVIMSoftwareStrategyState,
consts.STRATEGY_STATE_SW_APPLY_VIM_STRATEGY: ApplyVIMSoftwareStrategyState,
consts.STRATEGY_STATE_SW_FINISH_STRATEGY: FinishStrategyState,
}
def __init__(self, audit_rpc_client):
super().__init__(
audit_rpc_client,
consts.SW_UPDATE_TYPE_SOFTWARE, # software update strategy type
vim.STRATEGY_NAME_SW_USM, # strategy type used by vim
consts.STRATEGY_STATE_SW_PRE_CHECK, # starting state
)
# Initialize shared cache instances for the states that require them
self._shared_caches = SharedCacheRepository(consts.SW_UPDATE_TYPE_SOFTWARE)
self._shared_caches.initialize_caches()
def trigger_audit(self):
"""Trigger an audit for software"""
self.audit_rpc_client.trigger_software_audit(self.context)
def pre_apply_setup(self):
# Restart caches for next strategy
self._shared_caches.initialize_caches()
super().pre_apply_setup()
def determine_state_operator(self, region_name, strategy_step):
state = super().determine_state_operator(region_name, strategy_step)
state.add_shared_caches(self._shared_caches)
return state