Skip to content

Commit

Permalink
Fix Weekly Build (#18)
Browse files Browse the repository at this point in the history
* pin to non pre-release cfg/replay
* fix order of operations issue for junos abort config
* slack dependabot to be monthly instead of weekly
* pin to scrapli 2022.01.30a2 to fix juniper shell prompts
* regen docs
  • Loading branch information
carlmontanari authored Oct 3, 2021
1 parent b75b68c commit 0d967f2
Show file tree
Hide file tree
Showing 23 changed files with 659 additions and 1,498 deletions.
6 changes: 2 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
interval: "monthly"
timezone: "PST8PDT"
time: "03:00"
target-branch: "develop"
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
interval: "monthly"
timezone: "PST8PDT"
time: "03:00"
target-branch: "develop"
7 changes: 6 additions & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.4]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.2]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand All @@ -42,6 +42,11 @@ jobs:
# version we are targeting with nox, while still having versions like 3.9.0a4
run: |
echo "FRIENDLY_PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")" >> $GITHUB_ENV
- name: ensure openssl installed for macos
# openssl missing/being linked incorrectly causes ssh2-python install failures
if: matrix.os == 'macos-latest'
run: |
brew install openssl
- name: setup test env
run: |
python -m pip install --upgrade pip
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/weekly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-beta.4]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.2]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand All @@ -46,6 +46,11 @@ jobs:
# version we are targeting with nox, while still having versions like 3.9.0a4
run: |
echo "FRIENDLY_PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")" >> $GITHUB_ENV
- name: ensure openssl installed for macos
# openssl missing/being linked incorrectly causes ssh2-python install failures
if: matrix.os == 'macos-latest'
run: |
brew install openssl
- name: setup test env
run: |
python -m pip install --upgrade pip
Expand Down
19 changes: 4 additions & 15 deletions docs/api_docs/platform/core/juniper_junos/async_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ from scrapli_cfg.exceptions import DiffConfigError
from scrapli_cfg.platform.base.async_platform import AsyncScrapliCfgPlatform
from scrapli_cfg.platform.core.juniper_junos.base_platform import (
CONFIG_SOURCES,
JUNOS_ADDTL_PRIVS,
ScrapliCfgJunosBase,
)
from scrapli_cfg.response import ScrapliCfgResponse
Expand Down Expand Up @@ -77,11 +76,6 @@ class AsyncScrapliCfgJunos(AsyncScrapliCfgPlatform, ScrapliCfgJunosBase):

self.cleanup_post_commit = cleanup_post_commit

original_privs = self.conn.privilege_levels
updated_privs = {**original_privs, **JUNOS_ADDTL_PRIVS}
self.conn.privilege_levels = updated_privs
self.conn.update_privilege_levels()

async def _delete_candidate_config(self) -> Response:
"""
Delete candidate config from the filesystem
Expand Down Expand Up @@ -180,12 +174,12 @@ class AsyncScrapliCfgJunos(AsyncScrapliCfgPlatform, ScrapliCfgJunosBase):
session_or_config_file=bool(self.candidate_config_filename)
)

abort_result = await self._delete_candidate_config()
rollback_result = await self.conn.send_config(config="rollback 0")
abort_result = await self._delete_candidate_config()
self._reset_config_session()

return self._post_abort_config(
response=response, scrapli_responses=[abort_result, rollback_result]
response=response, scrapli_responses=[rollback_result, abort_result]
)

async def commit_config(self, source: str = "running") -> ScrapliCfgResponse:
Expand Down Expand Up @@ -334,11 +328,6 @@ class AsyncScrapliCfgJunos(AsyncScrapliCfgPlatform, ScrapliCfgJunosBase):

self.cleanup_post_commit = cleanup_post_commit

original_privs = self.conn.privilege_levels
updated_privs = {**original_privs, **JUNOS_ADDTL_PRIVS}
self.conn.privilege_levels = updated_privs
self.conn.update_privilege_levels()

async def _delete_candidate_config(self) -> Response:
"""
Delete candidate config from the filesystem
Expand Down Expand Up @@ -437,12 +426,12 @@ class AsyncScrapliCfgJunos(AsyncScrapliCfgPlatform, ScrapliCfgJunosBase):
session_or_config_file=bool(self.candidate_config_filename)
)

abort_result = await self._delete_candidate_config()
rollback_result = await self.conn.send_config(config="rollback 0")
abort_result = await self._delete_candidate_config()
self._reset_config_session()

return self._post_abort_config(
response=response, scrapli_responses=[abort_result, rollback_result]
response=response, scrapli_responses=[rollback_result, abort_result]
)

