Add support to Bool type in XMLRPC response

This commit is contained in:
Christian González authored and Ruben S. Montero committed 2018-11-16 12:47:22 +01:00
1 parent a14db6f7e8
commit 789cc0209b
1 file changed
+10 -5
+10 -5
View File
@@ -32,9 +32,10 @@ type oneClient struct {
}
type response struct {
status bool
body string
bodyInt int
status bool
body string
bodyInt int
bodyBool bool
}
// Resource implements an OpenNebula Resource methods. *XMLResource implements
@@ -125,6 +126,7 @@ func (c *oneClient) Call(method string, args ...interface{}) (*response, error)
status bool
body string
bodyInt int64
bodyBool bool
)
if c.xmlrpcClientError != nil {
@@ -152,13 +154,16 @@ func (c *oneClient) Call(method string, args ...interface{}) (*response, error)
if ok == false {
bodyInt, ok = result[1].(int64)
if ok == false {
log.Fatal("Unexpected XML-RPC response. Expected: Index 0 Int or String")
bodyBool, ok = result[1].(bool)
if ok == false {
log.Fatal("Unexpected XML-RPC response. Expected: Index 0 Int or String")
}
}
}
// TODO: errCode? result[2]
r := &response{status, body, int(bodyInt)}
r := &response{status, body, int(bodyInt), bodyBool}
if status == false {
err = errors.New(body)