Files
distcloud/distributedcloud/dcmanager/api/controllers/v1/notifications.py
Raphael 0c1cd7ab91 Remove patch audit and orchestration
This commit removes the usage of patch throughout DC applications,
deleting the patch orchestration and load and patch audits.

Note: this commit does not replace the usage of PatchingClient, which
will be done in a subsequent review.

Test plan:
1. PASS: Deploy a DC system.
2. PASS: Manage a subcloud and verify that all endpoints are set as
   'in-sync'.
3. PASS: Run dcmanager subcloud show and verify that there are no
   references to load and patch endpoints.
4. PASS: Unmanage a subcloud and verify that all endpoints are set as
   'unknown'.
5. PASS: Create and apply a strategy, verifying it completes
   successfully.
6. PASS: Execute a select statement in the subcloud_audits table and
   verify that the patch_audit_requested and load_audit_requested
   columns does not exist.
7. PASS: Perform a system upgrade successfully.

Story: 2011311
Task: 52184

Change-Id: Ic218b12fc67401f37a2d4701b8adcfbea2eae409
Signed-off-by: Raphael <Raphael.Lima@windriver.com>
2025-05-20 16:10:34 -03:00

67 lines
2.6 KiB
Python

# Copyright (c) 2021, 2024-2025 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 http.client as httpclient
from oslo_config import cfg
from oslo_log import log as logging
import pecan
from pecan import expose
from pecan import request
from dcmanager.api.controllers import restcomm
from dcmanager.audit import rpcapi as audit_rpc_client
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class NotificationsController(object):
def __init__(self):
super(NotificationsController, self).__init__()
self.audit_rpc_client = audit_rpc_client.ManagerAuditClient()
@expose(generic=True, template="json")
def index(self):
# Route the request to specific methods with parameters
pass
@index.when(method="POST", template="json")
def post(self):
if "events" not in request.json_body:
pecan.abort(httpclient.BAD_REQUEST, "Missing required notification events")
events = request.json_body["events"]
if "platform-upgrade-completed" in events:
# We're being notified that a platform upgrade has completed,
# so we want to trigger a software audit of all subclouds on the
# next audit cycle.
context = restcomm.extract_context_from_environ()
self.audit_rpc_client.trigger_software_audit(context)
if "k8s-upgrade-completed" in events:
# We're being notified that a kubernetes upgrade has completed,
# so we want to trigger a kubernetes audit of all subclouds on
# the next audit cycle.
context = restcomm.extract_context_from_environ()
self.audit_rpc_client.trigger_kubernetes_audit(context)
if "kube-rootca-update-completed" in events:
# We're being notified that a kube rootca update has completed, so
# we want to trigger a kube rootca update audit of all subclouds on
# the next audit cycle.
context = restcomm.extract_context_from_environ()
self.audit_rpc_client.trigger_kube_rootca_update_audit(context)
return