Skip to content

Commit

Permalink
Merge pull request #27 from scrapli/develop
Browse files Browse the repository at this point in the history
Prepare 2022.01.30 Release
  • Loading branch information
carlmontanari authored Jan 29, 2022
2 parents 0d967f2 + db30c5f commit 1135d17
Show file tree
Hide file tree
Showing 69 changed files with 7,668 additions and 14,781 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
max-parallel: 1
matrix:
os: [ubuntu-latest]
version: [3.9]
version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand All @@ -27,10 +27,10 @@ jobs:
build_posix:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 12
max-parallel: 8
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.2]
version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand Down Expand Up @@ -63,7 +63,18 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: docker run -v $(pwd):/docs --entrypoint "" squidfunk/mkdocs-material:latest ash -c 'pip install mdx_gh_links && mkdocs build --clean --strict'
- name: Cache htmltest external links
uses: actions/cache@v2
with:
path: tmp/.htmltest
# key will contain hash of all md files to check if files have changed
# when files are changed, a new key name is formed, and thus a new cache will be saved
key: htmltest-${{ hashFiles('docs/**/*.md') }}
# the restore key will fetch any previously saved cache even if there is no match on key
# this allows to use cache from prev runs and update it
restore-keys: |
htmltest-
- name: htmltest
run: |
curl https://htmltest.wjdp.uk | bash
./bin/htmltest -c docs/htmltest.yml
uses: wjdp/[email protected]
with:
config: docs/htmltest.yml
6 changes: 3 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up python 3.9
- name: set up python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"
- name: setup publish env
run: |
python -m pip install --upgrade pip
Expand All @@ -27,7 +27,7 @@ jobs:
python setup.py sdist bdist_wheel
python -m twine upload dist/*
- name: create release branch
uses: peterjgrainger/action-create-branch@v2.0.1
uses: peterjgrainger/action-create-branch@v2.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/weekly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
max-parallel: 1
matrix:
os: [ubuntu-latest]
version: [3.9]
version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand All @@ -31,10 +31,10 @@ jobs:
build_posix:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 12
max-parallel: 8
matrix:
os: [ubuntu-latest, macos-latest]
version: [3.6, 3.7, 3.8, 3.9, 3.10.0-rc.2]
version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: set up python ${{ matrix.version }}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ scrapli behaviour you know and love.

## Requirements

MacOS or \*nix<sup>1</sup>, Python 3.6+
MacOS or \*nix<sup>1</sup>, Python 3.7+

scrapli_cfg's only requirements is `scrapli`.

Expand All @@ -59,8 +59,8 @@ from scrapli_cfg import ScrapliCfg

device = {
"host": "172.18.0.11",
"auth_username": "vrnetlab",
"auth_password": "VR-netlab9",
"auth_username": "scrapli",
"auth_password": "scrapli",
"auth_strict_key": False,
"platform": "cisco_iosxe"
}
Expand Down
66 changes: 65 additions & 1 deletion docs/api_docs/diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,38 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):
self._unified_diff = ""
self._side_by_side_diff = ""

def __repr__(self) -> str:
"""
Magic repr method for ScrapliCfgResponse class

Args:
N/A

Returns:
str: repr for class object

Raises:
N/A

"""
return f"ScrapliCfgDiffResponse <Success: {str(not self.failed)}>"

def __str__(self) -> str:
"""
Magic str method for ScrapliCfgDiffResponse class

Args:
N/A

Returns:
str: str for class object

Raises:
N/A

"""
return f"ScrapliCfgDiffResponse <Success: {str(not self.failed)}>"

def record_diff_response(
self, source_config: str, candidate_config: str, device_diff: str
) -> None:
Expand Down Expand Up @@ -290,6 +322,38 @@ class ScrapliCfgDiffResponse(ScrapliCfgResponse):
self._unified_diff = ""
self._side_by_side_diff = ""

def __repr__(self) -> str:
"""
Magic repr method for ScrapliCfgResponse class

Args:
N/A

Returns:
str: repr for class object

Raises:
N/A

"""
return f"ScrapliCfgDiffResponse <Success: {str(not self.failed)}>"

def __str__(self) -> str:
"""
Magic str method for ScrapliCfgDiffResponse class

Args:
N/A

Returns:
str: str for class object

Raises:
N/A

"""
return f"ScrapliCfgDiffResponse <Success: {str(not self.failed)}>"

def record_diff_response(
self, source_config: str, candidate_config: str, device_diff: str
) -> None:
Expand Down Expand Up @@ -476,7 +540,7 @@ Raises:


##### record_diff_response
`record_diff_response(self, source_config: str, candidate_config: str, device_diff: str) ‑> NoneType`
`record_diff_response(self, source_config: str, candidate_config: str, device_diff: str) ‑> None`

```text
Scrapli config diff object
Expand Down
2 changes: 1 addition & 1 deletion docs/api_docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ logger.addHandler(NullHandler())


#### enable_basic_logging
`enable_basic_logging(file: Union[str, bool] = False, level: str = 'info', caller_info: bool = False, buffer_log: bool = True) ‑> NoneType`
`enable_basic_logging(file: Union[str, bool] = False, level: str = 'info', caller_info: bool = False, buffer_log: bool = True) ‑> None`

```text
Enable opinionated logging for scrapli_cfg
Expand Down
4 changes: 2 additions & 2 deletions docs/api_docs/platform/base/async_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ Raises:


##### cleanup
`cleanup(self) ‑> NoneType`
`cleanup(self) ‑> None`

```text
Cleanup after scrapli-cfg operations
Expand Down Expand Up @@ -935,7 +935,7 @@ Raises:


##### prepare
`prepare(self) ‑> NoneType`
`prepare(self) ‑> None`

```text
Prepare connection for scrapli_cfg operations
Expand Down
49 changes: 47 additions & 2 deletions docs/api_docs/platform/base/base_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ class ScrapliCfgBase:
conn: Union[NetworkDriver, AsyncNetworkDriver]

def __init__(self, config_sources: List[str], ignore_version: bool = False) -> None:
"""
Base class for all CFG platforms

Args:
config_sources: list of allowed config sources
ignore_version: ignore platform version check or not

Returns:
None

Raises:
N/A

"""
self.logger = get_instance_logger(
instance_name="scrapli_cfg.platform", host=self.conn.host, port=self.conn.port
)
Expand Down Expand Up @@ -591,7 +605,9 @@ class ScrapliCfgBase:
"""
diff_response.record_response(scrapli_responses=scrapli_responses)
diff_response.record_diff_response(
source_config=source_config, candidate_config=candidate_config, device_diff=device_diff
source_config=source_config + "\n",
candidate_config=candidate_config + "\n",
device_diff=device_diff,
)

if diff_response.failed:
Expand All @@ -611,6 +627,19 @@ class ScrapliCfgBase:
### ScrapliCfgBase


```text
Base class for all CFG platforms
Args:
config_sources: list of allowed config sources
ignore_version: ignore platform version check or not
Returns:
None
Raises:
N/A
```

<details class="source">
<summary>
Expand All @@ -622,6 +651,20 @@ class ScrapliCfgBase:
conn: Union[NetworkDriver, AsyncNetworkDriver]

def __init__(self, config_sources: List[str], ignore_version: bool = False) -> None:
"""
Base class for all CFG platforms

Args:
config_sources: list of allowed config sources
ignore_version: ignore platform version check or not

Returns:
None

Raises:
N/A

"""
self.logger = get_instance_logger(
instance_name="scrapli_cfg.platform", host=self.conn.host, port=self.conn.port
)
Expand Down Expand Up @@ -1159,7 +1202,9 @@ class ScrapliCfgBase:
"""
diff_response.record_response(scrapli_responses=scrapli_responses)
diff_response.record_diff_response(
source_config=source_config, candidate_config=candidate_config, device_diff=device_diff
source_config=source_config + "\n",
candidate_config=candidate_config + "\n",
device_diff=device_diff,
)

if diff_response.failed:
Expand Down
4 changes: 2 additions & 2 deletions docs/api_docs/platform/base/sync_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ Raises:


##### cleanup
`cleanup(self) ‑> NoneType`
`cleanup(self) ‑> None`

```text
Cleanup after scrapli-cfg operations
Expand Down Expand Up @@ -934,7 +934,7 @@ Raises:


##### prepare
`prepare(self) ‑> NoneType`
`prepare(self) ‑> None`

```text
Prepare connection for scrapli_cfg operations
Expand Down
16 changes: 4 additions & 12 deletions docs/api_docs/platform/core/arista_eos/async_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,11 @@ class AsyncScrapliCfgEOS(AsyncScrapliCfgPlatform, ScrapliCfgEOSBase):
except DiffConfigError:
pass

source_config, candidate_config = self._normalize_source_candidate_configs(
source_config=source_config
)

return self._post_diff_config(
diff_response=diff_response,
scrapli_responses=scrapli_responses,
source_config=source_config,
candidate_config=candidate_config,
source_config=self.clean_config(source_config),
candidate_config=self.clean_config(self.candidate_config),
device_diff=device_diff,
)
</code>
Expand Down Expand Up @@ -634,15 +630,11 @@ class AsyncScrapliCfgEOS(AsyncScrapliCfgPlatform, ScrapliCfgEOSBase):
except DiffConfigError:
pass

source_config, candidate_config = self._normalize_source_candidate_configs(
source_config=source_config
)

return self._post_diff_config(
diff_response=diff_response,
scrapli_responses=scrapli_responses,
source_config=source_config,
candidate_config=candidate_config,
source_config=self.clean_config(source_config),
candidate_config=self.clean_config(self.candidate_config),
device_diff=device_diff,
)
</code>
Expand Down
Loading

0 comments on commit 1135d17

Please sign in to comment.