Skip to content

Commit

Permalink
CRAYSAT-1902: Update sat bootprep with new changes of cfs v2
Browse files Browse the repository at this point in the history
Here, we update the `sat bootprep` to use only cfs v2
and will not break any changes
Also update the session check of `sat bootsys` to validate
cfs v2 sessions

Update latest csm-api-client
  • Loading branch information
annapoorna-s-alt authored and annapoorna-s-alt committed Sep 17, 2024
1 parent 3627688 commit aa09943
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 31 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.1] - 2024-09-17

### Changed
- Changed `sat bootprep` and `sat bootsys` to use the CFS.V2 updated classes from `csm-api-client`

## [3.32.0] - 2024-09-11

### Added
Expand Down
4 changes: 2 additions & 2 deletions sat/apiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2019-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2019-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -26,7 +26,7 @@
"""
# Import these names so that they can still be imported from the apiclient package directly

from csm_api_client.service.cfs import CFSClient
from csm_api_client.service.cfs import CFSClientBase
from csm_api_client.service.gateway import APIError, APIGatewayClient, ReadTimeout
from csm_api_client.service.hsm import HSMClient

Expand Down
6 changes: 3 additions & 3 deletions sat/cli/bootprep/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -330,7 +330,7 @@ def validate_image_configurations(input_images, cfs_client, input_config_names,
Args:
input_images (list of sat.cli.bootprep.input.image.InputImage): the
IMSImages which should have their configurations validated.
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS client to query to
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS client to query to
determine whether the configuration for the image exists.
input_config_names (list of str): the list of configuration names that
are defined in the input file
Expand Down Expand Up @@ -423,7 +423,7 @@ def validate_images(instance, args, cfs_client):
against the schema.
args: The argparse.Namespace object containing the parsed arguments
passed to the bootprep subcommand.
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client to make
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client to make
requests to the CFS API
Returns: None
Expand Down
6 changes: 3 additions & 3 deletions sat/cli/bootprep/input/configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -371,7 +371,7 @@ def __init__(self, data, instance, index, jinja_env, cfs_client,
index (int): the index of the item in the collection in the instance
jinja_env (jinja2.Environment): the Jinja2 environment in which
fields supporting Jinja2 templating should be rendered.
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client
product_catalog (cray_product_catalog.query.ProductCatalog):
the product catalog object
**kwargs: additional keyword arguments
Expand Down Expand Up @@ -466,7 +466,7 @@ def __init__(self, items_data, instance, jinja_env, request_dumper, cfs_client,
fields supporting Jinja2 templating should be rendered.
request_dumper (sat.cli.bootprep.output.RequestDumper): the dumper
for dumping request data to files.
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client
**kwargs: additional keyword arguments
"""
super().__init__(items_data, instance, jinja_env, request_dumper,
Expand Down
4 changes: 2 additions & 2 deletions sat/cli/bootprep/input/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BaseInputImage(DependencyGroupMember, ABC):
image_data (dict): the data for an image from the bootprep input file
ims_client (sat.apiclient.IMSClient): the IMSClient to make requests to
the IMS API
cfs_client (csm_api_client.service.cfs.CFSClient): the CFSClient to make requests to
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFSClient to make requests to
the CFS API
public_key_id (str): the id of the public key in IMS to use when
building the image
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, image_data, index, instance, jinja_env, product_catalog, ims_
the product catalog object
ims_client (sat.apiclient.IMSClient): the IMS API client to make
requests to the IMS API
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client to make
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client to make
requests to the CFS API
"""
super().__init__()
Expand Down
4 changes: 2 additions & 2 deletions sat/cli/bootprep/input/instance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -45,7 +45,7 @@ def __init__(self, instance_dict, request_dumper,
the instance has already been validated against the schema.
request_dumper (sat.cli.bootprep.output.RequestDumper): the dumper
for dumping request data to files.
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client to make
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client to make
requests to the CFS API
ims_client (sat.apiclient.IMSClient): the IMS API client to make
requests to the IMS API
Expand Down
8 changes: 4 additions & 4 deletions sat/cli/bootprep/input/session_template.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -52,7 +52,7 @@ class InputSessionTemplate(BaseInputItem):
requests to the BOS API
ims_client (sat.apiclient.IMSClient): the IMS API client to make
requests to the IMS API
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client to make
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client to make
requests to the CFS API
"""
description = 'BOS session template'
Expand All @@ -70,7 +70,7 @@ def __init__(self, data, instance, index, jinja_env, bos_client, cfs_client, ims
jinja_env (jinja2.Environment): the Jinja2 environment in which
fields supporting Jinja2 templating should be rendered.
bos_client (sat.apiclient.BOSClientCommon): the BOS API client
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client
ims_client (sat.apiclient.IMSClient): the IMS API client
**kwargs: additional keyword arguments
"""
Expand Down Expand Up @@ -398,7 +398,7 @@ def __init__(self, items_data, instance, jinja_env, request_dumper,
request_dumper (sat.cli.bootprep.output.RequestDumper): the dumper
for dumping request data to files.
bos_client (sat.apiclient.BOSClientCommon): the BOS API client
cfs_client (csm_api_client.service.cfs.CFSClient): the CFS API client
cfs_client (csm_api_client.service.cfs.CFSClientBase): the CFS API client
ims_client (sat.apiclient.IMSClient): the IMS API client
**kwargs: additional keyword arguments
"""
Expand Down
6 changes: 3 additions & 3 deletions sat/cli/bootprep/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -32,7 +32,7 @@
from jinja2.sandbox import SandboxedEnvironment
import yaml

from sat.apiclient import CFSClient, IMSClient
from sat.apiclient import CFSClientBase, IMSClient
from sat.apiclient.bos import BOSClientCommon
from sat.cli.bootprep.errors import (
BootPrepDocsError,
Expand Down Expand Up @@ -210,7 +210,7 @@ def do_bootprep_run(schema_validator, args):
LOGGER.info('Input file successfully validated against schema')

session = SATSession()
cfs_client = CFSClient(session)
cfs_client = CFSClientBase.get_cfs_client(session, 'v2')
ims_client = IMSClient(session)
# CASMTRIAGE-4288: IMS can be extremely slow to return DELETE requests for
# large images, so this IMSClient will not use a timeout on HTTP requests
Expand Down
6 changes: 3 additions & 3 deletions sat/cli/bootsys/service_activity.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2020-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2020-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -38,7 +38,7 @@

from sat.apiclient import (
APIError,
CFSClient,
CFSClientBase,
NMDClient
)
from sat.apiclient.bos import BOSClientCommon
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_active_sessions(self):
Raises:
ServiceCheckError: if unable to get the active CFS sessions.
"""
cfs_client = CFSClient(SATSession())
cfs_client = CFSClientBase.get_cfs_client(SATSession(), 'v2')
try:
sessions = cfs_client.get('sessions').json()
except (APIError, ValueError) as err:
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/bootprep/input/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -34,7 +34,7 @@
from csm_api_client.service.vcs import VCSError
from jinja2.sandbox import SandboxedEnvironment

from csm_api_client.service.cfs import CFSClient
from csm_api_client.service.cfs import CFSClientBase
from sat.cli.bootprep.errors import InputItemCreateError
from sat.cli.bootprep.input.configuration import (
AdditionalInventory,
Expand Down Expand Up @@ -617,7 +617,7 @@ def setUp(self):
self.mock_instance = Mock(spec=InputInstance)
# Fake index of configuration data in an input file
self.index = 0
self.mock_cfs_client = Mock(spep=CFSClient)
self.mock_cfs_client = Mock(spep=CFSClientBase)

def tearDown(self):
patch.stopall()
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/bootprep/input/test_image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2023-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -26,7 +26,7 @@
from unittest.mock import Mock, patch

from cray_product_catalog.query import InstalledProductVersion, ProductCatalog
from csm_api_client.service.cfs import CFSClient
from csm_api_client.service.cfs import CFSClientBase
from jinja2 import Environment

from sat.apiclient.ims import IMSClient
Expand Down Expand Up @@ -64,7 +64,7 @@ def setUp(self):

self.jinja_env = Environment()
self.jinja_env.globals = {self.product_name: {'version': self.product_version}}
self.mock_cfs_client = Mock(spec=CFSClient)
self.mock_cfs_client = Mock(spec=CFSClientBase)
self.mock_ims_client = Mock(spec=IMSClient)

# The IMS resources should have the same info as in the product catalog entries
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/bootprep/test_main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -131,7 +131,7 @@ def setUp(self):
self.mock_input_instance_cls = patch('sat.cli.bootprep.main.InputInstance').start()
self.mock_input_instance = self.mock_input_instance_cls.return_value
self.mock_sat_session = patch('sat.cli.bootprep.main.SATSession').start()
self.mock_cfs_client = patch('sat.cli.bootprep.main.CFSClient').start().return_value
self.mock_cfs_client = patch('sat.cli.bootprep.main.CFSClientBase.get_cfs_client').start().return_value
self.mock_ims_client = patch('sat.cli.bootprep.main.IMSClient').start().return_value
self.mock_bos_client = patch('sat.cli.bootprep.main.BOSClientCommon.get_bos_client').start().return_value
self.mock_configurations = self.mock_input_instance.input_configurations
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/bootsys/test_service_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def json():

patch('sat.cli.bootsys.service_activity.SATSession').start()
self.mock_cfs_client = patch(
'sat.cli.bootsys.service_activity.CFSClient').start()
'sat.cli.bootsys.service_activity.CFSClientBase.get_cfs_client').start()
self.mock_cfs_client.return_value.get = mock_cfs_get

def tearDown(self):
Expand Down

0 comments on commit aa09943

Please sign in to comment.