Skip to content

Commit e410de4

Browse files
committed
fix: apply sat file command used to create 'node_groups: []' array instead of removing the field in bos sessiontemplate when this field was not needed and such struct is not valid in CSM. This patch address this issue and node_groups will be removed if not needed
1 parent 267842e commit e410de4

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/commands/i_apply_sat_file/utils.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,9 @@ pub async fn process_session_template_section_in_sat_file(
21802180
)
21812181
.await
21822182
.unwrap_or_else(|_| {
2183+
// In dry run mode, generate a mock image
21832184
let dry_run_mock_image = if is_image_id {
2185+
// Image reference is an image ID
21842186
ims::image::http_client::types::Image {
21852187
id: Some(image_reference.to_string()),
21862188
created: None,
@@ -2194,6 +2196,7 @@ pub async fn process_session_template_section_in_sat_file(
21942196
metadata: None,
21952197
}
21962198
} else {
2199+
// Image reference is an image name
21972200
ims::image::http_client::types::Image {
21982201
id: None,
21992202
created: None,
@@ -2334,10 +2337,9 @@ pub async fn process_session_template_section_in_sat_file(
23342337

23352338
//FIXME: Get rid of this by making sure CSM admins don't create HSM groups for system
23362339
//wide operations instead of using roles
2337-
let node_groups_opt =
2338-
Some(hsm::group::hacks::filter_system_hsm_group_names(
2339-
node_groups_opt.unwrap_or_default(),
2340-
));
2340+
let node_groups_opt = node_groups_opt.map(|node_groups| {
2341+
hsm::group::hacks::filter_system_hsm_group_names(node_groups)
2342+
});
23412343

23422344
// Validate/check HSM groups in YAML file session_templates.bos_parameters.boot_sets.<parameter>.node_groups matches with
23432345
// Check hsm groups in SAT file includes the hsm_group_param
@@ -2397,7 +2399,7 @@ pub async fn process_session_template_section_in_sat_file(
23972399
etag: Some(ims_image_etag.to_string()),
23982400
kernel_parameters: Some(kernel_parameters.to_string()),
23992401
node_list: node_list_opt,
2400-
node_roles_groups: node_roles_groups_opt, // TODO: investigate whether this value can be a list
2402+
node_roles_groups: node_roles_groups_opt,
24012403
node_groups: node_groups_opt,
24022404
rootfs_provider,
24032405
rootfs_provider_passthrough,

src/node/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub async fn validate_target_hsm_members(
3232
)
3333
.await; */
3434

35-
let all_xnames_user_has_access =
35+
let xnames_user_has_access =
3636
hsm::group::utils::get_member_vec_from_hsm_name_vec(
3737
shasta_token,
3838
shasta_base_url,
@@ -53,9 +53,10 @@ pub async fn validate_target_hsm_members(
5353
.await; */
5454

5555
// Check user has access to all xnames he is requesting
56-
if hsm_group_members_opt.iter().all(|hsm_member| {
57-
all_xnames_user_has_access.contains(&hsm_member.to_string())
58-
}) {
56+
if hsm_group_members_opt
57+
.iter()
58+
.all(|hsm_member| xnames_user_has_access.contains(&hsm_member.to_string()))
59+
{
5960
Ok(
6061
hsm_group_members_opt
6162
.iter()

0 commit comments

Comments
 (0)