From 3d733d365ddedfbf61039aaee0314aaa881110ce Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 9 Feb 2024 14:06:52 +0000 Subject: [PATCH 1/2] Fix some typos and missing apostrophes Signed-off-by: Frediano Ziglio --- xcp/net/ifrename/dynamic.py | 2 +- xcp/net/ifrename/logic.py | 6 +++--- xcp/net/ifrename/macpci.py | 2 +- xcp/net/ifrename/static.py | 2 +- xcp/net/ip.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xcp/net/ifrename/dynamic.py b/xcp/net/ifrename/dynamic.py index f49147d7..6578da57 100644 --- a/xcp/net/ifrename/dynamic.py +++ b/xcp/net/ifrename/dynamic.py @@ -117,7 +117,7 @@ def load_and_parse(self): if len(l.strip()) and l.strip()[0] != '#' ] ) - # If the data is empty, dont pass it to json + # If the data is empty, don't pass it to json if not len( data.strip() ): return True diff --git a/xcp/net/ifrename/logic.py b/xcp/net/ifrename/logic.py index e66328e7..476dc2d7 100644 --- a/xcp/net/ifrename/logic.py +++ b/xcp/net/ifrename/logic.py @@ -101,7 +101,7 @@ def __rename_nic(nic, name, transactions, cur_state): else: # Another nic is in the way for applying the rule. Move it sideways - # Old comment from 2012: given new assertions, will this ever be nessesary? + # Old comment from 2012: given new assertions, will this ever be necessary? if aliased.kname[:5] == "side-": aliased_eth = aliased.kname.split('-')[2] else: @@ -371,7 +371,7 @@ def rename( static_rules, old_state ): """ Rename current state based on the rules and past state. - This function sanitises the input and delgates the renaming logic to + This function sanitises the input and delegates the renaming logic to __rename. @param static_rules List of MACPCI objects representing rules @@ -384,7 +384,7 @@ def rename( static_rules, @throws StaticRuleError, CurrentStateError, LastStateError, TypeError - @returns list of tuples of name changes requred + @returns list of tuples of name changes required """ if len(static_rules): diff --git a/xcp/net/ifrename/macpci.py b/xcp/net/ifrename/macpci.py index aef19918..3a21d6da 100644 --- a/xcp/net/ifrename/macpci.py +++ b/xcp/net/ifrename/macpci.py @@ -24,7 +24,7 @@ """ MACPCI object. -Used extensivly for interface rename logic. +Used extensively for interface rename logic. """ __version__ = "1.0.1" diff --git a/xcp/net/ifrename/static.py b/xcp/net/ifrename/static.py index e08bc7d4..59fda548 100644 --- a/xcp/net/ifrename/static.py +++ b/xcp/net/ifrename/static.py @@ -330,7 +330,7 @@ def save(self, header = True): fd = open_with_codec_handling(self.path, "w") fd.write(self.write(header)) - # else if we were given a file descriptor, just read it + # else if we were given a file descriptor, just write to it elif self.fd: self.fd.write(self.write(header)) diff --git a/xcp/net/ip.py b/xcp/net/ip.py index a20152cd..55b7e832 100644 --- a/xcp/net/ip.py +++ b/xcp/net/ip.py @@ -86,8 +86,8 @@ def ip_link_set_name(src_name, dst_name): if isup: # Performace note: if we are doing an intermediate rename to - # move a device sideways, we shouldnt bring it back until it has - # its final name. However, i cant think of a non-hacky way of doing + # move a device sideways, we shouldn't bring it back until it has + # its final name. However, I can't think of a non-hacky way of doing # this with the current implementation link_up = Popen(["ip", "link", "set", dst_name, "up"], universal_newlines=True) From c8ee01097c106fad5740e3a14e98c22323fd29e6 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Fri, 9 Feb 2024 14:08:06 +0000 Subject: [PATCH 2/2] Makes xcp/net/ifrename/{dynamic.py,static.py} more similar They are pretty similar, sync some differences. Signed-off-by: Frediano Ziglio --- xcp/net/ifrename/dynamic.py | 1 - xcp/net/ifrename/static.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/xcp/net/ifrename/dynamic.py b/xcp/net/ifrename/dynamic.py index 6578da57..ad8f61ba 100644 --- a/xcp/net/ifrename/dynamic.py +++ b/xcp/net/ifrename/dynamic.py @@ -238,7 +238,6 @@ def generate(self, state): LOG.critical("Unknown dynamic rule method %s" % method) - def write(self, header = True): """ Write the dynamic rules to a string diff --git a/xcp/net/ifrename/static.py b/xcp/net/ifrename/static.py index 59fda548..76ab3723 100644 --- a/xcp/net/ifrename/static.py +++ b/xcp/net/ifrename/static.py @@ -292,6 +292,9 @@ def generate(self, state): LOG.critical("Unknown static rule method %s" % method) def write(self, header = True): + """ + Write the static rules to a string + """ res = "" @@ -320,6 +323,10 @@ def write(self, header = True): return res def save(self, header = True): + """ + Save the static rules to a file/path. + Returns boolean indicating success or failure. + """ fd = None