go-panos
go-panos copied to clipboard
Command(command string) (string, error) returns an Empty string
The function below returns a empty string response when called,
I have tested with the command
res, err := pan.Command("
If you inspect the resp object you can see that the XML response is there, the Unmarshal into the commandOutput struct seems to be the problem
// Command lets you run any operational mode command against the given device, and it returns the output. You
// must use the XML-formatted version of the command string as if you were calling the API yourself,
// (e.g. "<show><running><ippool></ippool></running></show>")
func (p *PaloAlto) Command(command string) (string, error) {
var output commandOutput
resty.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
resp, err := resty.R().Get(fmt.Sprintf("%s&key=%s&type=op&cmd=%s", p.URI, p.Key, command))
if err != nil {
return "", fmt.Errorf("unable to run command '%s' - %s", command, err)
}
err = xml.Unmarshal([]byte(resp.String()), &output)
if err != nil {
return "", err
}
return output.Data, nil
}
Thanks for catching this @gavmckee80. I'll take a look and try to get it fixed ASAP.