diff --git a/pnp/images.toml b/pnp/images.toml index 3bc032f91e29ae270888ac6d0823e497f626a8a8..3328ca3f3560e72276036911e6e2bcbd3952127f 100644 --- a/pnp/images.toml +++ b/pnp/images.toml @@ -14,13 +14,13 @@ models = [] version = "17.6.4" md5 = "2caa962f5ed0ecc52f99b90c733c54de" size = 706565772 -models = [] +models = ["C1117-4PMLTEEAWE"] ["c1100-universalk9.17.10.01a.SPA.bin"] version = "17.10.1a" md5 = "a0cd6218c42f19bed425e3c63a11bcda" size = 689542648 -models = ["C1117-4PMLTEEAWE"] +models = [] ["c3560cx-universalk9-mz.152-7.E7.bin"] version = "15.2(7)E7" diff --git a/pnp/open-pnp.py b/pnp/open-pnp.py index add7a0fb0cfebe658cc5fda10f9e6ca8b85aa12e..34f7c98f724f2155216a0a4b9802106ba873d4ca 100755 --- a/pnp/open-pnp.py +++ b/pnp/open-pnp.py @@ -35,7 +35,7 @@ # 2023-02-23: added cli option -v/--version, --default_cfg # 2023-02-26: reorganized open-pnp.py in to open_pnp_classes.py and open_pnp_utils.py # 2023-32-07: changed '_' in cli options to '-' -> better readable/more bash like -# +# 2023-03-13: added '--no-default-cfg' option # # pip install flask xmltodict requests ifaddr tomli # @@ -78,7 +78,7 @@ from open_pnp_utils import ( ) -PNP_SERVER_VERSION = '20230227.v1.0.2' +PNP_SERVER_VERSION = '20230313.v1.0.3' def pnp_device_info(udi: str, correlator: str, info_type: str) -> str: @@ -161,9 +161,14 @@ def pnp_config_upgrade(udi: str, correlator: str) -> Optional[str]: cfg_file = f'{device.serial}.cfg' response = head(f'{SETTINGS.config_url}/{cfg_file}') if response.status_code != 200: # SERIAL.cfg not found - cfg_file = SETTINGS.default_cfg - response = head(f'{SETTINGS.config_url}/{cfg_file}') - if response.status_code != 200: # DEFAULT.cfg also not found + if not SETTINGS.no_default_cfg: + cfg_file = SETTINGS.default_cfg + response = head(f'{SETTINGS.config_url}/{cfg_file}') + if response.status_code != 200: # DEFAULT.cfg also not found + device.error_code = ERROR.ERROR_NO_CFG_FILE + device.hard_error = True + return + else: device.error_code = ERROR.ERROR_NO_CFG_FILE device.hard_error = True return diff --git a/pnp/open-pnp.toml b/pnp/open-pnp.toml index 16d301f2b6c70c3a6424caec3d366ff8eb950853..593ec93b1b33af82976d3d8582361df54303673e 100644 --- a/pnp/open-pnp.toml +++ b/pnp/open-pnp.toml @@ -8,6 +8,7 @@ # log_to_file = true # log_file = "log/pnp_debug.log" # default_cfg_file = "default.cfg" +# no_default_cfg = false # image_data = "images.toml" # image_url = "http://192.168.10.133:8080/images" # config_url = "http://192.168.10.133:8080/configs" diff --git a/pnp/open_pnp_classes.py b/pnp/open_pnp_classes.py index 4f2fe0e50d7ec2020a496248e66488d135e86714..14bc2041ef31e4ae2267e8c1d9e7832a5bfa643a 100644 --- a/pnp/open_pnp_classes.py +++ b/pnp/open_pnp_classes.py @@ -8,6 +8,9 @@ # Date : 2023-02-26 # File : open_pnp_classes.py +# +# 2023-03-13: fixed default_cfg option +# added no_default_cfg option from typing import Dict, Optional, Any from tomli import load as toml_load @@ -20,7 +23,7 @@ class ErrorCodes: 100: 'unknown platform', 101: 'no free space for update', 102: 'unknown image', - 103: 'config file not found', + 103: 'no config file found', 104: 'image file not found', 1412: 'Invalid input detected (config)', @@ -114,6 +117,7 @@ class Settings: image_url: Optional[str] = '', config_url: Optional[str] = '', default_cfg: Optional[str] = 'DEFAULT.cfg', + no_default_cfg: Optional[bool] = False, ): self.__settings = { 'cfg_file': cfg_file, @@ -129,6 +133,7 @@ class Settings: 'image_url': image_url, 'config_url': config_url, 'default_cfg': default_cfg, + 'no_default_cfg': no_default_cfg, } self.__args = {} self.__set_cli_args(cli_args) @@ -203,6 +208,10 @@ class Settings: def default_cfg(self) -> str: return self.__settings['default_cfg'] + @property + def no_default_cfg(self) -> bool: + return self.__settings['no_default_cfg'] + class SoftwareImage: def __init__(self, image: str, version: str, md5: str, size: int,): diff --git a/pnp/open_pnp_utils.py b/pnp/open_pnp_utils.py index 78eb4773d531a14a5b546a7abec7bd7d0cde9a7b..124be91c6b9b32ab59a979744f89a28d2b78aa19 100644 --- a/pnp/open_pnp_utils.py +++ b/pnp/open_pnp_utils.py @@ -8,6 +8,10 @@ # Date : 2023-02-26 # File : open_pnp_utils.py +# +# 2023-03-13: added --no-default-cfg option +# + from typing import List import logging from logging.handlers import RotatingFileHandler @@ -91,6 +95,9 @@ def parse_arguments(pnp_server_version: str) -> arg_Namespace: help='Enable Debug output send to "log-file".') parser.add_argument('--default-cfg', type=str, help='default config to use if no device specific config is found. (default: DEFAULT.cfg)') + parser.add_argument('--no-default-cfg', default=False, action='store_const', const=True, + help='Disables default config file for PnP devices. This option takes precedence over all ' + '"--default-cfg" cli options or config entries.') parser.add_argument('--log-file', type=str, help='Path/name of the logfile. (default: log/pnp_debug.log, requires --debug) ') parser.add_argument('--log-to-console', default=False, action='store_const', const=True, diff --git a/pnp/templates/status.html b/pnp/templates/status.html index 5c777a617e97f300c13ba98ddc1682046acaabaa..9ce2ea57fd9984e9ffe333e6aa2c21c22f92e6fd 100644 --- a/pnp/templates/status.html +++ b/pnp/templates/status.html @@ -1,31 +1,42 @@ +{# + +# Author: thl-cmk[at]outlook[dot]com +# URL : https://thl-cmk.hopto.org +# Date : 2022-12-10 +# File : status.html + +# +# 2023-03-13: moved error columns to debug output +# + +#} + {% macro header_row() %} <tr> <th>Count</th> <th>Action</th> - <th>Serial number</th> + <th>Serial number</th> <th>Platform</th> - <th>HW rev.</th> + <th>HW rev.</th> <th>IP-Address</th> - <th>PnP flow</th> + <th>PnP flow</th> <th>Status</th> - <th>First seen</th> - <th>Last contact</th> - <th>Current job</th> - <th>Current version</th> - <th>Target version</th> + <th>First seen</th> + <th>Last contact</th> + <th>Current job</th> + <th>Current version</th> + <th>Target version</th> + <th>Last message</th> {% if debug %} - <th>Current image</th> - <th>Target image</th> + <th>Current image</th> + <th>Target image</th> <th>Size</th> - <th>Free space</th> + <th>Free space</th> <th>Destination</th> - {% endif %} - <!-- <th>Error code</th> --> - <!-- <th>Last error</th> --> - <!-- <th>Last message</th> --> - <!-- <th>Error count</th> --> - <!-- <th>Hard error</th> --> - {% if debug %} + <th>Error code</th> + <th>Last error</th> + <th>Error count</th> + <th>Hard error</th> <th>Backoff</th> {% endif %} </tr> @@ -35,9 +46,9 @@ {% set min_rows = 50 %} {% if devices|length < min_rows %} {% set current_rows = devices|length %} - {% set num_columns = 17 %} + {% set num_columns = 13 %} {%if debug %} - {% set num_columns = num_columns + 6 %} + {% set num_columns = num_columns + 10 %} {% endif %} {% for i in range (0, min_rows - current_rows) %} <tr> @@ -188,19 +199,17 @@ <td>{{ device.current_job }}</td> <td>{{ device.version }}</td> <td>{{ device.target_image.version }}</td> + <td>{{ device.error_code_readable }}</td> {% if debug %} <td>{{ device.image }}</td> <td> <a href="{{ image_base_url }}/{{ device.target_image.image }}" target="_blank">{{device.target_image.image }}</a></td> <td>{{ device.target_image.size }}</td> <td>{{ device.destination_free }}</td> <td>{{ device.destination_name }}</td> - {% endif %} - <!-- <td>{{ device.error_code }}</td> --> - <!-- <td>{{ device.error_code_readable }}</td> --> - <!-- <td>{{ device.error_message }}</td> --> - <!-- <td>{{ device.error_count }}</td> --> - <!-- <td>{{ device.hard_error }}</td> --> - {% if debug %} + <td>{{ device.error_code }}</td> + <td>{{ device.error_message }}</td> + <td>{{ device.error_count }}</td> + <td>{{ device.hard_error }}</td> <td>{{ device.backoff }}</td> {% endif %} </tr>