Skip to content

Commit 130a2cb

Browse files
committed
v0.1.2 release
1 parent 1f37feb commit 130a2cb

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ Change Log
88
0.1.1 (10/08/2020)
99
-------------------
1010
- Minor changes. Not really important!
11+
12+
0.1.2 (11/08/2020)
13+
-------------------
14+
- Bug fixed!
15+
- Added 'login()' function to connect with routerOS by calling the function instead of during instantiating the RosCall class.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ That's where this api comes in. There's not many functions are simplified so far
2222
import pyros_api
2323

2424
connection = pyros_api.RosCall('Mikrotik IP', username='admin', password='')
25+
connection.login()
2526
connection.get_ppp_secret()
2627
```
2728

@@ -61,6 +62,7 @@ If we want to use SSL, we can simply specify `use_ssl` as `True`:
6162

6263
```python
6364
connection = pyros_api.RosCall('<IP>', username='admin', password='', use_ssl=True)
65+
connection.login()
6466
```
6567

6668
This will automatically verify SSL certificate and hostname.
@@ -90,6 +92,7 @@ It is highly recommended only to use this option with SSL enabled.
9092

9193
```python
9294
pyros_api.RosCall(host, username='admin', password='', plaintext_login=True)
95+
connection.login()
9396
```
9497

9598
### Execute Commands

pyros_api/routeros.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def __init__(self, ros_ip, username='admin', password='', port=8728,
2020
self._ssl_verify_hostname = ssl_verify_hostname
2121
self._ssl_context = ssl_context
2222

23-
try:
23+
self.connection = None
24+
self.api = None
25+
# deprecated and soon will get removed
26+
'''try:
2427
# connecting with ros
2528
self.connection = routeros_api.RouterOsApiPool(host=self._mikrotik_ip, username=self._username,
2629
password=self._password, port=self._port,
@@ -32,6 +35,21 @@ def __init__(self, ros_ip, username='admin', password='', port=8728,
3235
self.connection.set_timeout(5)
3336
self.api = self.connection.get_api()
3437
# print(connection.connected)
38+
except Exception as rce:
39+
print(':Error: connecting with routerOS! {}'.format(rce))'''
40+
41+
def login(self):
42+
try:
43+
# connecting with ros
44+
self.connection = routeros_api.RouterOsApiPool(host=self._mikrotik_ip, username=self._username,
45+
password=self._password, port=self._port,
46+
plaintext_login=self._plaintext_login, use_ssl=self._use_ssl,
47+
ssl_verify=self._ssl_verify,
48+
ssl_verify_hostname=self._ssl_verify_hostname,
49+
ssl_context=self._ssl_context)
50+
51+
self.connection.set_timeout(5)
52+
self.api = self.connection.get_api()
3553
except Exception as rce:
3654
print(':Error: connecting with routerOS! {}'.format(rce))
3755

0 commit comments

Comments
 (0)