Add task GetResult method
This commit is contained in:
parent
4efd1029a2
commit
396a8de131
@ -22,20 +22,20 @@ type APIResult struct {
|
||||
ErrorDescription string
|
||||
}
|
||||
|
||||
type VM struct {
|
||||
type XenAPIObject struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type SR struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type VDI struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
type VM XenAPIObject
|
||||
type SR XenAPIObject
|
||||
type VDI XenAPIObject
|
||||
type Network XenAPIObject
|
||||
type VBD XenAPIObject
|
||||
type VIF XenAPIObject
|
||||
type PIF XenAPIObject
|
||||
type Pool XenAPIObject
|
||||
type Task XenAPIObject
|
||||
|
||||
type VDIType int
|
||||
|
||||
@ -46,36 +46,6 @@ const (
|
||||
Floppy
|
||||
)
|
||||
|
||||
type Network struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type VBD struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type VIF struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type PIF struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
Ref string
|
||||
Client *XenAPIClient
|
||||
}
|
||||
|
||||
type TaskStatusType int
|
||||
|
||||
const (
|
||||
@ -902,6 +872,26 @@ func (self *Task) GetProgress() (progress float64, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Task) GetResult() (object *XenAPIObject, err error) {
|
||||
result := APIResult{}
|
||||
err = self.Client.APICall(&result, "task.get_result", self.Ref)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
switch ref := result.Value.(type) {
|
||||
case string:
|
||||
object = &XenAPIObject{
|
||||
Ref: ref.(string),
|
||||
Client: self.Client,
|
||||
}
|
||||
case nil:
|
||||
object = nil
|
||||
default:
|
||||
err = fmt.Errorf("task.get_result: unknown value type %T (expected string or nil)", ref)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (self *Task) GetErrorInfo() (errorInfo []string, err error) {
|
||||
result := APIResult{}
|
||||
err = self.Client.APICall(&result, "task.get_error_info", self.Ref)
|
||||
|
Loading…
Reference in New Issue
Block a user