async def commit_config(self, source: str = "running") -> ScrapliCfgResponse:
Expand Down
28 changes: 0 additions & 28 deletions docs/api_docs/platform/core/juniper_junos/base_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ from datetime import datetime
from logging import LoggerAdapter
from typing import Tuple

from scrapli.driver.network.base_driver import PrivilegeLevel
from scrapli_cfg.platform.core.juniper_junos.patterns import (
EDIT_PATTERN,
OUTPUT_HEADER_PATTERN,
Expand All @@ -45,33 +44,6 @@ CONFIG_SOURCES = [
"running",
]

JUNOS_ADDTL_PRIVS = {
"shell": (
PrivilegeLevel(
pattern=r"^(?!root)%\s?$",
name="shell",
previous_priv="exec",
deescalate="exit",
escalate="start shell",
escalate_auth=False,
escalate_prompt="",
)
),
# feel like ive had issues w/ root shell in the past... if this all goes well then it can be
# added back to scrapli core
"root_shell": (
PrivilegeLevel(
pattern=r"^root@%\s?$",
name="root_shell",
previous_priv="exec",
deescalate="exit",
escalate="start shell user root",
escalate_auth=True,
escalate_prompt=r"^[pP]assword:\s?$",
)
),
}


class ScrapliCfgJunosBase:
logger: LoggerAdapter
Expand Down
19 changes: 4 additions & 15 deletions docs/api_docs/platform/core/juniper_junos/sync_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ from scrapli_cfg.exceptions import DiffConfigError
from scrapli_cfg.platform.base.sync_platform import ScrapliCfgPlatform
from scrapli_cfg.platform.core.juniper_junos.base_platform import (
CONFIG_SOURCES,
JUNOS_ADDTL_PRIVS,
ScrapliCfgJunosBase,
)
from scrapli_cfg.response import ScrapliCfgResponse
Expand Down Expand Up @@ -77,11 +76,6 @@ class ScrapliCfgJunos(ScrapliCfgPlatform, ScrapliCfgJunosBase):

self.cleanup_post_commit = cleanup_post_commit

original_privs = self.conn.privilege_levels
updated_privs = {**original_privs, **JUNOS_ADDTL_PRIVS}
self.conn.privilege_levels = updated_privs
self.conn.update_privilege_levels()

def _delete_candidate_config(self) -> Response:
"""
Delete candidate config from the filesystem
Expand Down Expand Up @@ -178,12 +172,12 @@ class ScrapliCfgJunos(ScrapliCfgPlatform, ScrapliCfgJunosBase):
session_or_config_file=bool(self.candidate_config_filename)
)

abort_result = self._delete_candidate_config()
rollback_result = self.conn.send_config(config="rollback 0")
abort_result = self._delete_candidate_config()
self._reset_config_session()

return self._post_abort_config(
response=response, scrapli_responses=[abort_result, rollback_result]
response=response, scrapli_responses=[rollback_result, abort_result]
)

def commit_config(self, source: str = "running") -> ScrapliCfgResponse:
Expand Down Expand Up @@ -332,11 +326,6 @@ class ScrapliCfgJunos(ScrapliCfgPlatform, ScrapliCfgJunosBase):

self.cleanup_post_commit = cleanup_post_commit

original_privs = self.conn.privilege_levels
updated_privs = {**original_privs, **JUNOS_ADDTL_PRIVS}
self.conn.privilege_levels = updated_privs
self.conn.update_privilege_levels()

def _delete_candidate_config(self) -> Response:
"""
Delete candidate config from the filesystem
Expand Down Expand Up @@ -433,12 +422,12 @@ class ScrapliCfgJunos(ScrapliCfgPlatform, ScrapliCfgJunosBase):
session_or_config_file=bool(self.candidate_config_filename)
)

abort_result = self._delete_candidate_config()
rollback_result = self.conn.send_config(config="rollback 0")
abort_result = self._delete_candidate_config()
self._reset_config_session()

return self._post_abort_config(
response=response, scrapli_responses=[abort_result, rollback_result]
response=response, scrapli_responses=[rollback_result, abort_result]
)

def commit_config(self, source: str = "running") -> ScrapliCfgResponse:
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

## 2022.01.30

- Revised juniper abort config to remove candidate config file *after* rollback 0 to avoid issues where junos would
prompt for confirmation when exiting config mode to go delete the candidate config file prompting timeouts.


## 2021.07.30

- Initial release!
2 changes: 1 addition & 1 deletion examples/basic_usage/config_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main():
"""Demo basic config replace functionality"""

# load up a config to use for the candidate config
with open("config", "r") as f:
with open("config", "r", encoding="utf-8") as f:
my_config = f.read()

