Skip to content

Commit

Permalink
Cleanup BitCreek code (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmgaston authored Mar 1, 2024
1 parent bb373c2 commit f9a50da
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 664 deletions.
4 changes: 0 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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/
5 changes: 2 additions & 3 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
* gblewis1 nmgaston
/inbm/ gblewis1 sriharshamakineni
/inbm-vision/ nmgaston yengliong93
* @gblewis1 @nmgaston
/inbm/ @gblewis1 @nmgaston
31 changes: 16 additions & 15 deletions docs/Manifest Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|:-----------------------------------------|:---------------------------------------------|:-----------------:|:------------------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -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 |
|:-----------------------------------------|:--------------------------------------------------------------|:-----------------:|:----------------|
| `<?xml version='1.0' encoding='utf-8'?>` | `<?xml version='1.0' encoding='utf-8'?>` | R | |
| `<manifest>` | `<manifest>` | R | |
| `<type></type>` | `<type>config</type>` | R | Always 'config' |
| `<config>` | `<ota>` | R | |
| `<cmd></cmd>` | `<cmd>load</cmd>` | R | |
| `<configtype>` | `<configtype>` | R | |
| `<load>` | `<load>` | R | |
| `<fetch></fetch>` | `<fetch>http://yoururl:port/intel_manageability.conf</fetch>` | R | |
| `</load>` | `</load>` | R | |
| `</configtype>` | `</configtype>` | R | |
| `</config>` | `</config>` | R | |
| `</manifest>` | `</manifest>` | R | |
| Tag | Example | Required/Optional | Notes |
|:-----------------------------------------|:--------------------------------------------------------------|:-----------------:|:----------------------------------------------------|
| `<?xml version='1.0' encoding='utf-8'?>` | `<?xml version='1.0' encoding='utf-8'?>` | R | |
| `<manifest>` | `<manifest>` | R | |
| `<type></type>` | `<type>config</type>` | R | Always 'config' |
| `<config>` | `<ota>` | R | |
| `<cmd></cmd>` | `<cmd>load</cmd>` | R | |
| `<configtype>` | `<configtype>` | R | |
| `<load>` | `<load>` | R | |
| `<fetch></fetch>` | `<fetch>http://yoururl:port/intel_manageability.conf</fetch>` | R | |
| `<signature></signature>` | `<signature>ABC123</signature` | O | Digistal signature |
| `</load>` | `</load>` | R | |
| `</configtype>` | `</configtype>` | R | |
| `</config>` | `</config>` | R | |
| `</manifest>` | `</manifest>` | R | |


* The configuration file you provide in Fetch needs to be named *intel_manageability.conf*. If you wish to send with
Expand Down
10 changes: 7 additions & 3 deletions inbc-program/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -380,7 +384,7 @@ inbc remove --path trustedRepositories:https://abc.com/

## RESTART
### Description
Restart nodes
Restart

### Usage
```
Expand Down
17 changes: 6 additions & 11 deletions inbc-program/inbc/parser/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
import argparse

from ..xml_tag import create_xml_tag
from ..utility import _get_password
from ..inbc_exception import InbcException


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 = ('<?xml version="1.0" encoding="utf-8"?>' +
Expand All @@ -33,12 +30,10 @@ def load(args: argparse.Namespace) -> str:
'<load>' +
'{0}' +
'{1}' +
'{2}' +
'</load>' +
'</configtype>' +
'</config>' +
'</manifest>').format(
create_xml_tag(arguments, "path"),
create_xml_tag(arguments, "fetch"),
create_xml_tag(arguments, "signature")
)
Expand All @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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.')
Expand Down Expand Up @@ -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 .')
Expand Down
8 changes: 4 additions & 4 deletions inbc-program/inbc/parser/ota_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions inbc-program/inbc/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions inbc-program/inbc/parser/source_app_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 = ('<?xml version="1.0" encoding="utf-8"?>' +
'<manifest><type>source</type>' +
'<applicationSource>' +
Expand Down
15 changes: 15 additions & 0 deletions inbc-program/inbc/parser/source_os_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<?xml version="1.0" encoding="utf-8"?><manifest><type>source</type>' \
'<osSource><add><repos>'
for source in args.sources:
Expand All @@ -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 = '<?xml version="1.0" encoding="utf-8"?><manifest><type>source</type>' \
'<osSource><remove><repos>'
for source in args.sources:
Expand All @@ -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 = ('<?xml version="1.0" encoding="utf-8"?>' +
'<manifest><type>source</type>' +
'<osSource>' +
Expand Down
2 changes: 1 addition & 1 deletion inbc-program/tests/unit/test_ota_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 0 additions & 6 deletions inbm-lib/inbm_lib/request_message_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
11 changes: 3 additions & 8 deletions inbm-lib/inbm_lib/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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:
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion inbm-lib/tests/unit/inbm_lib/test_xmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
TEST_XML = '<?xml version="1.0" encoding="utf-8"?>' \
'<manifest><type>ota</type><ota><header><id>sampleID</id><name>Sample FOTA</name><description>' \
'Sample</description><type>fota</type><repo>remote</repo></header><type><fota name="sample">' \
'<targetType>host</targetType><fetch>https://abc.tar</fetch><biosversion>2018.03</biosversion>' \
'<fetch>https://abc.tar</fetch><biosversion>2018.03</biosversion>' \
'<vendor>Intel</vendor><manufacturer>hisilicon</manufacturer><product>kmb-on-poplar</product><releasedate>' \
'2020-11-16</releasedate></fota></type></ota></manifest> '

Expand Down
1 change: 1 addition & 0 deletions inbm/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion inbm/dispatcher-agent/dispatcher/configuration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit f9a50da

Please sign in to comment.