-
Notifications
You must be signed in to change notification settings - Fork 0
/
resControllerDummy.go
93 lines (78 loc) · 2.94 KB
/
resControllerDummy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* lvcl is a simple program clustering libvirt servers
* Copyright (C) 2020 Adam Prycki (email: [email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package main
import "sync"
type Dummy_rctl struct {
rwmux sync.RWMutex
resources []Cluster_resource
utilization []Cluster_utilization
}
func (c Dummy_rctl)Get_running_resources() *[]Cluster_resource {
return &c.resources }
func (c Dummy_rctl)Get_utilization() *[]Cluster_utilization {
return &c.utilization }
func (c Dummy_rctl)Start_resource(name string) bool {
lg.msg("Dummy resource "+name+" starting")
res := config.GetCluster_resourcebyName(&name)
if res == nil {
lg.msg("Dummy resource "+name+" doesn't exist")
return false}
res.State = resource_state_running
c.resources = append(c.resources, *res)
return true}
func (c Dummy_rctl)Stop_resource(name string) bool {
lg.msg("Dummy resource "+name+" stopping")
for k,_:=range c.resources {
if c.resources[k].Name == name {
c.resources[k].State = resource_state_stopped
lg.msg("Dummy resource "+name+" stopped")
return true}}
lg.msg("Dummy resource "+name+" couldn't stop, doesn't exist")
return false}
func (c Dummy_rctl)Nuke_resource(name string) bool {
lg.msg("Dummy resource "+name+" Nukked")
for k,_:=range c.resources {
if c.resources[k].Name == name {
c.resources[k].State = resource_state_stopped
lg.msg("Dummy resource "+name+" nuked")
return true}}
return true}
func (c Dummy_rctl)Migrate_resource(resource_name string,
dest_node string) bool {
lg.msg("Dummy resource "+resource_name+" migrating to "+dest_node)
return true}
func (c Dummy_rctl)Clean_resource(name string) bool {
lg.msg("Dummy resource "+name+" cleanned up")
for k,_:=range c.resources {
if c.resources[k].Name == name {
c.resources[k].State = resource_state_stopped
lg.msg("Dummy resource "+name+" cleanup")
return true}}
return false}
func (c Dummy_rctl)Kill_controller() bool {
lg.msg("Dummy resource controller Killed")
return true}
func NewDummy() *Dummy_rctl {
return &Dummy_rctl{
rwmux: sync.RWMutex{},
resources: make([]Cluster_resource, 0),
utilization: make([]Cluster_utilization, 0)}}
func (c Dummy_rctl)Get_controller_health() bool {
return true }
func (c Dummy_rctl)Get_live_migration_support() bool {
return false}