-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tutorial 02 Nautobot setup: use poetry as installation method
- Loading branch information
Showing
15 changed files
with
3,215 additions
and
3,898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
ARG NAUTOBOT_VER="2.2.7" | ||
ARG PYTHON_VER="3.9" | ||
|
||
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER} AS base | ||
|
||
|
||
ARG NAUTOBOT_ROOT=/opt/nautobot | ||
|
||
ENV prometheus_multiproc_dir=/prom_cache | ||
ENV NAUTOBOT_ROOT=${NAUTOBOT_ROOT} | ||
|
||
|
||
RUN which poetry || curl -sSL https://install.python-poetry.org | python3 - && \ | ||
poetry config virtualenvs.create false | ||
|
||
|
||
COPY pyproject.toml poetry.lock /source/ | ||
WORKDIR /source | ||
|
||
ENV PATH="${POETRY_HOME}/bin:${PATH}" | ||
|
||
RUN --mount=type=cache,target="/root/.cache",sharing=locked \ | ||
poetry install --no-root --no-ansi --no-interaction --only main | ||
|
||
|
||
FROM base AS apps | ||
|
||
RUN --mount=type=cache,target="/root/.cache",sharing=locked \ | ||
poetry install --no-root --no-ansi --no-interaction --only apps | ||
|
||
|
||
FROM apps AS dev | ||
|
||
COPY pkg /source/pkg | ||
|
||
RUN --mount=type=cache,target="/root/.cache",sharing=locked \ | ||
poetry install --no-root --no-ansi --no-interaction --only dev | ||
|
||
RUN cd /source/pkg/custom_napalm && \ | ||
poetry install --no-ansi --no-interaction --only main | ||
|
||
RUN cd /source/pkg/onboarding_extensions && \ | ||
poetry install --no-ansi --no-interaction --only main | ||
|
||
|
||
COPY nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
02-Nautobot-setup/nautobot/pkg/custom_napalm/custom_napalm/custom_eos.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from napalm.eos.eos import EOSDriver | ||
|
||
|
||
class CustomEOSDriver(EOSDriver): | ||
"""Custom NAPALM Arista EOS Handler.""" | ||
|
||
def get_my_banner(self): | ||
command = 'show banner motd' | ||
output = self._send_command(command) | ||
|
||
return_vars = {} | ||
for line in output.splitlines(): | ||
split_line = line.split() | ||
if "Site:" == split_line[0]: | ||
return_vars["site"] = split_line[1] | ||
elif "Device:" == split_line[0]: | ||
return_vars["device"] = split_line[1] | ||
elif "Floor:" == split_line[0]: | ||
return_vars["floor"] = split_line[1] | ||
elif "Room:" == split_line[0]: | ||
return_vars["room"] = split_line[1] | ||
return return_vars |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
02-Nautobot-setup/nautobot/pkg/custom_napalm/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[tool.poetry] | ||
name = "custom-napalm" | ||
version = "0.1.0" | ||
description = "custom napalm" | ||
authors = ["Michal Spiez <[email protected]>"] | ||
license = "Apache-2.0" | ||
packages = [ | ||
{ include = "custom_napalm" } | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.8,<3.12" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Oops, something went wrong.