home.switch-rack: use password for authentication

This commit is contained in:
Franzi 2023-03-28 22:52:10 +02:00 committed by Franzi
parent fe7d57aca0
commit 7eb2bf68d8
3 changed files with 13 additions and 4 deletions

View file

@ -15,3 +15,6 @@ for node in Path(join(repo_path, "nodes")).rglob("*.py"):
for name, data in nodes.items(): for name, data in nodes.items():
data.setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net') data.setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net')
data.setdefault('metadata', {}).setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net') data.setdefault('metadata', {}).setdefault('hostname', '.'.join(reversed(name.split('.'))) + '.kunbox.net')
if 'password' in data:
data['password'] = vault.decrypt(data['password'])

View file

@ -1,5 +1,6 @@
bundles = ["routeros"] bundles = ["routeros"]
hostname = "172.19.138.4" hostname = "172.19.138.4"
locking_node = "home.router"
os = "routeros" os = "routeros"
password = "encrypt$gAAAAABkI1Eqsust7XuYFK2-FaRzXWM5fOXumhdi5fWNokLtM0CBAqVqc5zcg37XH_JIZvkhp3buKvswcvd_znaV3Rb8kKeJTs4_VJo6OsvbiWkujfT50HspoUXER0JSZSmeZts8a_2i"
username = "admin" username = "admin"
# TODO password

View file

@ -2,6 +2,7 @@
from os import environ from os import environ
from sys import argv from sys import argv
from bundlewrap.metagen import NodeMetadataProxy
from bundlewrap.exceptions import FaultUnavailable from bundlewrap.exceptions import FaultUnavailable
from bundlewrap.repo import Repository from bundlewrap.repo import Repository
from bundlewrap.utils import Fault from bundlewrap.utils import Fault
@ -19,13 +20,17 @@ def print_faults(dictionary, keypath=[]):
else: else:
if '\n' not in resolved_fault: if '\n' not in resolved_fault:
print('{}/{}: {}'.format('/'.join(keypath), key, value)) print('{}/{}: {}'.format('/'.join(keypath), key, value))
elif isinstance(value, dict): elif isinstance(value, (list, set, tuple)):
print_faults(dict(enumerate(value)), keypath=keypath+[key])
elif isinstance(value, (dict, NodeMetadataProxy)):
print_faults(value, keypath=keypath+[key]) print_faults(value, keypath=keypath+[key])
if len(argv) == 1: if len(argv) == 1:
print('node name missing') print('node name missing')
exit(1) exit(1)
node = repo.get_node(argv[1]) node = repo.get_node(argv[1])
print_faults(node.metadata) print_faults({
'password': node.password,
'metadata': node.metadata,
})