Skip to content

Commit 923b95d

Browse files
author
vprusakovs
committed
1.1.1 (2023-03-16)
------------------ * [new] ./examples/ssh_vdom.py * [change] README.rst ssh
1 parent 5acdeea commit 923b95d

File tree

8 files changed

+69
-5
lines changed

8 files changed

+69
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
CHANGELOG
55
=========
66

7+
1.1.1 (2023-03-16)
8+
------------------
9+
* [new] ./examples/ssh_vdom.py
10+
* [change] README.rst ssh
11+
12+
713
1.1.0 (2023-03-05)
814
------------------
915
* [new] ciscoconfparse

README.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ or install the package from github.com release
4848

4949
.. code:: bash
5050
51-
pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.0.tar.gz
51+
pip install https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.1.tar.gz
5252
5353
or install the package from github.com repository
5454

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

938940
=============== ======= ============================================================================
939941
Parameter Type Description
@@ -996,6 +998,12 @@ SSH examples:
996998

997999
`./examples/ssh.py`_
9981000

1001+
SSH examples for working with vdom:
1002+
1003+
- get system arp from interfaces associated with vdom="VDOM"
1004+
- get system arp from interfaces associated with vdom="root"
1005+
1006+
`./examples/ssh_vdom.py`_
9991007

10001008
----------------------------------------------------------------------------------------------------
10011009

@@ -1049,3 +1057,4 @@ CiscoConfParse examples:
10491057
.. _`./examples/policy_extended_filter.py`: ./examples/policy_extended_filter.py
10501058
.. _`./examples/snmp_community.py`: ./examples/snmp_community.py
10511059
.. _`./examples/ssh.py`: ./examples/ssh.py
1060+
.. _`./examples/ssh_vdom.py`: ./examples/ssh_vdom.py

examples/ssh_vdom.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"""SSH examples for working with vdom:
2+
- get system arp from interfaces associated with vdom="VDOM"
3+
- get system arp from interfaces associated with vdom="root"
4+
"""
5+
6+
from fortigate_api import FortigateAPI
7+
8+
HOST = "hostname"
9+
USERNAME = "username"
10+
PASSWORD = "password"
11+
VDOM = "VDOM"
12+
13+
# Fortigate with configured VDOMs. diagnostic commands for custom vdom
14+
fgt_vdom = FortigateAPI(host=HOST, username=USERNAME, password=PASSWORD)
15+
vdom_commands = ["config vdom", f"edit {VDOM}"]
16+
output = fgt_vdom.ssh.send_config_set(vdom_commands)
17+
print(output)
18+
# config vdom
19+
#
20+
# hostname (vdom) # edit VDOM
21+
# current vf=VDOM:1
22+
#
23+
# hostname (VDOM) #
24+
25+
output = fgt_vdom.ssh.send_command("get system arp")
26+
print(output)
27+
# hostname (VDOM) #
28+
# Address Age(min) Hardware Addr Interface
29+
# 10.0.1.1 0 00:00:00:00:00:71 v1000
30+
# 10.0.4.1 0 00:00:00:00:00:71 v4000
31+
32+
# Fortigate with configured VDOMs. diagnostic commands for vdom=root
33+
fgt_root = FortigateAPI(host=HOST, username=USERNAME, password=PASSWORD)
34+
vdom_commands = ["config vdom", "edit root"]
35+
output = fgt_root.ssh.send_config_set(vdom_commands)
36+
print(output)
37+
# config vdom
38+
#
39+
# hostname (vdom) # edit root
40+
# current vf=root:0
41+
#
42+
# hostname (root) #
43+
44+
output = fgt_root.ssh.send_command("get system arp")
45+
print(output)
46+
# hostname (root) #
47+
# Address Age(min) Hardware Addr Interface
48+
# 10.0.5.1 7 00:00:00:00:00:71 v5000

fortigate_api/fortigate_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def __init__(self, **kwargs):
5050
False - disable (default)
5151
:type verify: bool
5252
53-
:param vdom: Name of virtual domain (default "root")
53+
:param vdom: Name of virtual domain (default "root").
54+
Used in REST API (Not used in SSH)
5455
:type vdom: str
5556
5657
:param ssh: Netmiko ConnectHandler parameters

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "fortigate_api"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
authors = [
55
{ name="Vladimir Prusakov", email="vladimir.prusakovs@gmail.com" },
66
]
@@ -31,7 +31,7 @@ classifiers = [
3131
"Homepage" = "https://github.com/vladimirs-git/fortigate-api"
3232
"Repository" = "https://github.com/vladimirs-git/fortigate-api"
3333
"Bug Tracker" = "https://github.com/vladimirs-git/fortigate-api/issues"
34-
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.0.tar.gz"
34+
"Download URL" = "https://github.com/vladimirs-git/fortigate-api/archive/refs/tags/1.1.1.tar.gz"
3535
[tool.setuptools.packages.find]
3636
include = ["fortigate_api"]
3737
[tool.setuptools.package-data]

tests/ccp_/__init__.py

Whitespace-only changes.
File renamed without changes.

tests/ccp_/test__ccp.py renamed to tests/test__ccp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import unittest
44

55
from fortigate_api import ccp
6-
from tests.ccp_.helpers__ccp import (
6+
from tests.helpers__ccp import (
77
BLOCK_A1,
88
BLOCK_A2,
99
BLOCK_E2,

0 commit comments

Comments
 (0)