usertools/telemetry: load aliases from config directory
PATCH 1/1 usertools/telemetry: load aliases from config directory
The default path of the telemetry alias file
was at the top level of the home directory.
Load aliases from the DPDK configuration directory instead, using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.
Keep --alias-file for users who want to provide an explicit path.
--- doc/guides/howto/telemetry.rst | 6 ++++-- usertools/dpdk-telemetry.py | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-)
doc/guides/howto/telemetry.rst +4 -2
@@ -154,9 +154,11 @@ and query information using the telemetry client python script. The telemetry script can load aliases at startup from:: - $HOME/.dpdk_telemetry_aliases + $XDG_CONFIG_HOME/dpdk/telemetry_aliases + + If ``XDG_CONFIG_HOME`` is not set, ``$HOME/.config/dpdk/telemetry_aliases`` is used. + A custom path can also be provided via the ``--alias-file`` script flag. - or from a custom path provided via the ``--alias-file`` script flag. Each alias entry must be in ``alias=command`` format. Empty lines and lines starting with ``#`` are ignored.
usertools/dpdk-telemetry.py +17 -6
@@ -22,7 +22,7 @@ DEFAULT_PREFIX = "rte" CMDS = [] ALIASES = {} -ALIAS_FILE = ".dpdk_telemetry_aliases" +ALIAS_FILE = "telemetry_aliases" MAX_ALIAS_EXPANSIONS = 32 BASIC_HELP_TEXT = """Basic usage:
@@ -46,19 +46,30 @@ """ +def get_default_alias_path(): + config_home = os.environ.get("XDG_CONFIG_HOME") + if config_home: + return os.path.join(config_home, "dpdk", ALIAS_FILE) + + home = os.environ.get("HOME") + if not home: + return None + + return os.path.join(home, ".config", "dpdk", ALIAS_FILE) + + def load_aliases(alias_path=None): - """Load aliases from $HOME/.dpdk_telemetry_aliases or a custom path if provided""" + """Load aliases from the config directory or a custom path if provided""" aliases = {} if alias_path and not os.path.isfile(alias_path): print("Warning: alias file {} not found, skipping".format(alias_path), file=sys.stderr) return aliases if not alias_path: - home = os.environ.get("HOME") - if not home: + alias_path = get_default_alias_path() + if not alias_path: return aliases - alias_path = os.path.join(home, ALIAS_FILE) if not os.path.isfile(alias_path): return aliases
@@ -434,7 +445,7 @@ def readline_complete(text, state): ) parser.add_argument( "--alias-file", - help=f"Provide a custom alias file instead of $HOME/{ALIAS_FILE}", + help="Provide a custom alias file instead of the default config path", ) parser.add_argument( "-i", "--instance", default="0", type=int, help="Provide instance number for DPDK application"
Signature · 1 line
2.54.0
Quoted 7 lines · Thomas Monjalon
The default path of the telemetry alias file
was at the top level of the home directory.Load aliases from the DPDK configuration directory instead, using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.
Quoted 5 lines
Keep --alias-file for users who want to provide an explicit path.
Fixes 410d498412e4 ("usertools/telemetry: support aliases for long commands")Signed-off-by Thomas Monjalon <[email protected]>
Tested without moving my existing alias file - no aliases loaded. Then tested after moving to .config/dpdk/ and it worked fine.
Doc changes LGTM too.
Quoted 83 lines
--- doc/guides/howto/telemetry.rst | 6 ++++-- usertools/dpdk-telemetry.py | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-)doc/guides/howto/telemetry.rst +4
-2@@ -154,9 +154,11 @@ and query information using the telemetry client python script. The telemetry script can load aliases at startup from:: - $HOME/.dpdk_telemetry_aliases + $XDG_CONFIG_HOME/dpdk/telemetry_aliases + + If ``XDG_CONFIG_HOME`` is not set, ``$HOME/.config/dpdk/telemetry_aliases`` is used. + A custom path can also be provided via the ``--alias-file`` script flag. - or from a custom path provided via the ``--alias-file`` script flag. Each alias entry must be in ``alias=command`` format. Empty lines and lines starting with ``#`` are ignored.usertools/dpdk-telemetry.py +17
-6@@ -22,7 +22,7 @@ DEFAULT_PREFIX = "rte" CMDS = [] ALIASES = {} -ALIAS_FILE = ".dpdk_telemetry_aliases" +ALIAS_FILE = "telemetry_aliases" MAX_ALIAS_EXPANSIONS = 32 BASIC_HELP_TEXT = """Basic usage:@@ -46,19 +46,30 @@ """ +def get_default_alias_path(): + config_home = os.environ.get("XDG_CONFIG_HOME") + if config_home: + return os.path.join(config_home, "dpdk", ALIAS_FILE) + + home = os.environ.get("HOME") + if not home: + return None + + return os.path.join(home, ".config", "dpdk", ALIAS_FILE) + + def load_aliases(alias_path=None): - """Load aliases from $HOME/.dpdk_telemetry_aliases or a custom path if provided""" + """Load aliases from the config directory or a custom path if provided""" aliases = {} if alias_path and not os.path.isfile(alias_path): print("Warning: alias file {} not found, skipping".format(alias_path), file=sys.stderr) return aliases if not alias_path: - home = os.environ.get("HOME") - if not home: + alias_path = get_default_alias_path() + if not alias_path: return aliases - alias_path = os.path.join(home, ALIAS_FILE) if not os.path.isfile(alias_path): return aliases@@ -434,7 +445,7 @@ def readline_complete(text, state): ) parser.add_argument( "--alias-file", - help=f"Provide a custom alias file instead of $HOME/{ALIAS_FILE}", + help="Provide a custom alias file instead of the default config path", ) parser.add_argument( "-i", "--instance", default="0", type=int, help="Provide instance number for DPDK application"Signature · 1 line
2.54.0
17/07/2026 11:37, Bruce Richardson:
Quoted 14 lines · Thomas Monjalon
Quoted 7 lines
The default path of the telemetry alias file
was at the top level of the home directory.Load aliases from the DPDK configuration directory instead, using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.Quoted 5 lines
Keep --alias-file for users who want to provide an explicit path.
Fixes 410d498412e4 ("usertools/telemetry: support aliases for long commands")Signed-off-by Thomas Monjalon <[email protected]>
Quoted 7 lines
Tested without moving my existing alias file - no aliases loaded. Then tested after moving to .config/dpdk/ and it worked fine.
Doc changes LGTM too.
Tested-by Bruce Richardson <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks for testing.
Thomas Monjalon, Jul 17, 2026 at 11:16:
Quoted 7 lines
The default path of the telemetry alias file
was at the top level of the home directory.Load aliases from the DPDK configuration directory instead, using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.
Quoted 6 lines
Keep --alias-file for users who want to provide an explicit path.
Fixes 410d498412e4 ("usertools/telemetry: support aliases for long commands")Signed-off-by Thomas Monjalon <[email protected]>---
Quoted 12 lines · Thomas Monjalon
The default path of the telemetry alias file
was at the top level of the home directory.Load aliases from the DPDK configuration directory instead, using $XDG_CONFIG_HOME/dpdk/telemetry_aliases
or $HOME/.config/dpdk/telemetry_aliases.Keep --alias-file for users who want to provide an explicit path.
Fixes 410d498412e4 ("usertools/telemetry: support aliases for long commands")Signed-off-by Thomas Monjalon <[email protected]>