mirror of
https://github.com/KrystianD/mikrotik_configurator.git
synced 2025-06-20 09:37:43 +02:00
added import_certificate helper function
This commit is contained in:
parent
0a6aac6bbd
commit
74725c852a
@ -68,6 +68,22 @@ def rollback_delete_chain(name):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def import_certificate(path):
|
||||||
|
name = os.path.splitext(os.path.basename(path))[0]
|
||||||
|
|
||||||
|
body = ""
|
||||||
|
body += load_file(path, f"{name}.txt")
|
||||||
|
body += f"""
|
||||||
|
/certificate import file-name="{name}.txt" passphrase="" name="{name}"
|
||||||
|
"""
|
||||||
|
cleanup_body = generate_catch_block(f"""
|
||||||
|
/certificate remove "{name}"
|
||||||
|
""")
|
||||||
|
cleanups.insert(0, cleanup_body)
|
||||||
|
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
def render_file(path: str, include_dirs: List[str], variables: Dict[str, str]):
|
def render_file(path: str, include_dirs: List[str], variables: Dict[str, str]):
|
||||||
global cleanups
|
global cleanups
|
||||||
cleanups = []
|
cleanups = []
|
||||||
@ -84,6 +100,7 @@ def render_file(path: str, include_dirs: List[str], variables: Dict[str, str]):
|
|||||||
env.globals['register_cleanup'] = register_cleanup
|
env.globals['register_cleanup'] = register_cleanup
|
||||||
env.globals['escape_string'] = escape_string
|
env.globals['escape_string'] = escape_string
|
||||||
env.globals['rollback_delete_chain'] = rollback_delete_chain
|
env.globals['rollback_delete_chain'] = rollback_delete_chain
|
||||||
|
env.globals['import_certificate'] = import_certificate
|
||||||
env.globals = {**env.globals, **variables}
|
env.globals = {**env.globals, **variables}
|
||||||
|
|
||||||
env.filters["ipnet"] = lambda x: str(IPNetwork(x))
|
env.filters["ipnet"] = lambda x: str(IPNetwork(x))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user