mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
log: add extra try except when removing log dirs and fix eni.d cp
The extra try/except are necessary just in case something goes wrong we still want to go through the entire list of extra log dir present on the system. Signed-off-by: Julien Fortin <jfortin@nvidia.com>
This commit is contained in:
@ -193,16 +193,19 @@ class LogManager:
|
||||
# cp ENI and ENI.d in the log directory
|
||||
shutil.copy2("/etc/network/interfaces", new_dir_path)
|
||||
try:
|
||||
shutil.copytree("/etc/network/interfaces.d/", new_dir_path)
|
||||
except FileNotFoundError:
|
||||
shutil.copytree("/etc/network/interfaces.d/", "%s/interfaces.d" % new_dir_path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# remove extra directory logs if we are reaching the 'user_config_limit'
|
||||
len_ifupdown2_log_dirs = len(ifupdown2_log_dirs)
|
||||
if len_ifupdown2_log_dirs > user_config_limit:
|
||||
for index in range(0, len_ifupdown2_log_dirs - user_config_limit):
|
||||
try:
|
||||
directory_to_remove = "%s/%s%s_%s" % (self.LOGGING_DIRECTORY, self.LOGGING_DIRECTORY_PREFIX, ifupdown2_log_dirs[index][0], ifupdown2_log_dirs[index][1])
|
||||
shutil.rmtree(directory_to_remove, ignore_errors=True)
|
||||
except:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def __create_dir(path):
|
||||
|
Reference in New Issue
Block a user