scripts/passwords_for: various improvements
This commit is contained in:
parent
18207d2ae5
commit
333873383b
1 changed files with 16 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from os import environ
|
||||
from os.path import abspath, dirname
|
||||
from sys import argv
|
||||
|
||||
from bundlewrap.exceptions import FaultUnavailable
|
||||
|
@ -7,13 +9,13 @@ from bundlewrap.metagen import NodeMetadataProxy
|
|||
from bundlewrap.repo import Repository
|
||||
from bundlewrap.utils import Fault
|
||||
|
||||
path = environ.get('BW_REPO_PATH', '.')
|
||||
repo = Repository(path)
|
||||
repo = Repository(
|
||||
dirname(dirname(abspath(__file__)))
|
||||
)
|
||||
|
||||
def print_faults(dictionary, keypath=[]):
|
||||
for key, value in sorted(dictionary.items()):
|
||||
key = str(key)
|
||||
|
||||
if isinstance(value, Fault):
|
||||
try:
|
||||
resolved_fault = value.value
|
||||
|
@ -27,12 +29,22 @@ def print_faults(dictionary, keypath=[]):
|
|||
elif isinstance(value, (dict, NodeMetadataProxy)):
|
||||
print_faults(value, keypath=keypath+[key])
|
||||
|
||||
|
||||
if len(argv) == 1:
|
||||
print('node name missing')
|
||||
exit(1)
|
||||
|
||||
node = repo.get_node(argv[1])
|
||||
if node.username or node.password:
|
||||
print_faults({
|
||||
'username': node.username,
|
||||
'password': node.password,
|
||||
})
|
||||
#if node.ipmi_username or node.ipmi_password:
|
||||
# print_faults({
|
||||
# 'ipmi_username': node.ipmi_username,
|
||||
# 'ipmi_password': node.ipmi_password,
|
||||
# })
|
||||
print_faults({
|
||||
'password': node.password,
|
||||
'metadata': node.metadata,
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue