mirror of
https://github.com/eduardogsilva/routerfleet.git
synced 2025-06-21 01:25:41 +02:00
Add support for "Mikrotik (Branded)" routers
This commit is contained in:
parent
9c8692451a
commit
d4988a9c72
4 changed files with 20 additions and 10 deletions
|
@ -5,6 +5,7 @@ import uuid
|
|||
SUPPORTED_ROUTER_TYPES = (
|
||||
('monitoring', 'Monitoring Only'),
|
||||
('routeros', 'Mikrotik (RouterOS)'),
|
||||
('routeros-branded', 'Mikrotik (Branded)'),
|
||||
('openwrt', 'OpenWRT')
|
||||
)
|
||||
|
||||
|
|
|
@ -142,6 +142,6 @@ STATICFILES_DIRS = [
|
|||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
MEDIA_ROOT = '/var/lib/routerfleet/'
|
||||
ROUTERFLEET_VERSION = 7022
|
||||
ROUTERFLEET_VERSION = 7023
|
||||
|
||||
from routerfleet.production_settings import *
|
||||
|
|
|
@ -82,7 +82,7 @@ def execute_backup(router_backup: RouterBackup):
|
|||
ssh_client = None
|
||||
additional_parameters = ""
|
||||
try:
|
||||
if router_backup.router.router_type == 'routeros':
|
||||
if router_backup.router.router_type == 'routeros' or router_backup.router.router_type == 'routeros-branded':
|
||||
if router.backup_profile:
|
||||
if router.backup_profile.parameter_sensitive:
|
||||
additional_parameters += ' show-sensitive'
|
||||
|
@ -125,7 +125,7 @@ def retrieve_backup(router_backup: RouterBackup):
|
|||
ssh_client = None
|
||||
|
||||
try:
|
||||
if router_backup.router.router_type == 'routeros':
|
||||
if router_backup.router.router_type == 'routeros' or router_backup.router.router_type == 'routeros-branded':
|
||||
rsc_file_path = f'/tmp/{backup_name}.{file_extension["text"]}'
|
||||
backup_file_path = f'/tmp/{backup_name}.{file_extension["binary"]}'
|
||||
ssh_client = connect_to_ssh(router.address, router.port, router.username, router.password, router.ssh_key)
|
||||
|
@ -180,7 +180,7 @@ def clean_up_backup_files(router_backup: RouterBackup):
|
|||
router = router_backup.router
|
||||
ssh_client = None
|
||||
try:
|
||||
if router_backup.router.router_type == 'routeros':
|
||||
if router_backup.router.router_type == 'routeros' or router_backup.router.router_type == 'routeros-branded':
|
||||
ssh_client = connect_to_ssh(router.address, router.port, router.username, router.password, router.ssh_key)
|
||||
ssh_client.exec_command('file remove [find where name~"routerfleet-backup-"]')
|
||||
elif router_backup.router.router_type == 'openwrt':
|
||||
|
|
|
@ -5,14 +5,14 @@ import telnetlib
|
|||
|
||||
|
||||
def get_router_features(router_type):
|
||||
if router_type in ['openwrt', 'routeros']:
|
||||
if router_type in ['openwrt', 'routeros', 'routeros-branded']:
|
||||
return ['backup', 'reverse_monitoring', 'ssh', 'ssh_key']
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def get_router_backup_file_extension(router_type):
|
||||
if router_type == 'routeros':
|
||||
if router_type == 'routeros' or router_type == 'routeros-branded':
|
||||
return {'text': 'rsc', 'binary': 'backup'}
|
||||
elif router_type == 'openwrt':
|
||||
return {'text': 'txt', 'binary': 'tar.gz'}
|
||||
|
@ -69,13 +69,22 @@ def test_authentication(router_type, address, port, username, password, sshkey=N
|
|||
def test_ssh_authentication(router_type, address, port, username, password, sshkey=None):
|
||||
try:
|
||||
ssh_client = connect_to_ssh(address, port, username, password, sshkey)
|
||||
if router_type == 'routeros':
|
||||
if router_type == 'routeros' or router_type == 'routeros-branded':
|
||||
stdin, stdout, stderr = ssh_client.exec_command('/system resource print')
|
||||
output = stdout.read().decode()
|
||||
if 'platform: MikroTik' in output:
|
||||
result = True, 'Success: MikroTik device confirmed'
|
||||
if router_type == 'routeros':
|
||||
if 'platform: MikroTik' in output:
|
||||
result = True, 'Success: MikroTik device confirmed'
|
||||
else:
|
||||
result = False, 'Device is not MikroTik'
|
||||
else:
|
||||
result = False, 'Device is not MikroTik'
|
||||
if 'platform: MikroTik' in output:
|
||||
result = False, 'Device is not branded. Please select Mikrotik (RouterOS)'
|
||||
elif 'platform: ' in output:
|
||||
result = True, 'Success: MikroTik branded device confirmed'
|
||||
else:
|
||||
result = False, 'Device is not MikroTik'
|
||||
|
||||
elif router_type == 'openwrt':
|
||||
stdin, stdout, stderr = ssh_client.exec_command('ubus call system board')
|
||||
output = stdout.read().decode()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue