diff --git a/doc/requirements.txt b/doc/requirements.txt index f9f7a73d..3734ee1c 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,4 @@ -sphinx>=2.0.0,!=2.1.0 # BSD +sphinx>=2.0.0,!=2.1.0,<7.2.0 # BSD openstackdocstheme>=2.2.1 # Apache-2.0 # Release Notes documentation diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/patch.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/patch.py index 30c71fe6..2c2b5d0d 100755 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/patch.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/patch.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. # -# Copyright (c) 2014 Wind River Systems, Inc. +# Copyright (c) 2014-2023 Wind River Systems, Inc. # import logging @@ -208,6 +208,7 @@ def get_patch(request, patch_id): def get_hosts(request): hosts = [] + default_value = None try: info = _patching_client(request).get_hosts() except Exception: @@ -217,7 +218,14 @@ def get_hosts(request): for h in info['data']: host = Host() for a in host._attrs: - setattr(host, a, h[a]) + # if host received doesn't have this attribute, + # add it with a default value + if hasattr(h, a): + setattr(host, a, h[a]) + else: + setattr(host, a, default_value) + LOG.debug("Attribute not found. Adding default:" + "%s", a) hosts.append(host) return hosts diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py index c1dd705b..7d5aa298 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/api/sysinv.py @@ -1167,14 +1167,39 @@ def host_get(request, host_id): host = cgtsclient(request).ihost.get(host_id) if not host: raise ValueError('No match found for host_id "%s".' % host_id) + + # if host received doesn't have this attribute, + # add it with a default value + set_host_defaults(host) + return Host(host) def host_list(request): hosts = cgtsclient(request).ihost.list() + + # if host received doesn't have this attribute, + # add it with a default value + for host_data in hosts: + set_host_defaults(host_data) + return [Host(n) for n in hosts] +def set_host_defaults(host): + default_value = None + attrs_list = Host._attrs + + host_dict = host._info + for attr in attrs_list: + if attr not in host_dict: + LOG.debug("Attribute not found. Adding default value: %s: %s", + attr, default_value) + host._add_details({attr: default_value}) + + return + + class DNS(base.APIResourceWrapper): """..."""