1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

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

This commit is contained in:
Christian González 2021-06-16 16:16:18 +02:00 committed by GitHub
parent 880e90bd09
commit 108ec40014
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -164,4 +164,5 @@ const (
Action SchedAction = "ACTION"
EndType SchedAction = "END_TYPE"
EndValue SchedAction = "END_VALUE"
ActionID SchedAction = "ID"
)

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
}