# open the "normal" scrapli connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
# in the configuration that looks an awful lot like a jinja2 variable, in this case:
# "{{ ethernet_interfaces }}" -- all we need to do is tell scrapli_cfg how to match (from the
# actual running config) what *should* go in this section (see the next comment section!)
with open("config", "r") as f:
with open("config", "r", encoding="utf-8") as f:
my_config = f.read()

# in this example we have a `dedicated_connection` which means that the scrapli connection is
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def parse_requirements(dev: bool = True) -> Dict[str, str]:
requirements = {}
requirements_file = "requirements.txt" if dev is False else "requirements-dev.txt"

with open(requirements_file, "r") as f:
with open(requirements_file, "r", encoding="utf-8") as f:
requirements_file_lines = f.readlines()

requirements_lines: List[str] = [
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
black==21.7b0
black==21.9b0
darglint==1.8.0
isort==5.9.3
mypy==0.910
nox==2021.6.12
nox==2021.10.1
pycodestyle==2.7.0
pydocstyle==6.1.1
pyfakefs==4.5.0
pyfakefs==4.5.1
pylama==7.7.1
pylint==2.9.6
pylint==2.11.1
pytest-asyncio==0.15.1
pytest-cov==2.12.1
pytest==6.2.4
scrapli-replay==2021.7.30a5
pytest==6.2.5
scrapli-replay==2021.7.30
-r requirements-asyncssh.txt
-r requirements-paramiko.txt
-r requirements-ssh2.txt
Expand Down
6 changes: 3 additions & 3 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mdx-gh-links==0.2
mkdocs==1.2.2
mkdocs-material==7.2.1
mkdocs-material-extensions==1.0.1
pdoc3==0.9.2 ; sys_platform != "win32"
mkdocs-material==7.3.1
mkdocs-material-extensions==1.0.3
pdoc3==0.10.0 ; sys_platform != "win32"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scrapli>=2021.07.30a3
scrapli>=2022.01.30a2
10 changes: 2 additions & 8 deletions scrapli_cfg/platform/core/juniper_junos/async_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from scrapli_cfg.platform.base.async_platform import AsyncScrapliCfgPlatform
from scrapli_cfg.platform.core.juniper_junos.base_platform import (
CONFIG_SOURCES,
JUNOS_ADDTL_PRIVS,
ScrapliCfgJunosBase,
)
from scrapli_cfg.response import ScrapliCfgResponse
Expand Down Expand Up @@ -47,11 +46,6 @@ def __init__(

self.cleanup_post_commit = cleanup_post_commit

original_privs = self.conn.privilege_levels
updated_privs = {**original_privs, **JUNOS_ADDTL_PRIVS}
self.conn.privilege_levels = updated_privs
self.conn.update_privilege_levels()

async def _delete_candidate_config(self) -> Response:
"""
Delete candidate config from the filesystem
Expand Down Expand Up @@ -150,12 +144,12 @@ async def abort_config(self) -> ScrapliCfgResponse:
session_or_config_file=bool(self.candidate_config_filename)
)

abort_result = await self._delete_candidate_config()
rollback_result = await self.conn.send_config(config="rollback 0")
abort_result = await self._delete_candidate_config()
self._reset_config_session()

return self._post_abort_config(
response=response, scrapli_responses=[abort_result, rollback_result]
response=response, scrapli_responses=[rollback_result, abort_result]
)

async def commit_config(self, source: str = "running") -> ScrapliCfgResponse:
Expand Down
28 changes: 0 additions & 28 deletions scrapli_cfg/platform/core/juniper_junos/base_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from logging import LoggerAdapter
from typing import Tuple

from scrapli.driver.network.base_driver import PrivilegeLevel
from scrapli_cfg.platform.core.juniper_junos.patterns import (
EDIT_PATTERN,
OUTPUT_HEADER_PATTERN,
Expand All @@ -15,33 +14,6 @@
"running",
]

JUNOS_ADDTL_PRIVS = {
"shell": (
PrivilegeLevel(
pattern=r"^(?!root)%\s?$",
name="shell",
previous_priv="exec",
deescalate="exit",
escalate="start shell",
escalate_auth=False,
escalate_prompt="",
)
),
# feel like ive had issues w/ root shell in the past... if this all goes well then it can be
# added back to scrapli core
"root_shell": (
PrivilegeLevel(
pattern=r"^root@%\s?$",
name="root_shell",
previous_priv="exec",
deescalate="exit",
escalate="start shell user root",
escalate_auth=True,
escalate_prompt=r"^[pP]assword:\s?$",
)
),
}


class ScrapliCfgJunosBase:
logger: LoggerAdapter
Expand Down
Loading

0 comments on commit 0d967f2

Please sign in to comment.