I am working with VMWare Aria Automation Config API to automate tasks using Python. I am unable to use .format with any of the methods and I do not understand why. Here is an example
This does not work:
from sseapiclient import APIClient
client = APIClient('http://myaac.com', username, password)
mycommand = 'cmd="local",fun="test.ping",tgt={"saltmaster":{"tgt":"minion*","tgt_type":"glob"}}'
client.api.cmd.route_cmd('{}'.format(mycommand))
I get an error message:
"3004: Request validation failure.
job_uuid:
- Not a valid UUID.
cmd:
- Expected 'cmd'"
which if I understand correctly means that the value passed via .format is not considered.
However, passing parameters directly works fine:
from sseapiclient import APIClient
client = APIClient('http://myaac.com', username, password)
client.api.cmd.route_cmd(cmd="local",fun="test.ping",tgt={"saltmaster":{"tgt":"minion*","tgt_type":"glob"}})
Any ideas?
str.formatis used for formatting strings.'{}'.format(a)is just the same asstr(a).route_cmdis expecting several arguments, in particular one namedcmd. Passing it a single string will not work.If you want to store named arguments in a single variable, you should use a
dict: