forked from vladimirs-git/fortigate-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh_vdom.py
53 lines (44 loc) · 1.46 KB
/
ssh_vdom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""SSH examples for working with vdom.
- Get system arp from interfaces associated with vdom="VDOM"
- Get system arp from interfaces associated with vdom="root"
"""
import logging
from fortigate_api import FortigateAPI
logging.getLogger().setLevel(logging.DEBUG)
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