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
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from os.path import abspath, dirname
|
||||||
from sys import argv
|
from sys import argv
|
||||||
|
|
||||||
from bundlewrap.exceptions import FaultUnavailable
|
from bundlewrap.exceptions import FaultUnavailable
|
||||||
|
@ -7,13 +9,13 @@ from bundlewrap.metagen import NodeMetadataProxy
|
||||||
from bundlewrap.repo import Repository
|
from bundlewrap.repo import Repository
|
||||||
from bundlewrap.utils import Fault
|
from bundlewrap.utils import Fault
|
||||||
|
|
||||||
path = environ.get('BW_REPO_PATH', '.')
|
repo = Repository(
|
||||||
repo = Repository(path)
|
dirname(dirname(abspath(__file__)))
|
||||||
|
)
|
||||||
|
|
||||||
def print_faults(dictionary, keypath=[]):
|
def print_faults(dictionary, keypath=[]):
|
||||||
for key, value in sorted(dictionary.items()):
|
for key, value in sorted(dictionary.items()):
|
||||||
key = str(key)
|
key = str(key)
|
||||||
|
|
||||||
if isinstance(value, Fault):
|
if isinstance(value, Fault):
|
||||||
try:
|
try:
|
||||||
resolved_fault = value.value
|
resolved_fault = value.value
|
||||||
|
@ -27,12 +29,22 @@ def print_faults(dictionary, keypath=[]):
|
||||||
elif isinstance(value, (dict, NodeMetadataProxy)):
|
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])
|
||||||
|
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({
|
print_faults({
|
||||||
'password': node.password,
|
|
||||||
'metadata': node.metadata,
|
'metadata': node.metadata,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue