diff --git a/crmsh/corosync.py b/crmsh/corosync.py index 0b21cde1a..282460817 100644 --- a/crmsh/corosync.py +++ b/crmsh/corosync.py @@ -682,7 +682,7 @@ def update_link(self, linknumber: int, options: dict[str, str|None]) -> dict: Returns: updated configuration dom. The internal state of LinkManager is also updated. """ links = self.links() - if links[linknumber] is None: + if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None: raise ValueError(f'Link {linknumber} does not exist.') if 'nodes' in options: raise ValueError('Unknown option "nodes".') @@ -735,7 +735,7 @@ def update_node_addr(self, linknumber: int, node_addresses: typing.Mapping[int, Returns: updated configuration dom. The internal state of LinkManager is also updated. """ links = self.links() - if links[linknumber] is None: + if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None: raise ValueError(f'Link {linknumber} does not exist.') return self.__upsert_node_addr_impl(self._config, links, linknumber, node_addresses) @@ -804,7 +804,7 @@ def remove_link(self, linknumber: int) -> dict: Returns: updated configuration dom. The internal state of LinkManager is also updated. """ links = self.links() - if links[linknumber] is None: + if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None: raise ValueError(f'Link {linknumber} does not exist.') if sum(1 if link is not None else 0 for link in links) <= 1: raise ValueError(f'Cannot remove the last link.')