Workaround xapi bug in Task.GetResult

xapi currently sends us an xmlrpc-encoded string via xmlrpc.
This seems to be a bug. Remove this workaround when it's fixed
This commit is contained in:
Cheng Sun 2015-01-02 12:55:34 +00:00
parent 0cb3aff4e8
commit fc03c2010f

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"github.com/nilshell/xmlrpc" "github.com/nilshell/xmlrpc"
"log" "log"
"regexp"
) )
type XenAPIClient struct { type XenAPIClient struct {
@ -880,9 +881,17 @@ func (self *Task) GetResult() (object *XenAPIObject, err error) {
} }
switch ref := result.Value.(type) { switch ref := result.Value.(type) {
case string: case string:
object = &XenAPIObject{ // @fixme: xapi currently sends us an xmlrpc-encoded string via xmlrpc.
Ref: ref.(string), // This seems to be a bug in xapi. Remove this workaround when it's fixed
Client: self.Client, re := regexp.MustCompile("^<value><array><data><value>([^<]*)</value>.*</data></array></value>$")
match := re.FindStringSubmatch(ref)
if match == nil {
object = nil
} else {
object = &XenAPIObject{
Ref: match[1],
Client: self.Client,
}
} }
case nil: case nil:
object = nil object = nil