Fix for Horizon inventory in subclouds upgrade

When dealing with a subcloud where Centos and SystemController have
already been upgraded to Debian, Horizon encounters difficulties
loading Host Inventory and Software Management pages. This issue
arises due to variations in host attributes between different
versions.

To address this, any expected but missing attributes will be
assigned default values before loading the page.

Additionally, adding a fix for issues with sphinx version for this package

Test Plan:
- Select the target subcloud with the previous version. Navigate to
  Platform -> Host Inventory and confirm the successful loading of
  the Host table.
- Select the target subcloud. Navigate to Platform -> Host Inventory
  and confirm the ability to load the Edit Host modal and Host
  details.
- Select the target subcloud. Navigate to Platform -> Software
  Management and confirm the successful loading of patch details for
  this host.

closes-bug: 2032838

Signed-off-by: fperez <fabrizio.perez@windriver.com>
Change-Id: I671fcca81c14a787d4c55f823d1dae793fe2df35
This commit is contained in:
fperez 2023-08-23 15:28:57 -03:00
parent 26d37f6eb6
commit 99ece544e5
3 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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):
"""..."""