proxies: add smart proxy support

still to do:

* document new configuration options
* add smart proxies to groups view
* import bandwidth and CPU alarms
This commit is contained in:
Iain Learmonth 2022-05-24 19:51:38 +01:00
parent 9b90101cf4
commit 66af6e6550
15 changed files with 275 additions and 32 deletions

View file

@ -1,6 +1,8 @@
from abc import ABCMeta, abstractmethod
import os
from typing import Tuple, Optional
from typing import Tuple, Optional, Any
import jinja2
from app import app
@ -34,3 +36,16 @@ class BaseAutomation(metaclass=ABCMeta):
self.short_name or self.__class__.__name__.lower(),
filename or ""
)
def tmpl_write(self, filename: str, template: str, **kwargs: Any) -> None:
"""
Write a Jinja2 template to the working directory for use by an automation module.
:param filename: filename to write to
:param template: Jinja2 template
:param kwargs: variables for use with the template
:return: None
"""
tmpl = jinja2.Template(template)
with open(self.working_directory(filename), 'w') as tf:
tf.write(tmpl.render(**kwargs))