Commit 15ef27da authored by Adrian Schollmeyer's avatar Adrian Schollmeyer
Browse files

export-netbox-to-dokuwiki: Add support for a password retrieval command

Signed-off-by: Adrian Schollmeyer's avatarAdrian 'nex' Schollmeyer <>
parent bed978bb
......@@ -5,6 +5,8 @@ import re
import argparse
import progressbar
import dokuwiki
import subprocess
import configparser
from fem_netbox import cli_common
......@@ -51,7 +53,11 @@ def create_argument_parser():
def get_dokuwiki_config(config):
dw_url = config.get("dokuwiki", "url")
dw_username = config.get("ldap", "username")
dw_password = config.get("ldap", "password")
dw_password = config.get("ldap", "password")
except configparser.NoOptionError:
dw_password = get_dokuwiki_password_from_pass_command(
config.get("ldap", "password_command"))
if not dw_url:
raise Exception("Missing DokuWiki URL!")
......@@ -63,6 +69,16 @@ def get_dokuwiki_config(config):
return {"url": dw_url, "username": dw_username, "password": dw_password}
def get_dokuwiki_password_from_pass_command(command):
res =
["/bin/sh", "-c", command],
password = res.stdout
return password
class NetboxDokuwikiExporter:
def __init__(self, netbox, file_output, dokuwiki_config, enable_progress):
self.netbox = netbox
......@@ -15,3 +15,5 @@ url =
username = foo
; Either use a password:
password = bar
; Or use a password command line:
password_command = pass fem-ldap | head -n1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment