Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #158 from nautobot/develop
Browse files Browse the repository at this point in the history
Sync develop to main
  • Loading branch information
qduk authored Apr 26, 2023
2 parents 03461dd + c4b3f3c commit 850a1f0
Show file tree
Hide file tree
Showing 15 changed files with 2,562 additions and 1,272 deletions.
68 changes: 26 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
with:
python-version: "3.10"
- name: "Linting: black"
run: "poetry run invoke black"
bandit:
Expand All @@ -36,8 +38,12 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
with:
python-version: "3.10"
- name: "Linting: bandit"
run: "poetry run invoke bandit"
needs:
- "black"
pydocstyle:
runs-on: "ubuntu-20.04"
env:
Expand All @@ -47,8 +53,12 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
with:
python-version: "3.10"
- name: "Linting: pydocstyle"
run: "poetry run invoke pydocstyle"
needs:
- "black"
flake8:
runs-on: "ubuntu-20.04"
env:
Expand All @@ -58,8 +68,12 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
with:
python-version: "3.10"
- name: "Linting: flake8"
run: "poetry run invoke flake8"
needs:
- "black"
yamllint:
runs-on: "ubuntu-20.04"
env:
Expand All @@ -69,8 +83,12 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
with:
python-version: "3.10"
- name: "Linting: yamllint"
run: "poetry run invoke yamllint"
needs:
- "black"
pylint:
needs:
- "bandit"
Expand All @@ -79,38 +97,17 @@ jobs:
- "yamllint"
- "black"
runs-on: "ubuntu-20.04"
strategy:
fail-fast: true
matrix:
python-version: ["3.7"]
nautobot-version: ["1.3.4"]
env:
INVOKE_NAUTOBOT_SSOT_ARISTACV_PYTHON_VER: "${{ matrix.python-version }}"
INVOKE_NAUTOBOT_SSOT_ARISTACV_NAUTOBOT_VER: "${{ matrix.nautobot-version }}"
steps:
- name: "Check out repository code"
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v1"
- name: "Build"
uses: "docker/build-push-action@v2"
with:
builder: "${{ steps.buildx.outputs.name }}"
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
python-version: "3.10"
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Build Container"
run: "poetry run invoke build"
- name: "Linting: pylint"
run: "poetry run invoke pylint"
unittest:
Expand All @@ -119,8 +116,8 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.7", "3.8", "3.9"]
nautobot-version: ["1.0.1", "1.3.4"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
nautobot-version: ["1.4.2", "latest"]
runs-on: "ubuntu-20.04"
env:
INVOKE_NAUTOBOT_SSOT_ARISTACV_PYTHON_VER: "${{ matrix.python-version }}"
Expand All @@ -130,25 +127,12 @@ jobs:
uses: "actions/checkout@v2"
- name: "Setup environment"
uses: "networktocode/gh-action-setup-poetry-environment@v2"
- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v1"
- name: "Build"
uses: "docker/build-push-action@v2"
with:
builder: "${{ steps.buildx.outputs.name }}"
context: "./"
push: false
load: true
tags: "${{ env.PLUGIN_NAME }}/nautobot:${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
file: "./development/Dockerfile"
cache-from: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
cache-to: "type=gha,scope=${{ matrix.nautobot-version }}-py${{ matrix.python-version }}"
build-args: |
NAUTOBOT_VER=${{ matrix.nautobot-version }}
PYTHON_VER=${{ matrix.python-version }}
python-version: "${{ matrix.python-version }}"
- name: "Copy credentials"
run: "cp development/creds.example.env development/creds.env"
- name: "Build Container"
run: "poetry run invoke build"
- name: "Run Tests"
run: "poetry run invoke unittest"
publish_gh:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/upstream_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: "Nautobot Upstream Testing"

on: # yamllint disable-line rule:truthy rule:comments
schedule:
- cron: "0 4 */2 * *" # every other day at midnight

jobs:
upstream-test:
uses: "nautobot/nautobot/.github/workflows/plugin_upstream_testing_base.yml@develop"
with: # Below could potentially be collapsed into a single argument if a concrete relationship between both is enforced
invoke_context_name: "NAUTOBOT_SSOT_ARISTACV"
plugin_name: "nautobot-ssot-aristacv"
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## v1.6.0 - 2023-04-26

### Added

- #149 - Update gRPC service for Cloudvision tags to us tag.v2. Addresses #149.

### Fixed

- #151 - Correct Interface mode. Fixes #139.

## v1.5.1 - 2023-02-24

### Added
Expand Down
84 changes: 73 additions & 11 deletions development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,80 @@
# -------------------------------------------------------------------------------------
# Nautobot App Developement Dockerfile Template
# Version: 1.0.0
#
# Apps that need to add additional steps or packages can do in the section below.
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

ARG PYTHON_VER
ARG NAUTOBOT_VER
# Accepts a desired Nautobot version as build argument, default to 1.4.0
ARG NAUTOBOT_VER="1.4"

# Accepts a desired Python version as build argument, default to 3.8
ARG PYTHON_VER="3.8"

# Retrieve published development image of Nautobot base which should include most CI dependencies
FROM ghcr.io/nautobot/nautobot-dev:${NAUTOBOT_VER}-py${PYTHON_VER}

WORKDIR /source
# Runtime argument and environment setup
ARG NAUTOBOT_ROOT=/opt/nautobot

ENV prometheus_multiproc_dir=/prom_cache
ENV NAUTOBOT_ROOT ${NAUTOBOT_ROOT}

# Install Poetry manually via its installer script;
# We might be using an older version of Nautobot that includes an older version of Poetry
# and CI and local development may have a newer version of Poetry
# Since this is only used for development and we don't ship this container, pinning Poetry back is not expressly necessary
# We also don't need virtual environments in container
RUN curl -sSL https://install.python-poetry.org -o /tmp/install-poetry.py && \
python /tmp/install-poetry.py && \
rm -f /tmp/install-poetry.py && \
poetry config virtualenvs.create false

# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
# -------------------------------------------------------------------------------------
# App-specifc system build/test dependencies.
#
# Example: LDAP requires `libldap2-dev` to be apt-installed before the Python package.
# -------------------------------------------------------------------------------------
# --> Start safe to modify section

# Copy in only pyproject.toml/poetry.lock to help with caching this layer if no updates to dependencies
COPY poetry.lock pyproject.toml /source/
# --no-root declares not to install the project package since we're wanting to take advantage of caching dependency installation
# and the project is copied in and installed after this step
RUN poetry install --no-interaction --no-ansi --no-root --extras "nautobot-device-lifecycle-mgmt"
# Uncomment the line below if you are apt-installing any package.
# RUN apt update
# RUN apt install libldap2-dev

# Copy in the rest of the source code and install local Nautobot plugin
# --> Stop safe to modify section
# -------------------------------------------------------------------------------------
# Install Nautobot App
# -------------------------------------------------------------------------------------
# !!! USE CAUTION WHEN MODIFYING LINES BELOW

# Copy in the source code
WORKDIR /source
COPY . /source
RUN poetry install --no-interaction --no-ansi

COPY development/nautobot_config.py /opt/nautobot/nautobot_config.py
# Get container's installed Nautobot version as a forced constraint
# NAUTOBOT_VER may be a branch name and not a published release therefor we need to get the installed version
# so pip can use it to recognize local constraints.
RUN pip show nautobot | grep "^Version: " | sed -e 's/Version: /nautobot==/' > constraints.txt

# Use Poetry to grab dev dependencies from the lock file
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
#
# We can't use the entire freeze as it takes forever to resolve with rigidly fixed non-direct dependencies,
# especially those that are only direct to Nautobot but the container included versions slightly mismatch
RUN poetry export -f requirements.txt --without-hashes --output poetry_freeze_base.txt
RUN poetry export -f requirements.txt --dev --without-hashes --extras nautobot-device-lifecycle-mgmt --output poetry_freeze_all.txt
RUN sort poetry_freeze_base.txt poetry_freeze_all.txt | uniq -u > poetry_freeze_dev.txt

# Install all local project as editable, constrained on Nautobot version, to get any additional
# direct dependencies of the app
RUN pip install -c constraints.txt -e .
RUN cat poetry_freeze_all.txt

# Install any dev dependencies frozen from Poetry
# Can be improved in Poetry 1.2 which allows `poetry install --only dev`
RUN pip install -c constraints.txt -r poetry_freeze_dev.txt

COPY development/nautobot_config.py ${NAUTOBOT_ROOT}/nautobot_config.py
# !!! USE CAUTION WHEN MODIFYING LINES ABOVE
2 changes: 1 addition & 1 deletion development/docker-compose.requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
image: "redis:6-alpine"
command:
- "sh"
- "-c" # this is to evaluate the $REDIS_PASSWORD from the env
- "-c" # this is to evaluate the $REDIS_PASSWORD from the env
- "redis-server --appendonly yes --requirepass $$REDIS_PASSWORD"
env_file:
- "dev.env"
Expand Down
11 changes: 5 additions & 6 deletions nautobot_ssot_aristacv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Plugin declaration for aristacv_sync."""
import os
from django.conf import settings
from django.db.models.signals import post_migrate
from nautobot.extras.plugins import PluginConfig

try:
from importlib import metadata
Expand All @@ -8,11 +12,6 @@

__version__ = metadata.version(__name__)

import os
from django.conf import settings
from django.db.models.signals import post_migrate
from nautobot.extras.plugins import PluginConfig


class NautobotSSOTAristaCVConfig(PluginConfig):
"""Plugin configuration for the nautobot_ssot_aristacv plugin."""
Expand All @@ -24,7 +23,7 @@ class NautobotSSOTAristaCVConfig(PluginConfig):
description = "Nautobot SSoT Arista CloudVision."
base_url = "nautobot-sot_aristacv"
required_settings = []
min_version = "1.2.0"
min_version = "1.4.0"
max_version = "1.9999"
default_settings = {
"cvp_host": os.getenv("NAUTOBOT_ARISTACV_HOST"),
Expand Down
2 changes: 1 addition & 1 deletion nautobot_ssot_aristacv/diffsync/adapters/cloudvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import distutils
import re

import arista.tag.v1 as TAG
import arista.tag.v2 as TAG
from diffsync import DiffSync
from diffsync.exceptions import ObjectAlreadyExists, ObjectNotFound
from nautobot_ssot_aristacv.diffsync.models.cloudvision import (
Expand Down
4 changes: 4 additions & 0 deletions nautobot_ssot_aristacv/tests/fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ def load_json(path):
INTF_DESCRIPTION_QUERY = load_json(
"./nautobot_ssot_aristacv/tests/fixtures/get_interface_description_client_query.json"
)
TRUNK_INTF_MODE_QUERY = load_json("./nautobot_ssot_aristacv/tests/fixtures/get_interface_mode_client_query_trunk.json")
ACCESS_INTF_MODE_QUERY = load_json(
"./nautobot_ssot_aristacv/tests/fixtures/get_interface_mode_client_query_access.json"
)
IP_INTF_QUERY = load_json("./nautobot_ssot_aristacv/tests/fixtures/get_ip_interfaces_client_query.json")
IP_INTF_FIXTURE = load_json("./nautobot_ssot_aristacv/tests/fixtures/get_ip_interfaces_response.json")
Loading

0 comments on commit 850a1f0

Please sign in to comment.