Skip to content

Commit a5529bc

Browse files
committed
Fix buffer_profile GCU validator to pass scope to rdma_config_update_validator
validate_field_operation invokes validators as (scope, patch_element). buffer_profile_config_update_validator only took patch_element and called rdma_config_update_validator with one argument, causing TypeError on field-level BUFFER_PROFILE patches. Accept scope and forward both arguments. Signed-off-by: anamehra <anamehra@cisco.com>
1 parent 9733062 commit a5529bc

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

generic_config_updater/field_operation_validators.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ def get_asic_name():
6262
return asic
6363

6464

65-
def buffer_profile_config_update_validator(patch_element):
65+
def buffer_profile_config_update_validator(scope, patch_element):
6666
"""
6767
Enhanced buffer profile validator that handles both field-level and object-level operations.
6868
- Field-level operations (e.g., /BUFFER_PROFILE/profile/dynamic_th) follow existing rules
6969
- Object-level operations (e.g., /BUFFER_PROFILE/profile) allow remove operations
70+
71+
scope: same as other GCU validators (e.g. localhost, asic0); forwarded to rdma_config_update_validator.
7072
"""
7173
path = patch_element["path"]
7274
path_parts = jsonpointer.JsonPointer(path).parts
@@ -87,7 +89,7 @@ def buffer_profile_config_update_validator(patch_element):
8789
return False # Disallow unsupported operations
8890

8991
# For field-level operations, use the existing validation logic
90-
return rdma_config_update_validator(patch_element)
92+
return rdma_config_update_validator(scope, patch_element)
9193

9294

9395
def rdma_config_update_validator(scope, patch_element):

tests/generic_config_updater/field_operation_validator_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ def test_buffer_profile_config_update_validator_object_level_remove(self):
379379
}
380380

381381
# Object-level remove should be allowed without ASIC/version validation
382-
assert fov.buffer_profile_config_update_validator(patch_element) is True
382+
for scope in ["localhost", "asic0"]:
383+
assert fov.buffer_profile_config_update_validator(scope, patch_element) is True
383384

384385
def test_buffer_profile_config_update_validator_object_level_add(self):
385386
"""Test that object-level add operations are allowed"""
@@ -390,7 +391,8 @@ def test_buffer_profile_config_update_validator_object_level_add(self):
390391
}
391392

392393
# Object-level add should be allowed
393-
assert fov.buffer_profile_config_update_validator(patch_element) is True
394+
for scope in ["localhost", "asic0"]:
395+
assert fov.buffer_profile_config_update_validator(scope, patch_element) is True
394396

395397
def test_buffer_profile_config_update_validator_object_level_unsupported_op(self):
396398
"""Test that unsupported operations on object-level are denied"""
@@ -400,7 +402,8 @@ def test_buffer_profile_config_update_validator_object_level_unsupported_op(self
400402
"from": "/BUFFER_PROFILE/old_profile"
401403
}
402404

403-
assert fov.buffer_profile_config_update_validator(patch_element) is False
405+
for scope in ["localhost", "asic0"]:
406+
assert fov.buffer_profile_config_update_validator(scope, patch_element) is False
404407

405408
def test_buffer_profile_config_update_validator_field_level_uses_existing_validation(self):
406409
"""Test that field-level operations use existing validation logic"""
@@ -413,4 +416,5 @@ def test_buffer_profile_config_update_validator_field_level_uses_existing_valida
413416
# Mock the existing validation to return True
414417
with patch("generic_config_updater.field_operation_validators.rdma_config_update_validator",
415418
return_value=True):
416-
assert fov.buffer_profile_config_update_validator(patch_element) is True
419+
for scope in ["localhost", "asic0"]:
420+
assert fov.buffer_profile_config_update_validator(scope, patch_element) is True

0 commit comments

Comments
 (0)