RouterOS
RouterOS
¶
Bases: Ip, System
Class that generates the connection with a MikroTik router.
Examples:
>>> from netmikro import RouterOS
>>> router = RouterOS(
... '192.168.3.3',
... 'user',
... 'password',
... 22,
... )
>>> router.cmd('/system identity print')
'name: Netmikro'
Source code in netmikro/routeros.py
__init__(host, username, password, ssh_port=22, delay=0)
¶
Class that generates the connection with a MikroTik router.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
IP address of the router you want to connect to. |
required |
username
|
str
|
Username to be used in the connection. |
required |
password
|
str
|
Password to be used in the connection. |
required |
ssh_port
|
int
|
SSH port to be used in the connection. |
22
|
delay
|
float
|
Time delay between command executions on the router. |
0
|
Source code in netmikro/routeros.py
cmd(command)
¶
Runs a command in the router's terminal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Command to be executed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Output of the command |
Examples:
Source code in netmikro/routeros.py
cmd_multiline(*args)
¶
Runs multiple commands in the router's terminal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
List of commands to be executed. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Output of the commands. |
Examples:
>>> router.cmd_multiline([
... '/system identity print',
... '/system note print'
... ])
['name: Netmikro', 'note: Test']