Skip to content

Commit

Permalink
v0.1.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
cykyy committed Aug 11, 2020
1 parent 1f37feb commit 130a2cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ Change Log
0.1.1 (10/08/2020)
-------------------
- Minor changes. Not really important!

0.1.2 (11/08/2020)
-------------------
- Bug fixed!
- Added 'login()' function to connect with routerOS by calling the function instead of during instantiating the RosCall class.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ That's where this api comes in. There's not many functions are simplified so far
import pyros_api

connection = pyros_api.RosCall('Mikrotik IP', username='admin', password='')
connection.login()
connection.get_ppp_secret()
```

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

```python
connection = pyros_api.RosCall('<IP>', username='admin', password='', use_ssl=True)
connection.login()
```

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

```python
pyros_api.RosCall(host, username='admin', password='', plaintext_login=True)
connection.login()
```

### Execute Commands
Expand Down
20 changes: 19 additions & 1 deletion pyros_api/routeros.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def __init__(self, ros_ip, username='admin', password='', port=8728,
self._ssl_verify_hostname = ssl_verify_hostname
self._ssl_context = ssl_context

try:
self.connection = None
self.api = None
# deprecated and soon will get removed
'''try:
# connecting with ros
self.connection = routeros_api.RouterOsApiPool(host=self._mikrotik_ip, username=self._username,
password=self._password, port=self._port,
Expand All @@ -32,6 +35,21 @@ def __init__(self, ros_ip, username='admin', password='', port=8728,
self.connection.set_timeout(5)
self.api = self.connection.get_api()
# print(connection.connected)
except Exception as rce:
print(':Error: connecting with routerOS! {}'.format(rce))'''

def login(self):
try:
# connecting with ros
self.connection = routeros_api.RouterOsApiPool(host=self._mikrotik_ip, username=self._username,
password=self._password, port=self._port,
plaintext_login=self._plaintext_login, use_ssl=self._use_ssl,
ssl_verify=self._ssl_verify,
ssl_verify_hostname=self._ssl_verify_hostname,
ssl_context=self._ssl_context)

self.connection.set_timeout(5)
self.api = self.connection.get_api()
except Exception as rce:
print(':Error: connecting with routerOS! {}'.format(rce))

Expand Down

0 comments on commit 130a2cb

Please sign in to comment.