F #5289: Support sched action API into GOCA (#1302)

This commit is contained in:
Christian González authored and GitHub committed 2021-06-16 16:16:18 +02:00
1 parent 880e90bd09
commit 108ec40014
2 files changed
+25

No files matched your search

@@ -164,4 +164,5 @@ const (
Action SchedAction = "ACTION"
EndType SchedAction = "END_TYPE"
EndValue SchedAction = "END_VALUE"
ActionID SchedAction = "ID"
)
+24
View File
@@ -24,6 +24,7 @@ import (
"github.com/OpenNebula/one/src/oca/go/src/goca/parameters"
"github.com/OpenNebula/one/src/oca/go/src/goca/schemas/shared"
"github.com/OpenNebula/one/src/oca/go/src/goca/schemas/vm"
"github.com/OpenNebula/one/src/oca/go/src/goca/schemas/vm/keys"
)
// VMsController is a controller for a pool of VMs
@@ -550,3 +551,26 @@ func (vc *VMController) Unlock() error {
_, err := vc.c.Client.Call("one.vm.unlock", vc.ID)
return err
}
// AddSchedAction adds a new scheduled action to the VM
func (vc *VMController) AddSchedAction(action *vm.SchedAction) error {
_, err := vc.c.Client.Call("one.vm.schedadd", vc.ID, action.String())
return err
}
// UpdateSchedAction updates the scheduled action specified by the action ID attribute
func (vc *VMController) UpdateSchedAction(action *vm.SchedAction) error {
actionId, err := action.GetInt(string(keys.ActionID))
if err != nil {
return err
}
_, err = vc.c.Client.Call("one.vm.schedupdate", vc.ID, actionId, action.String())
return err
}
// DeleteSchedAction deletes the actionId action
func (vc *VMController) DeleteSchedAction(actionId int) error {
_, err := vc.c.Client.Call("one.vm.scheddelete", vc.ID, actionId)
return err
}