new features
This commit is contained in:
@@ -191,6 +191,8 @@ class BackupService:
|
||||
router = self._router_for_user(db, user, router_id)
|
||||
if router.device_type != 'routeros':
|
||||
raise HTTPException(status_code=400, detail='Text export is available only for RouterOS devices')
|
||||
if router.disable_all_backups or router.disable_export_backups:
|
||||
raise HTTPException(status_code=400, detail='Exports are disabled for this device')
|
||||
settings = settings_service.get_or_create(db)
|
||||
stamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
name = f'{router.name}_{router.id}_{stamp}.rsc'
|
||||
@@ -214,6 +216,8 @@ class BackupService:
|
||||
|
||||
def binary_backup(self, db: Session, user: User, router_id: int) -> Backup:
|
||||
router = self._router_for_user(db, user, router_id)
|
||||
if router.disable_all_backups or router.disable_binary_backups:
|
||||
raise HTTPException(status_code=400, detail='Binary backups are disabled for this device')
|
||||
settings = settings_service.get_or_create(db)
|
||||
stamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
base_name = f'{router.name}_{router.id}_{stamp}'
|
||||
@@ -306,6 +310,13 @@ class BackupService:
|
||||
routers = db.query(Router).filter(Router.owner_id == user.id).all()
|
||||
result = []
|
||||
for router in routers:
|
||||
if router.disable_all_backups or router.disable_export_backups:
|
||||
result.append({
|
||||
'router': router.name,
|
||||
'status': 'skipped',
|
||||
'message': 'Exports are disabled for this device',
|
||||
})
|
||||
continue
|
||||
if (router.device_type or 'routeros').lower() != 'routeros':
|
||||
result.append({
|
||||
'router': router.name,
|
||||
@@ -324,6 +335,13 @@ class BackupService:
|
||||
routers = db.query(Router).filter(Router.owner_id == user.id).all()
|
||||
result = []
|
||||
for router in routers:
|
||||
if router.disable_all_backups or router.disable_binary_backups:
|
||||
result.append({
|
||||
'router': router.name,
|
||||
'status': 'skipped',
|
||||
'message': 'Binary backups are disabled for this device',
|
||||
})
|
||||
continue
|
||||
try:
|
||||
backup = self.binary_backup(db, user, router.id)
|
||||
result.append({'router': router.name, 'status': 'ok', 'backup_id': backup.id})
|
||||
|
||||
Reference in New Issue
Block a user