From d0fef4f73fa317e8d8aeaab3b1c72f5681e374c1 Mon Sep 17 00:00:00 2001 From: Jeremy Schulman Date: Sun, 21 Jan 2024 14:41:24 -0500 Subject: [PATCH] update (#47) --- Makefile | 12 ++------ netcam_aioeos/config/eos_dcfg.py | 51 ++++++++++++++++++++++++++++++-- pyproject.toml | 2 +- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 829e2a0..34a2ab4 100644 --- a/Makefile +++ b/Makefile @@ -8,17 +8,11 @@ all: precheck precheck: invoke precheck -package: setup.py requirements.txt - -setup.py: - poetry build && \ - tar --strip-components=1 -xvf dist/$(DIST_BASENAME).tar.gz '*/setup.py' - -requirements.txt: - poetry export --without-hashes > requirements.txt - clean: rm -rf dist *.egg-info .pytest_cache rm -f requirements.txt setup.py rm -f poetry.lock find . -name '__pycache__' | xargs rm -rf + +doc-check: + interrogate -vvv netcam_aioeos --omit-covered-files diff --git a/netcam_aioeos/config/eos_dcfg.py b/netcam_aioeos/config/eos_dcfg.py index f4986d6..6dc2e06 100644 --- a/netcam_aioeos/config/eos_dcfg.py +++ b/netcam_aioeos/config/eos_dcfg.py @@ -140,7 +140,15 @@ async def config_diff(self) -> str: return self.config_diff_contents async def config_replace(self, rollback_timeout: int): - """ """ + """ + This function is used to load-replace the configuration file using an + EOS configuration session. + + rollback_timeout: + The amount of time (minutes) to set when doing the commit with + timeout command. + + """ log = get_logger() log.info( f"{self.device.name}: loading config into session {self.config_id} ..." @@ -181,6 +189,43 @@ async def file_delete(self): await self.eapi.cli(f"delete {self.local_file}") async def config_merge(self, rollback_timeout: int): - raise RuntimeError( - f"{self.device.name}: EOS config-mgmt does not support merge" + """ + This function is used to load-merge the configuration file using an + EOS configuration session. + + Parameters + ---------- + rollback_timeout: + The amount of time (minutes) to set when doing the commit with + timeout command. + """ + log = get_logger() + log.info( + f"{self.device.name}: loading config into session {self.config_id} ..." ) + await self.sesson_config.load_scp_file(filename=self.local_file) + + # capture the diffs before running the commit + log.info(f"{self.device.name}: generating session diff ...") + self.config_diff_contents = await self.sesson_config.diff() + + # if there are no diffs, abort the session, and return + if not self.config_diff_contents: + await self.sesson_config.abort() + return + + log.info( + f"{self.device.name}: commit with rollback-timer {rollback_timeout} minutes ..." + ) + await self.sesson_config.commit(timer=f"00:{rollback_timeout:02}:00") + + log.info(f"{self.device.name}: checking device reachability ...") + if not await self.is_reachable(): + raise RuntimeError(f"{self.device.name}: device is no longer reachable.") + + # commit the configuration and copy running to startup + log.info( + f"{self.device.name}: committing confiuration and saving to startup ..." + ) + await self.sesson_config.commit() + await self.eapi.cli("write") diff --git a/pyproject.toml b/pyproject.toml index bf1f99b..a700525 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netcam-aioeos" -version = "0.6.7" +version = "0.7.0" description = "NetCAD/CAM - Arista EOS/eAPI asyncio driver" readme = "README.md" authors = ["Jeremy Schulman"]