From f9a50da99337ced89157eed4ff4f6e562e88f10a Mon Sep 17 00:00:00 2001 From: Natalie Gaston Date: Thu, 29 Feb 2024 18:54:12 -0800 Subject: [PATCH] Cleanup BitCreek code (#487) --- .dockerignore | 4 - CODEOWNERS | 5 +- docs/Manifest Parameters.md | 31 +-- inbc-program/README.md | 10 +- inbc-program/inbc/parser/config_parser.py | 17 +- inbc-program/inbc/parser/ota_parser.py | 8 +- inbc-program/inbc/parser/parser.py | 2 - inbc-program/inbc/parser/source_app_parser.py | 20 ++ inbc-program/inbc/parser/source_os_parser.py | 15 ++ inbc-program/tests/unit/test_ota_parser.py | 2 +- .../inbm_lib/request_message_constants.py | 6 - inbm-lib/inbm_lib/timer.py | 11 +- .../tests/unit/inbm_lib/test_xmlparser.py | 2 +- inbm/Changelog.md | 1 + .../dispatcher/configuration_helper.py | 2 +- inbm/dispatcher-agent/dispatcher/constants.py | 8 - .../dispatcher/dispatcher_class.py | 82 +++---- .../dispatcher-agent/dispatcher/ota_parser.py | 13 +- .../dispatcher-agent/dispatcher/ota_target.py | 202 ------------------ .../dispatcher-agent/manifest_schema.xsd | 117 +--------- .../tests/unit/aota/test_aota.py | 1 - .../tests/unit/test_dispatcher.py | 61 +----- .../tests/unit/test_ota_parser.py | 2 +- .../tests/unit/test_ota_target.py | 104 --------- .../inb/files/manageability-autoenable | 52 ----- pull_request_template.md | 2 +- 26 files changed, 116 insertions(+), 664 deletions(-) delete mode 100644 inbm/dispatcher-agent/dispatcher/ota_target.py delete mode 100644 inbm/dispatcher-agent/tests/unit/test_ota_target.py diff --git a/.dockerignore b/.dockerignore index 87e486919..b5f6fa623 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,16 +1,12 @@ **/venv-* **/.vscode inbm/output -inbm-vision/output **/nginx-data **/*.rpm **/*.deb **/*.zip .git inbm/scratch-packaging -inbm-vision/scratch-packaging inbm/dockerfiles -inbm-vision/dockerfiles inbm/Dockerfile-* -inbm-vision/Dockerfile-* dist/ diff --git a/CODEOWNERS b/CODEOWNERS index da11c7251..d618773bb 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,2 @@ -* gblewis1 nmgaston -/inbm/ gblewis1 sriharshamakineni -/inbm-vision/ nmgaston yengliong93 +* @gblewis1 @nmgaston +/inbm/ @gblewis1 @nmgaston diff --git a/docs/Manifest Parameters.md b/docs/Manifest Parameters.md index 18327c545..3b58d3f7c 100644 --- a/docs/Manifest Parameters.md +++ b/docs/Manifest Parameters.md @@ -611,7 +611,7 @@ The POTA manifest is used to perform both a FOTA and SOTA update at the same tim ### Query Manifest Parameters -The query command can be used to gather information about the system and the Vision cards. +The query command can be used to gather information about the system. | XML Tags | Definition | Required/Optional | Notes | |:-----------------------------------------|:---------------------------------------------|:-----------------:|:------------------------------------------------------------------------------------------------| @@ -798,20 +798,21 @@ The query command can be used to gather information about the system and the Vis ## Load #### Configuration LOAD Manifest Parameters -| Tag | Example | Required/Optional | Notes | -|:-----------------------------------------|:--------------------------------------------------------------|:-----------------:|:----------------| -| `` | `` | R | | -| `` | `` | R | | -| `` | `config` | R | Always 'config' | -| `` | `` | R | | -| `` | `load` | R | | -| `` | `` | R | | -| `` | `` | R | | -| `` | `http://yoururl:port/intel_manageability.conf` | R | | -| `` | `` | R | | -| `` | `` | R | | -| `` | `` | R | | -| `` | `` | R | | +| Tag | Example | Required/Optional | Notes | +|:-----------------------------------------|:--------------------------------------------------------------|:-----------------:|:----------------------------------------------------| +| `` | `` | R | | +| `` | `` | R | | +| `` | `config` | R | Always 'config' | +| `` | `` | R | | +| `` | `load` | R | | +| `` | `` | R | | +| `` | `` | R | | +| `` | `http://yoururl:port/intel_manageability.conf` | R | | +| `` | `ABC123` | `` | R | | +| `` | `` | R | | +| `` | `` | R | | +| `` | `` | R | | * The configuration file you provide in Fetch needs to be named *intel_manageability.conf*. If you wish to send with diff --git a/inbc-program/README.md b/inbc-program/README.md index 3bbefeb65..be4e32cb1 100644 --- a/inbc-program/README.md +++ b/inbc-program/README.md @@ -114,7 +114,7 @@ SOTA on Ubuntu is supported in 3 modes: 2. No download - Retrieves and installs packages. 3. Download only - Retrieve packages (will not unpack or install). -By default when SOTA is performaing an install, it will upgrade all eligible packages. The user can optionally specify a list of packages to upgrade (or install if not present) via the [--package-list, -p=PACKAGES] option. +By default, when SOTA is performing an installation, it will upgrade all eligible packages. The user can optionally specify a list of packages to upgrade (or install if not present) via the [--package-list, -p=PACKAGES] option. ### Usage @@ -300,12 +300,16 @@ inbc aota --app compose --command down --version 1.0 --containertag compose-up ### Description Load a new configuration file. This will replace the existing configuration file with the new file. +📝 The configuration file you provide needs to be named *intel_manageability.conf*. + + ### Usage ``` inbc load - {--path, -p FILE_PATH} [--uri, -u URI] + {--signature, -s SIGNATURE} ``` + ### Examples #### Load new Configuration File ``` @@ -380,7 +384,7 @@ inbc remove --path trustedRepositories:https://abc.com/ ## RESTART ### Description -Restart nodes +Restart ### Usage ``` diff --git a/inbc-program/inbc/parser/config_parser.py b/inbc-program/inbc/parser/config_parser.py index 43e4c0014..00d3ceb89 100644 --- a/inbc-program/inbc/parser/config_parser.py +++ b/inbc-program/inbc/parser/config_parser.py @@ -6,7 +6,6 @@ import argparse from ..xml_tag import create_xml_tag -from ..utility import _get_password from ..inbc_exception import InbcException @@ -14,14 +13,12 @@ def load(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated XML manifest """ arguments = { 'fetch': args.uri, - 'signature': args.signature, - 'username': args.username, - 'password': _get_password(args.username, "Please provide the password: ") + 'signature': args.signature } manifest = ('' + @@ -33,12 +30,10 @@ def load(args: argparse.Namespace) -> str: '' + '{0}' + '{1}' + - '{2}' + '' + '' + '' + '').format( - create_xml_tag(arguments, "path"), create_xml_tag(arguments, "fetch"), create_xml_tag(arguments, "signature") ) @@ -50,7 +45,7 @@ def get(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated XML manifest """ arguments = { @@ -79,7 +74,7 @@ def set(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated XML manifest """ arguments = { @@ -107,7 +102,7 @@ def set(args: argparse.Namespace) -> str: def append(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated XML manifest """ if not args.path: raise InbcException('argument --path/-p: required.') @@ -137,7 +132,7 @@ def append(args: argparse.Namespace) -> str: def remove(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated XML manifest """ if not args.path: raise InbcException('argument --path/-p: required .') diff --git a/inbc-program/inbc/parser/ota_parser.py b/inbc-program/inbc/parser/ota_parser.py index 2682e50c6..bb11df7ed 100644 --- a/inbc-program/inbc/parser/ota_parser.py +++ b/inbc-program/inbc/parser/ota_parser.py @@ -20,7 +20,7 @@ def sota(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated XML manifest string + @return: Generated XML manifest """ if not args.uri: # Update on local Ubuntu system. Does update through ubuntu without fetching a package. @@ -86,7 +86,7 @@ def fota(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated XML manifest string + @return: Generated XML manifest """ p = _gather_system_details() @@ -139,7 +139,7 @@ def pota(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated xml manifest string + @return: Generated xml manifest """ os_type = detect_os() p = _gather_system_details() @@ -201,7 +201,7 @@ def aota(args: argparse.Namespace) -> str: """Creates manifest in XML format. @param args: Arguments provided by the user from command line - @return: Generated XML manifest string + @return: Generated XML manifest """ arguments = { 'cmd': args.command, diff --git a/inbc-program/inbc/parser/parser.py b/inbc-program/inbc/parser/parser.py index 76a292a18..309f87615 100644 --- a/inbc-program/inbc/parser/parser.py +++ b/inbc-program/inbc/parser/parser.py @@ -262,8 +262,6 @@ def parse_load_args(self) -> None: type=lambda x: validate_string_less_than_n_characters( x, 'URL', 1000), help='Remote URI from where to retrieve package') - load_parser.add_argument('--username', '-un', required=False, help='Username on the remote server', - type=lambda x: validate_string_less_than_n_characters(x, 'Username', 50)) load_parser.add_argument('--signature', '-s', default='None', required=False, help='Signature string', type=lambda x: validate_string_less_than_n_characters(x, 'Signature', 1000)) load_parser.set_defaults(func=load) diff --git a/inbc-program/inbc/parser/source_app_parser.py b/inbc-program/inbc/parser/source_app_parser.py index 65dd67da0..ee4f1f7e6 100644 --- a/inbc-program/inbc/parser/source_app_parser.py +++ b/inbc-program/inbc/parser/source_app_parser.py @@ -14,6 +14,11 @@ def application_add(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ if bool(args.gpgKeyUri) != bool(args.gpgKeyName): raise InbcException( "Source requires either both gpgKeyUri and gpgKeyName to be provided, or neither of them.") @@ -49,6 +54,11 @@ def application_add(args: argparse.Namespace) -> str: def application_remove(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ arguments = { 'keyname': args.gpgKeyName, 'filename': args.filename @@ -73,6 +83,11 @@ def application_remove(args: argparse.Namespace) -> str: def application_update(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ arguments = { 'sources': args.sources, 'filename': args.filename @@ -94,6 +109,11 @@ def application_update(args: argparse.Namespace) -> str: def application_list(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ manifest = ('' + 'source' + '' + diff --git a/inbc-program/inbc/parser/source_os_parser.py b/inbc-program/inbc/parser/source_os_parser.py index 43ef14a48..7b1b8ed48 100644 --- a/inbc-program/inbc/parser/source_os_parser.py +++ b/inbc-program/inbc/parser/source_os_parser.py @@ -8,6 +8,11 @@ def os_add(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ manifest = 'source' \ '' for source in args.sources: @@ -19,6 +24,11 @@ def os_add(args: argparse.Namespace) -> str: def os_remove(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ manifest = 'source' \ '' for source in args.sources: @@ -41,6 +51,11 @@ def os_update(args: argparse.Namespace) -> str: def os_list(args: argparse.Namespace) -> str: + """Creates manifest in XML format. + + @param args: Arguments provided by the user from command line + @return: Generated XML manifest + """ manifest = ('' + 'source' + '' + diff --git a/inbc-program/tests/unit/test_ota_parser.py b/inbc-program/tests/unit/test_ota_parser.py index 93aee7888..6d5032266 100644 --- a/inbc-program/tests/unit/test_ota_parser.py +++ b/inbc-program/tests/unit/test_ota_parser.py @@ -149,7 +149,7 @@ def test_raise_invalid_fota_date_format(self, mock_stderr, mock_trigger) -> None with pytest.raises(SystemExit): self.arg_parser.parse_args( ['fota', '-u', 'https://abc.com/test.tar', '-r', '12-31-2024', - '-m', 'Intel', '--target', '123ABC', '456DEF']) + '-m', 'Intel']) assert "Not a valid date - format YYYY-MM-DD:" in str(mock_stderr.getvalue()) @patch('inbm_lib.mqttclient.mqtt.mqtt.Client.reconnect') diff --git a/inbm-lib/inbm_lib/request_message_constants.py b/inbm-lib/inbm_lib/request_message_constants.py index fe161635d..2aa75eca7 100644 --- a/inbm-lib/inbm_lib/request_message_constants.py +++ b/inbm-lib/inbm_lib/request_message_constants.py @@ -27,9 +27,3 @@ CONFIGURATION_FAILURE_MESSAGE_LIST = [CONFIGURATION_FAILURE, CONFIGURATION_GET_FAILURE, CONFIGURATION_SET_FAILURE, CONFIGURATION_LOAD_FAILURE, CONFIGURATION_UNSUCCESSFUL, CONFIGURATION_LOAD_UNSUCCESSFUL] - -NODE_NOT_FOUND = "No active nodes found" - -# Other message -NUM_TARGET = "OTA_TARGETS:" -NO_DEVICE_FOUND = "No xlink PCIe device found. Please install xlink driver. Will detect again in 30 seconds." diff --git a/inbm-lib/inbm_lib/timer.py b/inbm-lib/inbm_lib/timer.py index 7437e55e7..c5b074971 100644 --- a/inbm-lib/inbm_lib/timer.py +++ b/inbm-lib/inbm_lib/timer.py @@ -9,7 +9,7 @@ import logging from time import sleep from threading import Thread -from typing import Any, Callable +from typing import Any from typing import Optional logger = logging.getLogger(__name__) @@ -21,19 +21,17 @@ class Timer(object): @param count_down_time: time to count down (in seconds) @param callback_method: calling object - @param node_id: string representing node device id @param is_daemon: Set thread deamon. Default on threads is None. If not None, daemon explicitly sets whether the thread is daemonic. If None (the default), the daemonic property is inherited from the current thread. """ def __init__(self, count_down_time: int, callback_method: Any = None, - node_id: Optional[str] = None, is_daemon: Optional[bool] = None) -> None: + is_daemon: Optional[bool] = None) -> None: """If user doesn't pass callback method, user can check timeout value""" self._running = True self.count_down_time = count_down_time self.callback = callback_method - self.node_id = node_id self.current_time = 0 self.timer = Thread(target=self._start_internal_timer) if is_daemon: @@ -64,7 +62,4 @@ def _start_internal_timer(self) -> None: if self._running: if self.callback is not None: - if self.node_id: - self.callback(self.node_id) - else: - self.callback() + self.callback() diff --git a/inbm-lib/tests/unit/inbm_lib/test_xmlparser.py b/inbm-lib/tests/unit/inbm_lib/test_xmlparser.py index 349177e3d..62bb2884f 100644 --- a/inbm-lib/tests/unit/inbm_lib/test_xmlparser.py +++ b/inbm-lib/tests/unit/inbm_lib/test_xmlparser.py @@ -66,7 +66,7 @@ TEST_XML = '' \ 'ota
sampleIDSample FOTA' \ 'Samplefotaremote
' \ - 'hosthttps://abc.tar2018.03' \ + 'https://abc.tar2018.03' \ 'Intelhisiliconkmb-on-poplar' \ '2020-11-16
' diff --git a/inbm/Changelog.md b/inbm/Changelog.md index fba3f8d4e..ff9838aad 100644 --- a/inbm/Changelog.md +++ b/inbm/Changelog.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## NEXT - ?.?.? - ? ### Changed + - Removed remaining Bit Creek code including 'Target' references from the manifest schema. ### Fixed diff --git a/inbm/dispatcher-agent/dispatcher/configuration_helper.py b/inbm/dispatcher-agent/dispatcher/configuration_helper.py index 5be1fcdb3..41616f11a 100644 --- a/inbm/dispatcher-agent/dispatcher/configuration_helper.py +++ b/inbm/dispatcher-agent/dispatcher/configuration_helper.py @@ -8,7 +8,7 @@ import logging import os -from typing import Tuple, Optional, Any +from typing import Optional from inbm_common_lib.shell_runner import PseudoShellRunner from inbm_common_lib.utility import get_canonical_representation_of_path diff --git a/inbm/dispatcher-agent/dispatcher/constants.py b/inbm/dispatcher-agent/dispatcher/constants.py index 7b3f115ea..38ec088fd 100644 --- a/inbm/dispatcher-agent/dispatcher/constants.py +++ b/inbm/dispatcher-agent/dispatcher/constants.py @@ -16,7 +16,6 @@ 'public' / 'dispatcher-agent' / 'logging.ini') PROCEED_WITHOUT_ROLLBACK_DEFAULT = False -HOST_WITH_NODES_DEFAULT = False # Workload Orchestration ORCHESTRATOR_RESPONSE_DEFAULT = False @@ -37,10 +36,6 @@ CONFIGURATION_DISPATCHER_UPDATE_CHANNEL = 'configuration/update/dispatcher/+' CONFIGURATION_ALL_AGENTS_UPDATE_CHANNEL = 'configuration/update/all/+' CONFIGURATION_SOTA_UPDATE_CHANNEL = 'configuration/update/sota/+' -TARGET_OTA_CMD_CHANNEL = 'ma/request/install' -TARGET_PROVISION = 'ma/request/provision' -TARGET_CMD_RESTART = 'ma/request/restart' -VISION_CMD_QUERY = 'ma/request/query' # Publishing channels CUSTOM_CMD_CHANNEL = 'manageability/cmd/custom' @@ -70,13 +65,10 @@ CACHE = str(INTEL_MANAGEABILITY_CACHE_PATH_PREFIX) REPO_CACHE = str(INTEL_MANAGEABILITY_CACHE_PATH_PREFIX / 'repository-tool') -TargetType = Enum('TargetType', 'none vision node') - SUCCESS_RESTART = "Restart Command Success" # File permission masks UMASK_CONFIGURATION_FILE = 0o113 # 0o113 means prohibit execute by user or group, allow only read for other -UMASK_PROVISION_FILE = 0o113 # 0o113 means prohibit execute by user or group, allow only read for other UMASK_OTA = 0o117 # 0o117 means prohibit execute by user or group, prohibit all for other diff --git a/inbm/dispatcher-agent/dispatcher/dispatcher_class.py b/inbm/dispatcher-agent/dispatcher/dispatcher_class.py index 2e157a7fa..fd5e3e29b 100644 --- a/inbm/dispatcher-agent/dispatcher/dispatcher_class.py +++ b/inbm/dispatcher-agent/dispatcher/dispatcher_class.py @@ -15,11 +15,11 @@ from queue import Queue from threading import Thread, active_count from time import sleep -from typing import Tuple -from typing import Optional, Any +from typing import Optional, Any, Mapping, Tuple from dispatcher.config.config_operation import ConfigOperation from dispatcher.source.source_command import do_source_command +from dispatcher.common.result_constants import Result, PUBLISH_SUCCESS, OTA_FAILURE from .install_check_service import InstallCheckService @@ -27,12 +27,15 @@ from inbm_lib.detect_os import detect_os, LinuxDistType, OsType from inbm_lib.wmi_exception import WmiException from inbm_lib.validate_package_list import parse_and_validate_package_list +from inbm_lib.constants import QUERY_CMD_CHANNEL, OTA_SUCCESS, FAIL from inbm_common_lib.constants import REMOTE_SOURCE, UNKNOWN from inbm_common_lib.dmi import is_dmi_path_exists, get_dmi_system_info from inbm_common_lib.device_tree import get_device_tree_system_info from inbm_common_lib.platform_info import PlatformInformation -from inbm_lib.constants import QUERY_CMD_CHANNEL, OTA_SUCCESS, FAIL +from inbm_common_lib.exceptions import UrlSecurityException +from .dispatcher_broker import DispatcherBroker +from .dispatcher_exception import DispatcherException from .aota.aota_error import AotaError from .source.source_exception import SourceError from .common import dispatcher_state @@ -43,7 +46,6 @@ from .device_manager.device_manager import get_device_manager from .fota.fota_error import FotaError from .ota_factory import OtaFactory -from .ota_target import * from .ota_thread import ota_lock from .ota_util import create_ota_resource_list from .remediationmanager.remediation_manager import RemediationManager @@ -91,7 +93,7 @@ def _check_type_validate_manifest(xml: str, class Dispatcher: - def __init__(self, args: List[str], broker: DispatcherBroker, install_check_service: InstallCheckService) -> None: + def __init__(self, args: list[str], broker: DispatcherBroker, install_check_service: InstallCheckService) -> None: log_config_path = get_log_config_path() msg = f"Looking for logging configuration file at {log_config_path}" print(msg) @@ -109,7 +111,6 @@ def __init__(self, args: List[str], broker: DispatcherBroker, install_check_serv self.device_manager = get_device_manager() self.config_dbs = ConfigDbs.WARN self.dbs_remove_image_on_failed_container = True - self.host_with_nodes = HOST_WITH_NODES_DEFAULT self.proceed_without_rollback = PROCEED_WITHOUT_ROLLBACK_DEFAULT self.diag_health_report = {'rc': -1, 'cmd': 'diagnostic OR MQTT', @@ -304,39 +305,30 @@ def do_install(self, xml: str, schema_location: Optional[str] = None) -> Result: repo_type = header['repo'] resource = parsed_head.get_children(f'ota/type/{ota_type}') kwargs = {'ota_type': ota_type} - target_type = resource.get('targetType', None) - - if target_type is None: - target_type = TargetType.none.name - logger.debug(f"Target type: {target_type}") # Record OTA data for logging. self._update_logger.set_time() self._update_logger.ota_type = ota_type self._update_logger.metadata = xml - if target_type is TargetType.none.name and ota_type == OtaType.POTA.name.lower(): + if ota_type == OtaType.POTA.name.lower(): ota_list = create_ota_resource_list(parsed_head, resource) # Perform manifest checking first before OTA self._validate_pota_manifest( - repo_type, target_type, kwargs, parsed_head, ota_list) + repo_type, kwargs, parsed_head, ota_list) for ota in sorted(ota_list.keys()): kwargs['ota_type'] = ota result = self._do_ota_update( - xml, ota, repo_type, target_type, ota_list[ota], kwargs, parsed_head) + ota, repo_type, ota_list[ota], kwargs, parsed_head) if result == Result(CODE_BAD_REQUEST, "FAILED TO INSTALL") or result == OTA_FAILURE: break else: result = self._do_ota_update( - xml, ota_type, repo_type, target_type, resource, kwargs, parsed_head) + ota_type, repo_type, resource, kwargs, parsed_head) elif type_of_manifest == 'config': logger.debug('Running configuration command sent down ') - target_type = parsed_head.find_element('config/targetType') - if target_type is None: - target_type = TargetType.none.name - logger.debug(f"target_type : {target_type}") result = self._do_config_operation(parsed_head) except (DispatcherException, UrlSecurityException) as error: logger.error(error) @@ -374,14 +366,12 @@ def do_install(self, xml: str, schema_location: Optional[str] = None) -> Result: self._update_logger.save_log() return result - def _do_ota_update(self, xml: str, ota_type: str, repo_type: str, target_type: Optional[str], resource: Dict, - kwargs: Dict, parsed_head: XmlHandler) -> Result: + def _do_ota_update(self, ota_type: str, repo_type: str, resource: dict, + kwargs: dict, parsed_head: XmlHandler) -> Result: """Performs OTA updates by creating a thread based on OTA factory detected from the manifest - @param xml: manifest in XML format @param ota_type: Type of OTA requested (AOTA/FOTA/SOTA) @param repo_type: Type of repo to fetch files (local/remote) - @param target_type: Target on which the config operation needs to be performed @param resource: resource to parse @param kwargs: arguments dictionary to be updated after parsing resources @param parsed_head: Parsed head of the manifest xml @@ -406,35 +396,31 @@ def _do_ota_update(self, xml: str, ota_type: str, repo_type: str, target_type: O t = factory.create_thread(parsed_manifest) return t.start() - def _validate_pota_manifest(self, repo_type: str, target_type: Optional[str], - kwargs: Dict, parsed_head: XmlHandler, ota_list: Dict) -> None: + def _validate_pota_manifest(self, repo_type: str, + kwargs: dict, parsed_head: XmlHandler, ota_list: dict) -> None: """Validate POTA manifest by checking FOTA and SOTA information before starting OTA. @param repo_type: Type of repo to fetch files (local/remote) - @param target_type: Target on which the config operation needs to be performed @param kwargs: arguments dictionary to be updated after parsing resources @param parsed_head: Parsed head of the manifest xml """ - logger.debug("") for ota in sorted(ota_list.keys()): - # target_type is only used for Accelerator Manageability Framework logger.debug(f"ota = {ota}") - if target_type is TargetType.none.name: - logger.debug("") - factory = OtaFactory.get_factory( - ota.upper(), - repo_type, - self._dispatcher_broker, - self.proceed_without_rollback, - self._sota_repos, - self._install_check_service, - self._update_logger, - self.config_dbs) - p = factory.create_parser() - # NOTE: p.parse can raise one of the *otaError exceptions - parsed_manifest = p.parse(ota_list[ota], kwargs, parsed_head) - t = factory.create_thread(parsed_manifest) - t.check() + logger.debug("") + factory = OtaFactory.get_factory( + ota.upper(), + repo_type, + self._dispatcher_broker, + self.proceed_without_rollback, + self._sota_repos, + self._install_check_service, + self._update_logger, + self.config_dbs) + p = factory.create_parser() + # NOTE: p.parse can raise one of the *otaError exceptions + parsed_manifest = p.parse(ota_list[ota], kwargs, parsed_head) + t = factory.create_thread(parsed_manifest) + t.check() logger.debug(f'{ota} checks complete.') def check_username_password(self, parsed_manifest: Mapping[str, Optional[Any]]) -> None: @@ -467,14 +453,6 @@ def _verify_username_password_present(self, usr: Optional[str], pwd: Optional[st elif (usr is None) and pwd: raise DispatcherException(f'No Username sent in manifest for {ota}') - def _do_install_on_target(self, ota_type: str, xml: str, repo_type: str, parsed_manifest: Mapping[str, Optional[Any]]): - logger.debug("") - t = OtaTarget(xml, parsed_manifest, ota_type, - self._dispatcher_broker) - target_ota_status = t.install() - logger.debug(f"Install on Target STATUS: {target_ota_status}") - return target_ota_status - def _on_cloud_request(self, topic: str, payload: str, qos: int) -> None: """Called when a message is received from cloud diff --git a/inbm/dispatcher-agent/dispatcher/ota_parser.py b/inbm/dispatcher-agent/dispatcher/ota_parser.py index 1ca110187..09502b31f 100644 --- a/inbm/dispatcher-agent/dispatcher/ota_parser.py +++ b/inbm/dispatcher-agent/dispatcher/ota_parser.py @@ -195,9 +195,7 @@ def parse(self, resource: Dict, kwargs: Dict, parsed: XmlHandler) -> Dict[str, A class PotaParser(OtaParser): - """Parses the POTA manifest. - - """ + """Parses the POTA manifest.""" def __init__(self, repo_type: str) -> None: super().__init__(repo_type) @@ -212,17 +210,8 @@ def parse(self, resource: Dict, kwargs: Dict, parsed: XmlHandler) -> Dict[str, A """ logger.debug(" ") - target_type = resource.get('targetType', None) - if target_type: - targets = resource.get('targets') - [resource.pop(key) for key in ['targetType', 'targets']] if targets else \ - [resource.pop(key) for key in ['targetType']] - for key in resource.keys(): ota_resource = parsed.get_children(f'ota/type/pota/{key}') - if target_type: - ota_resource['targetType'] = target_type - ota_resource['targets'] = targets if key == 'fota': fota_args = FotaParser(self._repo_type) kwargs.update({key: fota_args.parse(ota_resource, kwargs, parsed)}) diff --git a/inbm/dispatcher-agent/dispatcher/ota_target.py b/inbm/dispatcher-agent/dispatcher/ota_target.py deleted file mode 100644 index 9a95e5c43..000000000 --- a/inbm/dispatcher-agent/dispatcher/ota_target.py +++ /dev/null @@ -1,202 +0,0 @@ -""" - Publishes OTA manifests for targets. - - Copyright (C) 2017-2024 Intel Corporation - SPDX-License-Identifier: Apache-2.0 -""" -import logging -import os -from typing import Any, Optional, Mapping, List, Dict -from urllib.parse import urlsplit -from dispatcher.packagemanager.constants import DEFAULT_HASH_ALGORITHM - -from inbm_common_lib.utility import get_canonical_representation_of_path, canonicalize_uri, CanonicalUri -from inbm_common_lib.constants import CONFIG_CHANNEL, CONFIG_LOAD -from inbm_common_lib.exceptions import UrlSecurityException -from .common.result_constants import PUBLISH_SUCCESS, Result, OTA_FAILURE -from .constants import TARGET_OTA_CMD_CHANNEL, SCHEMA_LOCATION, UMASK_OTA, OTA_PACKAGE_CERT_PATH, REPO_CACHE -from .dispatcher_broker import DispatcherBroker -from .dispatcher_exception import DispatcherException -from .downloader import download -from .ota_factory import OtaType -from .packagemanager.local_repo import DirectoryRepo -from .packagemanager.package_manager import verify_signature -from inbm_lib.xmlhandler import XmlException, XmlHandler - -logger = logging.getLogger(__name__) - - -class OtaTarget: - """Publish OTA for targets Tool. - - @param xml: XML to be modified - @param parsed_manifest: parsed_manifest values for ota - @param ota_type: type of ota - @param dispatcher_broker: DispatcherBroker object used to communicate with other INBM services - """ - - def __init__(self, xml: str, parsed_manifest: Mapping[str, Optional[Any]], ota_type: str, - dispatcher_broker: DispatcherBroker) -> None: - self._xml = xml - self._dispatcher_broker = dispatcher_broker - self._uri: Optional[str] = parsed_manifest.get('uri', None) - self._ota_element = parsed_manifest.get('resource') - self._ota_type = ota_type - self._str_repo = parsed_manifest.get('repo', None) - self._repo = DirectoryRepo(self._str_repo) if self._str_repo else DirectoryRepo(REPO_CACHE) - self._username = parsed_manifest.get('username', None) - self._password = parsed_manifest.get('password', None) - self._signature = parsed_manifest.get('signature', None) - self._hash_algorithm = parsed_manifest.get('hash_algorithm', DEFAULT_HASH_ALGORITHM) - if self._ota_type == OtaType.POTA.name: - [parsed_manifest.pop('ota_type')] # type: ignore - self._parsed_manifest = parsed_manifest - logger.debug("") - - def install(self) -> Result: - """Manages the install sequence to support the Accelerator Manageability Framework - - @return: OTA result - @raises DispatcherException: Invalid OTA type requested - """ - logger.debug("") - - self._dispatcher_broker.telemetry( - "Publishing manifest on targets initialized..") - if self._dispatcher_broker is None: - raise DispatcherException( - "dispatcher_broker not specified in Publish OTA for Targets constructor") - valid_check = True - repo_list: List[DirectoryRepo] = [] - if self._ota_type == OtaType.POTA.name: - logger.debug(f"parsed man : {self._parsed_manifest}") - # To track user defined repos for fota and sota. The list is used during cleanup in case of signature check failure. - for ota_key in self._parsed_manifest.keys(): - logger.debug(f"OTA KEY : {ota_key}") - ota_resource = self._parsed_manifest[ota_key] - if ota_resource is None: - raise DispatcherException("no ota_resource in POTA") - uri = ota_resource.get('uri', None) - username = ota_resource.get('username', None) - password = ota_resource.get('password', None) - repo = ota_resource.get('repo', None) - repo = DirectoryRepo(repo) if repo else DirectoryRepo(REPO_CACHE) - repo_list.append(repo) - signature = ota_resource.get('signature', None) - hash_algorithm = ota_resource.get('hash_algorithm', None) - try: - download_info = {'username': username, 'password': password, - 'signature': signature, 'hash_algorithm': hash_algorithm} - self._download_and_validate_package( - uri, repo, ota_key.upper(), download_info) - except (DispatcherException, UrlSecurityException) as err: - valid_check = False - ota_error = str(err) - self._dispatcher_broker.telemetry(ota_error) - break - - elif self._ota_type == OtaType.FOTA.name or self._ota_type == OtaType.SOTA.name: - repo_list.append(self._repo) - try: - download_info = {'username': self._username, 'password': self._password, - 'signature': self._signature, 'hash_algorithm': self._hash_algorithm} - self._download_and_validate_package( - self._uri, self._repo, self._ota_type, download_info) - except (DispatcherException, UrlSecurityException) as err: - valid_check = False - ota_error = str(err) - self._dispatcher_broker.telemetry(ota_error) - else: - raise DispatcherException( - f"The target OTA type is not supported: {self._ota_type}") - - if not valid_check: - logger.error(ota_error) - for repo in repo_list: - repo.delete_all() - self._dispatcher_broker.telemetry(ota_error) - return OTA_FAILURE - - xml_to_publish = self._modify_manifest() - self._dispatcher_broker.mqtt_publish( - TARGET_OTA_CMD_CHANNEL, xml_to_publish) - return PUBLISH_SUCCESS - - def _download_and_validate_package(self, uri: Optional[str], - repo: DirectoryRepo, ota_type: str, download_info: Dict[str, Any]): - if uri is None or uri == "": - raise DispatcherException( - f"Fetch URI is empty for {ota_type}. Please provide the URI to download file") - - if repo is None: - raise DispatcherException("attempted to download with uninitialized repo") - download( - dispatcher_broker=self._dispatcher_broker, - uri=canonicalize_uri(uri), - repo=repo, - umask=UMASK_OTA, - username=download_info.get('username', None), - password=download_info.get('password', None)) - if ota_type != OtaType.SOTA.name: - self._validate_signature(canonicalize_uri(uri), repo, download_info.get( - 'signature', None), download_info.get('hash_algorithm', None)) - self._dispatcher_broker.telemetry('Proceeding to publish OTA manifest...') - - def _validate_signature(self, uri: CanonicalUri, repo: DirectoryRepo, - signature: Optional[str], hash_algo: Optional[int]): - logger.debug("") - file_name = os.path.basename(urlsplit(uri.value).path) - file_path = os.path.join(repo.get_repo_path(), file_name) - if os.path.exists(OTA_PACKAGE_CERT_PATH): - if signature: - verify_signature(signature, file_path, self._dispatcher_broker, hash_algo) - else: - raise DispatcherException( - 'OTA update aborted. Signature is required to validate the package and proceed with the update.') - else: - self._dispatcher_broker.telemetry('Skipping signature check.') - - def _modify_manifest(self, schema_location: str = SCHEMA_LOCATION) -> str: - logger.debug("") - schema_location = get_canonical_representation_of_path(schema_location) - try: - parsed = XmlHandler(xml=self._xml, is_file=False, schema_location=schema_location) - if self._ota_type == OtaType.POTA.name: - logger.debug("") - for ota_key in self._parsed_manifest.keys(): - ota_resource = self._parsed_manifest[ota_key] - if ota_resource is None: - raise DispatcherException("ota_resource missing in POTA") - uri = ota_resource.get('uri', None) - pkg_filename = os.path.basename(uri) - new_xml = self._modify_manifest_helper( - parsed=parsed, ota_key=ota_key, package_name=pkg_filename).decode('utf-8', errors='strict') - parsed = XmlHandler(xml=str(new_xml), is_file=False, - schema_location=schema_location) - else: - if self._ota_element is None: - raise DispatcherException(f"ota_resource missing in {self._ota_type}") - pkg_filename = os.path.basename(self._ota_element['fetch']) - new_xml = self._modify_manifest_helper( - parsed=parsed, package_name=pkg_filename).decode('utf-8', errors='strict') - return new_xml - except XmlException as e: - raise DispatcherException(f"ERROR : {e}") - - def _modify_manifest_helper(self, parsed: Any, package_name: str, ota_key: Optional[str] = None) -> bytes: - logger.debug("") - if ota_key is None: - ota_key = '' - ota_path = f"ota/type/{self._ota_type.lower()}" - else: - ota_path = f"ota/type/{self._ota_type.lower()}/{ota_key}" - - fetch_path = f"ota/type/{self._ota_type.lower()}/{ota_key}/fetch" - username = f"ota/type/{self._ota_type.lower()}/{ota_key}/username" - password = f"ota/type/{self._ota_type.lower()}/{ota_key}/password" - new_xml = parsed.set_attribute("ota/header/repo", "local") - new_xml = parsed.add_element(ota_path, "path", REPO_CACHE + '/' + package_name) - new_xml = parsed.remove_element(fetch_path) - new_xml = parsed.remove_element(username) - new_xml = parsed.remove_element(password) - return new_xml diff --git a/inbm/dispatcher-agent/fpm-template/usr/share/dispatcher-agent/manifest_schema.xsd b/inbm/dispatcher-agent/fpm-template/usr/share/dispatcher-agent/manifest_schema.xsd index 06e9ba30d..cc68d051c 100644 --- a/inbm/dispatcher-agent/fpm-template/usr/share/dispatcher-agent/manifest_schema.xsd +++ b/inbm/dispatcher-agent/fpm-template/usr/share/dispatcher-agent/manifest_schema.xsd @@ -73,7 +73,6 @@ - @@ -92,25 +91,9 @@ - - - - - - - - - - - - - - - - @@ -133,25 +116,6 @@ - - - - - - - - - - - - - - - - - - - @@ -170,45 +134,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -477,21 +407,6 @@ - - - - - - - - - - - - - - - @@ -569,21 +484,6 @@ - - - - - - - - - - - - - - - @@ -598,21 +498,6 @@ - - - - - - - - - - - - - - - diff --git a/inbm/dispatcher-agent/tests/unit/aota/test_aota.py b/inbm/dispatcher-agent/tests/unit/aota/test_aota.py index 605144e40..013c35626 100644 --- a/inbm/dispatcher-agent/tests/unit/aota/test_aota.py +++ b/inbm/dispatcher-agent/tests/unit/aota/test_aota.py @@ -7,7 +7,6 @@ from dispatcher.aota.aota_command import DirectoryRepo from dispatcher.aota.aota_error import AotaError from dispatcher.aota.constants import SupportedDriver -from dispatcher.aota.checker import check_resource from ..common.mock_resources import * from unittest.mock import patch from typing import Any diff --git a/inbm/dispatcher-agent/tests/unit/test_dispatcher.py b/inbm/dispatcher-agent/tests/unit/test_dispatcher.py index 7934073a2..91a598ad0 100644 --- a/inbm/dispatcher-agent/tests/unit/test_dispatcher.py +++ b/inbm/dispatcher-agent/tests/unit/test_dispatcher.py @@ -9,12 +9,10 @@ from dispatcher.aota.aota_error import AotaError from dispatcher.common.result_constants import PUBLISH_SUCCESS, CODE_OK, CODE_BAD_REQUEST -from dispatcher.constants import TargetType from dispatcher.dispatcher_class import Dispatcher from dispatcher.dispatcher_exception import DispatcherException from dispatcher.ota_thread import AotaThread from dispatcher.install_check_service import InstallCheckService -from inbm_lib.xmlhandler import XmlHandler from dispatcher.ota_util import create_ota_resource_list from inbm_common_lib.platform_info import PlatformInformation @@ -187,31 +185,6 @@ def test_do_install_ota_error_result_succeeds(self, mock_workload_orchestration_ assert "400" in result - @patch('inbm_lib.xmlhandler.XmlHandler', autospec=True) - @patch('dispatcher.ota_util.create_ota_resource_list') - @patch('dispatcher.dispatcher_class.Dispatcher._do_ota_update') - def test_do_install_pota_resource_func_called(self, mock_ota_update, mock_ota_resource_func, MockXmlHandler, - mock_logging) -> None: - xml = '' \ - 'ota
potaremote' \ - '
node' \ - 'node-id1node-id2' \ - 'http://nat-ubuntu.jf.intel.com:8000/A1170000F60XE01.rar' \ - '5.12384signature' \ - 'Default stringDefault string' \ - '1American Megatrends Inc.2018-02-08' \ - 'boot6B29FC40-CA47-1067-B31D-00DD010662DAsize/p /b' \ - 'user1pwd' \ - ' updatehttp://nat-ubuntu.jf.intel.com:8000/file.mender' \ - 'signatureuserpwd' \ - '2020-10-10 ' \ - '
' - d = TestDispatcher._build_dispatcher() - d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION) - mock_ota_resource_func.assert_not_called() - mock_ota_resource_func.return_value = {'fota': 'FOTA', 'sota': 'SOTA'} - mock_ota_update.assert_called() - @patch('inbm_lib.xmlhandler.XmlHandler', autospec=True) def test_do_install_pota_do_ota_func_called(self, MockXmlHandler, mock_logging) -> None: parsed_head = MockXmlHandler.return_value @@ -322,30 +295,6 @@ def test_dispatcher_state_file_info_fota1(self, mock_consume_disp_file, mock_dis mock_send_result.assert_called_once_with( "FOTA INSTALL UNKNOWN: Error gathering BIOS information.") - @patch('dispatcher.dispatcher_class.Dispatcher._do_ota_update') - @patch('inbm_lib.mqttclient.mqtt.mqtt.Client.connect') - @patch('inbm_lib.mqttclient.mqtt.mqtt.Client.subscribe') - @patch('dispatcher.dispatcher_class.Dispatcher._send_result') - @patch('dispatcher.dispatcher_class.Dispatcher.invoke_workload_orchestration_check') - def test_fota_for_target_pass(self, - mock_workload_orchestration_func: Any, - mock_send_result: Any, - m_sub: Any, - m_connect: Any, - mock_install_target: Any, - mock_logging: Any) -> None: - xml = '' \ - 'ota
sampleIDSample FOTA' \ - 'Samplefotaremote
' \ - 'hosthttps://abc.tar2018.03' \ - 'Intelhisiliconkmb-on-poplar' \ - '2020-11-16
' - d = TestDispatcher._build_dispatcher() - d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION) - mock_install_target.assert_called_once() - mock_install_target.return_value = PUBLISH_SUCCESS - self.assertEqual(200, d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION).status) - @patch('dispatcher.dispatcher_class.Dispatcher._send_result') @patch('inbm_common_lib.dmi.is_dmi_path_exists', return_value=False) @patch('inbm_common_lib.device_tree.get_device_tree_system_info', return_value=devicetree_parsed_1) @@ -431,7 +380,7 @@ def test_config_load_operation_called(self, mock_install_func: Any, mock_logging: Any) -> None: xml = 'config ' \ - 'loadnodemaxCacheSize ' \ + 'loadmaxCacheSize ' \ ' ' d = TestDispatcher._build_dispatcher() @@ -454,7 +403,7 @@ def test_config_load_operation_called_bad(self, mock_install_func: Any, mock_logging: Any) -> None: xml = 'config ' \ - 'loadbadnodemaxCacheSize ' \ + 'loadbadmaxCacheSize ' \ ' ' d = TestDispatcher._build_dispatcher() @@ -473,14 +422,14 @@ def test_reboot_cmd(self, mock_perform_cmd_type_operation, mock_workload_orchest @patch('dispatcher.dispatcher_class.Dispatcher.invoke_workload_orchestration_check') @patch('dispatcher.dispatcher_class.Dispatcher._perform_cmd_type_operation') def test_query_cmd(self, mock_perform_cmd_type_operation, mock_workload_orchestration, mock_logging) -> None: - xml = 'cmdquerynode' + xml = 'cmdquery' d = TestDispatcher._build_dispatcher() - status = d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION).status + d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION).status mock_workload_orchestration.assert_called() mock_perform_cmd_type_operation.assert_called_once() def test_parse_error_invalid_command(self, mock_logging) -> None: - xml = 'cmdorangenode' + xml = 'cmdorange' d = TestDispatcher._build_dispatcher() status = d.do_install(xml=xml, schema_location=TEST_SCHEMA_LOCATION).status self.assertEqual(300, status) diff --git a/inbm/dispatcher-agent/tests/unit/test_ota_parser.py b/inbm/dispatcher-agent/tests/unit/test_ota_parser.py index fe3e1eec3..0140c2611 100644 --- a/inbm/dispatcher-agent/tests/unit/test_ota_parser.py +++ b/inbm/dispatcher-agent/tests/unit/test_ota_parser.py @@ -42,7 +42,7 @@ def test_parse_sota_empty_fields_should_include_hash_algorithm(self) -> None: def test_parse_pota_empty_fields_should_include_fota(self) -> None: p = PotaParser('remote') result = p.parse( - {'fota': '', 'sota': '', 'targetType': 'node', 'targets': ' ', 'fetch': 'https://www.google.com/'}, {}, self.parsed) + {'fota': '', 'sota': '', 'fetch': 'https://www.google.com/'}, {}, self.parsed) self.assertTrue('fota' in result) diff --git a/inbm/dispatcher-agent/tests/unit/test_ota_target.py b/inbm/dispatcher-agent/tests/unit/test_ota_target.py deleted file mode 100644 index 97a94ad4a..000000000 --- a/inbm/dispatcher-agent/tests/unit/test_ota_target.py +++ /dev/null @@ -1,104 +0,0 @@ -import mock -import os - -from unittest import TestCase -from unittest.mock import Mock, patch -from unit.common.mock_resources import * -from dispatcher.common.result_constants import PUBLISH_SUCCESS -from dispatcher.ota_target import OtaTarget - -TEST_XML = 'ota
sampleID' \ - 'fotaremote
' \ - 'hosthttps://abc.tar' \ - '2018.03Intelhisilicon' \ - 'kmb-on-poplar2020-11-16
' -TEST_POTA_XML = '' \ - 'ota
potaremote' \ - '
node'\ - 'node-id1node-id2'\ - 'http://nat-ubuntu.jf.intel.com:8000/A1170000F60XE01.rar' \ - '5.12384signature' \ - 'Default stringDefault string' \ - '1American Megatrends Inc.2018-02-08'\ - 'boot6B29FC40-CA47-1067-B31D-00DD010662DAsize/p /b'\ - 'user1pwd' \ - ' updatehttp://nat-ubuntu.jf.intel.com:8000/file.mender' \ - 'signatureuserpwd'\ - '2020-10-10 '\ - '
' -MODIFIED_TEST_XML = 'ota
' \ - 'sampleIDfotalocal' \ - '
host' \ - '2018.03Intelhisilicon' \ - 'kmb-on-poplar2020-11-16' \ - '/var/cache/manageability/repository-tool/abc.tar
' -TEST_XML_WITH_CREDENTIALS = '' \ - 'ota
sampleID' \ - 'fotaremote
' \ - 'hosthttps://abc.tar2018.03' \ - 'usermypassword' \ - 'Intelhisiliconkmb-on-poplar' \ - '2020-11-16
' -TEST_SCHEMA_LOCATION = os.path.join(os.path.dirname(__file__), - '../../fpm-template/usr/share/dispatcher-agent/' - 'manifest_schema.xsd') -ota_element = {'fetch': 'https://abc.tar'} -parsed_manifest = {'uri': 'https://abc.com', 'signature': 'asdf', - 'hash_algorithm': '3', - 'resource': ota_element, - 'username': 'uname', - 'password': 'pwd'} -pota_parsed_manifest = {'ota_type': 'pota', 'fota': {'uri': 'http://nat-ubuntu.jf.intel.com:8000/A1170000F60XE01.rar', 'signature': 'signature', 'hash_algorithm': 384, 'resource': {'fetch': 'http://nat-ubuntu.jf.intel.com:8000/A1170000F60XE01.rar', 'biosversion': '5.12', 'sigversion': '384', 'signature': 'signature', 'manufacturer': 'Default string', 'product': 'Default string', 'productversion': '1', 'vendor': 'American Megatrends Inc.', 'releasedate': '2018-02-08', 'boot': 'boot', 'guid': 'guid', 'size': 'size', 'tooloptions': '/p /b', 'username': 'user1', - 'password': 'pwd', 'targetType': 'node', 'targets': ' '}, 'username': 'user1', 'password': 'pwd'}, 'sota': {'sota_cmd': 'update', 'log_to_file': 'y', 'uri': 'http://nat-ubuntu.jf.intel.com:8000/file.mender', 'signature': 'signature', 'hash_algorithm': 384, 'resource': {'cmd': 'update', 'fetch': 'http://nat-ubuntu.jf.intel.com:8000/file.mender', 'signature': 'signature', 'username': 'user', 'password': 'pwd', 'release_date': '2020-10-10', 'targetType': 'node', 'targets': ' '}, 'username': 'user', 'password': 'pwd', 'release_date': '2020-10-10'}} - - -class TestPublishTargetOta(TestCase): - - @mock.patch('dispatcher.dispatcher_broker.DispatcherBroker', autospec=True) - def setUp(self, mock_broker): - self.mocked_broker = mock_broker.return_value - - @patch('dispatcher.ota_target.download') - @patch('dispatcher.ota_target.OtaTarget._modify_manifest') - def test_ota_target(self, mock_modify, mock_download) -> None: - - t = OtaTarget(TEST_XML, parsed_manifest, "FOTA", Mock()) - status = t.install() - mock_modify.assert_called_once() - mock_download.assert_called_once() - self.assertEqual(status, PUBLISH_SUCCESS) - - @patch('inbm_lib.xmlhandler.XmlHandler.__init__') - @patch('inbm_lib.xmlhandler.XmlHandler.add_element') - @patch('inbm_lib.xmlhandler.XmlHandler.set_attribute') - @patch('inbm_lib.xmlhandler.XmlHandler.remove_element') - @patch('dispatcher.ota_target.download') - def test_publish_fota(self, mock_download, mock_rmv, mock_set, mock_add, mock_xmlhandler) -> None: - mock_xmlhandler.return_value = None - t = OtaTarget(TEST_XML, parsed_manifest, "FOTA", Mock()) - t.install() - mock_download.assert_called_once() - - @patch('inbm_lib.xmlhandler.XmlHandler.__init__') - @patch('inbm_lib.xmlhandler.XmlHandler.add_element') - @patch('inbm_lib.xmlhandler.XmlHandler.set_attribute') - @patch('inbm_lib.xmlhandler.XmlHandler.remove_element') - @patch('dispatcher.ota_target.download') - @patch('dispatcher.ota_target.OtaTarget._modify_manifest') - def test_publish_pota(self, mock_modify_manifest, mock_download, mock_rmv, mock_set, mock_add, mock_xmlhandler) -> None: - mock_xmlhandler.return_value = None - t = OtaTarget(TEST_POTA_XML, pota_parsed_manifest, "POTA", Mock()) - t.install() - mock_download.assert_called() - self.assertEqual(mock_download.call_count, 2) - mock_modify_manifest.assert_called_once() - - def test_modify_manifest_without_credential_info(self) -> None: - t = OtaTarget(TEST_XML, parsed_manifest, "FOTA", Mock()) - m = t._modify_manifest(schema_location=TEST_SCHEMA_LOCATION) - self.assertEqual(m, MODIFIED_TEST_XML) - - def test_modify_manifest_with_credential_info(self) -> None: - t = OtaTarget(TEST_XML_WITH_CREDENTIALS, parsed_manifest, "FOTA", Mock()) - m = t._modify_manifest(schema_location=TEST_SCHEMA_LOCATION) - self.assertEqual(m, MODIFIED_TEST_XML) diff --git a/inbm/packaging/yocto/meta-intel-ese-manageability/recipes-inb/inb/files/manageability-autoenable b/inbm/packaging/yocto/meta-intel-ese-manageability/recipes-inb/inb/files/manageability-autoenable index 6ec39d6c9..9ae24abd5 100644 --- a/inbm/packaging/yocto/meta-intel-ese-manageability/recipes-inb/inb/files/manageability-autoenable +++ b/inbm/packaging/yocto/meta-intel-ese-manageability/recipes-inb/inb/files/manageability-autoenable @@ -21,55 +21,3 @@ function run_FOTA() { fi fi } - - -KMB_PCIE_EP_STATUS="/proc/device-tree/soc/pcie_ep@37000000/status" -THB_PCIE_EP_STATUS="/proc/device-tree/soc/pcie_ep@82000000/status" - -if [ -f $KMB_PCIE_EP_STATUS ]; then - PCIE_EP_STATUS=$KMB_PCIE_EP_STATUS -elif [ -f $THB_PCIE_EP_STATUS ]; then - PCIE_EP_STATUS=$THB_PCIE_EP_STATUS -else - PCIE_EP_STATUS="" -fi - -# Status is okay if it is in HDDL mode. -if [ ! $PCIE_EP_STATUS == "" ]; then - IS_HDDL=$(cat $PCIE_EP_STATUS | tr -d '\0') - echo $IS_HDDL - if [ $IS_HDDL == "okay" ]; then - echo HDDL mode enabled. - - # PV3 upgrade. Any version prior to PV3 may have TPM temporarily disabled. This - # will force a reprovision with TPM=auto in that case so it has a chance to be re-enabled - # if it is functioning on the system. - # In HDDL mode, we don't have any secrets other than TLS keys, so we don't lose any - # credentials doing this and we can regenerate TLS keys on reboot. - - if [ ! -f /etc/intel-manageability/PV3_UPGRADED ]; then - rm -f /etc/intel-manageability/AUTO_ENABLED || true # Allow auto-enable to work below - touch /etc/intel-manageability/PV3_UPGRADED # Prevent PV3 upgrade from happening more than once - fi - - run_FOTA # this might reboot - - sed -i 's/true<\/networkCheck>/false<\/networkCheck>/' /etc/intel_manageability.conf - - if [ -f /etc/intel-manageability/AUTO_ENABLED ]; then - echo "Already autoenabled." - exit 0 - fi - - mqtt-remove-keys || true # This is necessary in case we're coming from a PV3 upgrade - SKIP_DOCKER_CONFIGURATION=1 NO_CLOUD=1 NO_OTA_CERT=1 PROVISION_TPM=auto /usr/bin/provision-tc - systemctl enable inbm-node.service - touch /etc/intel-manageability/AUTO_ENABLED # This is run AFTER node is enabled (but not started) and provision-tc succeeds, in case there is an error starting node. - - # Finally, we start inbm-node.service. - # TODO: BC needs a provision-bc script. This is temporary: - if [ -f /usr/bin/inbm-node ] ; then - systemctl start inbm-node.service - fi - fi -fi diff --git a/pull_request_template.md b/pull_request_template.md index 94f4fd216..36878ab60 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,7 +17,7 @@ Reference URL for issue tracking (JIRA/HSD/Github): **\** - [ ] Added label to the Pull Request for easier discoverability and search - [ ] RTC or HSD number will be included in final merge. HSD must always be included if available. - [ ] Changelogs are updated (or N/A if not customer visible) -- [ ] inbm/log_changes.txt and inbm-vision/log_changes.txt are updated for potentially Validation-breaking log changes (or N/A if none) +- [ ] inbm/log_changes.txt are updated for potentially Validation-breaking log changes (or N/A if none) ### CODE MAINTAINABILITY - [ ] **_Commit Message meets guidelines as indicated in the URL\*_**