Skip to content

Commit

Permalink
Merge pull request #279 from Cray-HPE/CRAYSAT-1929-fix-sat-status-cfs…
Browse files Browse the repository at this point in the history
…-fields

CRAYSAT-1929: Fix CFS fields in `sat status` for CFS v3
  • Loading branch information
haasken-hpe authored Oct 30, 2024
2 parents 45e7a7f + 829ba2c commit 8b586d6
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 8b586d6

Please sign in to comment.