Accept nested namespaces in spacewalk.api

salt-run $server spacewalk.api allows users to run arbitrary Spacewalk
API functions through Salt. These are passed in a namespace.method
notation and may use nested namespaces. Previously only methods in a
top-level namespace were supported.

Fixes https://github.com/saltstack/salt/issues/57442

Co-authored-by: Wayne Werner <wwerner@saltstack.com>
This commit is contained in:
Alexander Graul 2020-05-28 19:22:24 +02:00 committed by Daniel Wozniak
parent e52c9f5ea5
commit a909ab8ad3
2 changed files with 6 additions and 1 deletions

1
changelog/57442.fixed Normal file
View file

@ -0,0 +1 @@
Accept nested namespaces in spacewalk.api runner function.

View file

@ -176,7 +176,11 @@ def api(server, command, *args, **kwargs):
log.error(err_msg)
return {call: err_msg}
namespace, method = command.split(".")
namespace, _, method = command.rpartition(".")
if not namespace:
return {
call: "Error: command must use the following format: 'namespace.method'"
}
endpoint = getattr(getattr(client, namespace), method)
try: