Skip to content

Commit

Permalink
update (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyschulman authored Jan 21, 2024
1 parent 26c4ef3 commit d0fef4f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
51 changes: 48 additions & 3 deletions netcam_aioeos/config/eos_dcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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} ..."
Expand Down Expand Up @@ -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")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down

0 comments on commit d0fef4f

Please sign in to comment.