Merge "Add patch method in EthernetSwitchACLRule in RSD 2.1"

This commit is contained in:
Zuul 2019-04-09 23:09:08 +00:00 committed by Gerrit Code Review
commit 9b7c8a0e04
2 changed files with 28 additions and 0 deletions

View File

@ -130,6 +130,17 @@ class EthernetSwitchACLRule(rsd_lib_base.ResourceBase):
) )
] ]
def update(self, data=None):
"""Update a new ACL rule
:param data: JSON for acl_rule
"""
update_schema = acl_rule_schema.acl_rule_req_schema
del update_schema["required"]
if data is not None or len(data) > 0:
validate(data, update_schema)
self._conn.patch(self.path, data=data)
class EthernetSwitchACLRuleCollection(rsd_lib_base.ResourceCollectionBase): class EthernetSwitchACLRuleCollection(rsd_lib_base.ResourceCollectionBase):
@property @property

View File

@ -197,6 +197,23 @@ class EthernetSwitchACLRuleTestCase(testtools.TestCase):
# | WHEN & THEN | # | WHEN & THEN |
self.assertIsInstance(self.acl_rule_inst.mirror_port_region, list) self.assertIsInstance(self.acl_rule_inst.mirror_port_region, list)
def test_update(self):
data = {
"RuleId": 1,
"Action": "Permit",
"Condition": {
"IPSource": {
"IPv4Address": "192.168.6.0",
"Mask": "0.0.0.255",
},
},
}
self.acl_rule_inst.update(data)
self.acl_rule_inst._conn.patch.assert_called_once_with(
"/redfish/v1/EthernetSwitches/Switch1/ACLs/ACL1/Rules/Rule1",
data=data,
)
class EthernetSwitchACLRuleCollectionTestCase(testtools.TestCase): class EthernetSwitchACLRuleCollectionTestCase(testtools.TestCase):
def setUp(self): def setUp(self):