
This commit introduces the new dcagent package. It is comprised of a periodic process that queries the necessary endpoints to gather the audit data and an API running on port 8325 (internal) and 8326 (admin). The api only has one endpoint /v1/dcaudit that accepts only PATCH and will respond with 'in-sync' or 'out-of-sync' for dcmanager-audit based on the RegionOne data provided or will return the subcloud data for the requested endpoints for dcorch-audit. The agent also supports a key 'use_cache' to be sent in the payload that will determine if it should use the cache data gathered by the periodic process or get new information on the fly. Example of payload using cached data: { "base_audit": "", "firmware_audit": "<regionone-audit-data>", "kubernetes_audit": "<regionone-audit-data>", "kube_rootca_audit" : "<regionone-audit-data>", "software_audit": "<regionone-audit-data>" } Example of payload requesting new information: { "certificates": "", "iuser": "", "fernet_repo": "", "use_cache": "false" } NOTES: - As patch and load audits will be deprecated in the next major release, no effort was made to integrate both patch and load audit to dcagent. - All tests described below were executed applying [1] as well, to avoid retesting. [1]: https://review.opendev.org/c/starlingx/distcloud/+/923351 Test plan: - PASS: Run dcmanager audit with dcagent. Verify only one call is made to audit the subcloud and the response include the correct sync status. - PASS: Run dcmanager audit without dcagent. Verify the audit works as expected querying each individual endpoint. Story: 2011106 Task: 50559 Change-Id: I1820ca9688d5d05f8712f9a42f6012f2ec3e2d8a Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
78 lines
1.9 KiB
Python
78 lines
1.9 KiB
Python
#
|
|
# Copyright (c) 2024 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
"""
|
|
Routines for configuring DC agent, largely copied from Neutron
|
|
"""
|
|
|
|
import sys
|
|
|
|
from oslo_config import cfg
|
|
from oslo_log import log as logging
|
|
|
|
from dcagent.common.i18n import _
|
|
from dcagent.common import version
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
common_opts = [
|
|
cfg.StrOpt("bind_host", default="0.0.0.0", help=_("The host IP to bind to")),
|
|
cfg.IntOpt("bind_port", default=8325, help=_("The port to bind to")),
|
|
cfg.IntOpt("api_workers", default=1, help=_("number of api workers")),
|
|
cfg.StrOpt(
|
|
"auth_strategy", default="keystone", help=_("The type of authentication to use")
|
|
),
|
|
]
|
|
|
|
|
|
def init(args, **kwargs):
|
|
# Register the configuration options
|
|
cfg.CONF.register_opts(common_opts)
|
|
|
|
logging.register_options(cfg.CONF)
|
|
|
|
cfg.CONF(
|
|
args=args,
|
|
project="dcagent",
|
|
version="%%(prog)s %s" % version.version_info.release_string(),
|
|
**kwargs
|
|
)
|
|
|
|
|
|
def setup_logging():
|
|
"""Sets up the logging options for a log with supplied name."""
|
|
product_name = "dcagent"
|
|
logging.setup(cfg.CONF, product_name)
|
|
LOG.info("Logging enabled!")
|
|
LOG.info(
|
|
"%(prog)s version %(version)s",
|
|
{"prog": sys.argv[0], "version": version.version_info.release_string()},
|
|
)
|
|
LOG.debug("command line: %s", " ".join(sys.argv))
|
|
|
|
|
|
def reset_service():
|
|
# Reset worker in case SIGHUP is called.
|
|
# Note that this is called only in case a service is running in daemon mode.
|
|
setup_logging()
|
|
|
|
# TODO(vgluzrom) enforce policy later
|
|
# policy.refresh()
|
|
|
|
|
|
def test_init():
|
|
# Register the configuration options
|
|
cfg.CONF.register_opts(common_opts)
|
|
try:
|
|
logging.register_options(cfg.CONF)
|
|
except cfg.ArgsAlreadyParsedError:
|
|
pass
|
|
setup_logging()
|
|
|
|
|
|
def list_opts():
|
|
yield None, common_opts
|