From fc03c2010f1c62946f3de200fdffe9106492442e Mon Sep 17 00:00:00 2001 From: Cheng Sun Date: Fri, 2 Jan 2015 12:55:34 +0000 Subject: [PATCH] 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 --- builder/xenserver/common/client.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/builder/xenserver/common/client.go b/builder/xenserver/common/client.go index 46b838a..ff7f371 100644 --- a/builder/xenserver/common/client.go +++ b/builder/xenserver/common/client.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/nilshell/xmlrpc" "log" + "regexp" ) type XenAPIClient struct { @@ -880,9 +881,17 @@ func (self *Task) GetResult() (object *XenAPIObject, err error) { } switch ref := result.Value.(type) { case string: - object = &XenAPIObject{ - Ref: ref.(string), - Client: self.Client, + // @fixme: xapi currently sends us an xmlrpc-encoded string via xmlrpc. + // This seems to be a bug in xapi. Remove this workaround when it's fixed + re := regexp.MustCompile("^([^<]*).*$") + match := re.FindStringSubmatch(ref) + if match == nil { + object = nil + } else { + object = &XenAPIObject{ + Ref: match[1], + Client: self.Client, + } } case nil: object = nil