Skip to content

Commit

Permalink
1.1.1 (2023-03-16)
Browse files Browse the repository at this point in the history
------------------
* [new] ./examples/ssh_vdom.py
* [change] README.rst ssh
  • Loading branch information
vprusakovs committed Mar 16, 2023
1 parent 5acdeea commit 923b95d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
CHANGELOG
=========

1.1.1 (2023-03-16)
------------------
* [new] ./examples/ssh_vdom.py
* [change] README.rst ssh


1.1.0 (2023-03-05)
------------------
* [new] ciscoconfparse
Expand Down
11 changes: 10 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ or install the package from github.com release

.. code:: bash
pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.0.tar.gz
pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.1.tar.gz
or install the package from github.com repository

Expand Down Expand Up @@ -934,6 +934,8 @@ SSH
---
**SSH(host, username, password, ssh)**
SSH connector to the Fortigate. Contains methods to get and put configuration commands using ssh.
Note, FortigateAPI parameter "vdom" used in REST API only and not used in SSH.
In order to send cli commands to a specific vdom, you need "config vdom" before.

=============== ======= ============================================================================
Parameter Type Description
Expand Down Expand Up @@ -996,6 +998,12 @@ SSH examples:

`./examples/ssh.py`_

SSH examples for working with vdom:

- get system arp from interfaces associated with vdom="VDOM"
- get system arp from interfaces associated with vdom="root"

`./examples/ssh_vdom.py`_

----------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -1049,3 +1057,4 @@ CiscoConfParse examples:
.. _`./examples/policy_extended_filter.py`: ./examples/policy_extended_filter.py
.. _`./examples/snmp_community.py`: ./examples/snmp_community.py
.. _`./examples/ssh.py`: ./examples/ssh.py
.. _`./examples/ssh_vdom.py`: ./examples/ssh_vdom.py
48 changes: 48 additions & 0 deletions examples/ssh_vdom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""SSH examples for working with vdom:
- get system arp from interfaces associated with vdom="VDOM"
- get system arp from interfaces associated with vdom="root"
"""

from fortigate_api import FortigateAPI

HOST = "hostname"
USERNAME = "username"
PASSWORD = "password"
VDOM = "VDOM"

# Fortigate with configured VDOMs. diagnostic commands for custom vdom
fgt_vdom = FortigateAPI(host=HOST, username=USERNAME, password=PASSWORD)
vdom_commands = ["config vdom", f"edit {VDOM}"]
output = fgt_vdom.ssh.send_config_set(vdom_commands)
print(output)
# config vdom
#
# hostname (vdom) # edit VDOM
# current vf=VDOM:1
#
# hostname (VDOM) #

output = fgt_vdom.ssh.send_command("get system arp")
print(output)
# hostname (VDOM) #
# Address Age(min) Hardware Addr Interface
# 10.0.1.1 0 00:00:00:00:00:71 v1000
# 10.0.4.1 0 00:00:00:00:00:71 v4000

# Fortigate with configured VDOMs. diagnostic commands for vdom=root
fgt_root = FortigateAPI(host=HOST, username=USERNAME, password=PASSWORD)
vdom_commands = ["config vdom", "edit root"]
output = fgt_root.ssh.send_config_set(vdom_commands)
print(output)
# config vdom
#
# hostname (vdom) # edit root
# current vf=root:0
#
# hostname (root) #

output = fgt_root.ssh.send_command("get system arp")
print(output)
# hostname (root) #
# Address Age(min) Hardware Addr Interface
# 10.0.5.1 7 00:00:00:00:00:71 v5000
3 changes: 2 additions & 1 deletion fortigate_api/fortigate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(self, **kwargs):
False - disable (default)
:type verify: bool
:param vdom: Name of virtual domain (default "root")
:param vdom: Name of virtual domain (default "root").
Used in REST API (Not used in SSH)
:type vdom: str
:param ssh: Netmiko ConnectHandler parameters
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "fortigate_api"
version = "1.1.0"
version = "1.1.1"
authors = [
{ name="Vladimir Prusakov", email="[email protected]" },
]
Expand Down Expand Up @@ -31,7 +31,7 @@ classifiers = [
"Homepage" = "https://github.com/vladimirs-git/fortigate-api"
"Repository" = "https://github.com/vladimirs-git/fortigate-api"
"Bug Tracker" = "https://github.com/vladimirs-git/fortigate-api/issues"
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.0.tar.gz"
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.1.tar.gz"
[tool.setuptools.packages.find]
include = ["fortigate_api"]
[tool.setuptools.package-data]
Expand Down
Empty file removed tests/ccp_/__init__.py
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/ccp_/test__ccp.py → tests/test__ccp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest

from fortigate_api import ccp
from tests.ccp_.helpers__ccp import (
from tests.helpers__ccp import (
BLOCK_A1,
BLOCK_A2,
BLOCK_E2,
Expand Down

0 comments on commit 923b95d

Please sign in to comment.