Skip to content

Commit

Permalink
CRAYSAT-1929: Fix CFS fields in sat status for CFS v3
Browse files Browse the repository at this point in the history
The `CFSStatusModule` still had hard-coded property names for the
properties of a CFS component, and these property names were only valid
for CFS v2, so `sat status` only showed CFS fields when CFS v2 was used.
Update the mapping so that it correctly maps CFS properties to the
`sat status` column names for both CFS v2 and v3.

Test Description:
Built `cray-sat` image and tested on `noname` with both CFS versions,
that is:

* `sat status --cfs-version v2`
* `sat status --cfs-version v3`
  • Loading branch information
haasken-hpe committed Oct 29, 2024
1 parent 45e7a7f commit 829ba2c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.32.9] - 2024-10-29

### Fixed
- Fix missing CFS fields in `sat status` when using CFS v3.

## [3.32.8] - 2024-10-21

### Fixed
Expand Down
34 changes: 20 additions & 14 deletions sat/cli/status/status_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,24 +437,30 @@ class CFSStatusModule(StatusModule):
source_name = 'CFS'
component_types = {'Node'}

@staticmethod
def map_heading(heading):
return {
'id': 'xname',
'desiredConfig': 'Desired Config',
'configurationStatus': 'Configuration Status',
'errorCount': 'Error Count'
}.get(heading, heading)
def __init__(self, *, session, **_):
super().__init__(session=session)
self.cfs_version = get_config_value('cfs.api_version')
self.cfs_client = CFSClientBase.get_cfs_client(self.session, self.cfs_version)

# CFS v2 and v3 components have different property names in components,
# so generate a mapping from those field names to the row headings. It
# should be generated here rather than in `map_heading` because that method
# is called for every row.
self.heading_mapping = {
self.cfs_client.join_words(*heading.split()): heading
for heading in self.headings if heading != 'xname'
}
# This property name is the same between CFS v2 and v3
self.heading_mapping['id'] = 'xname'

def map_heading(self, heading):
return self.heading_mapping.get(heading, heading)

@property
def rows(self):
cfs_version = get_config_value('cfs.api_version')
cfs_client = CFSClientBase.get_cfs_client(self.session, cfs_version)
try:
cfs_response = cfs_client.get_components()
for response in cfs_response:
yield response

cfs_response = self.cfs_client.get_components()
yield from cfs_response
except APIError as err:
raise StatusModuleException(f'Failed to query CFS for component information: {err}') from err
except ValueError as err:
Expand Down

0 comments on commit 829ba2c

Please sign in to comment.