Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRAYSAT-1929: Fix CFS fields in sat status for CFS v3 #279

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading