-
Notifications
You must be signed in to change notification settings - Fork 48
/
NLBHandler.go
97 lines (76 loc) · 2.69 KB
/
NLBHandler.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
94
95
96
97
// Cloud Driver Interface of CB-Spider.
// The CB-Spider is a sub-Framework of the Cloud-Barista Multi-Cloud Project.
// The CB-Spider Mission is to connect all the clouds with a single interface.
//
// * Cloud-Barista: https://github.com/cloud-barista
//
// This is Resouces interfaces of Cloud Driver.
//
// by CB-Spider Team, 2022.05.
package resources
import "time"
//-------- Info Structure
type NLBInfo struct {
IId IID // {NameId, SystemId}
VpcIID IID // {NameId, SystemId}
Type string // PUBLIC(V) | INTERNAL
Scope string // REGION(V) | GLOBAL
//------ Frontend
Listener ListenerInfo
//------ Backend
VMGroup VMGroupInfo
HealthChecker HealthCheckerInfo
CreatedTime time.Time
KeyValueList []KeyValue
}
type ListenerInfo struct {
Protocol string // TCP|UDP
IP string // Auto Generated and attached
Port string // 1-65535
DNSName string // Optional, Auto Generated and attached
CspID string // Optional, May be Used by Driver.
KeyValueList []KeyValue
}
type VMGroupInfo struct {
Protocol string // TCP|UDP|HTTP|HTTPS
Port string // 1-65535
VMs *[]IID
CspID string // Optional, May be Used by Driver.
KeyValueList []KeyValue
}
type HealthCheckerInfo struct {
Protocol string // TCP|HTTP|HTTPS
Port string // Listener Port or 1-65535
Interval int // secs, Interval time between health checks.
Timeout int // secs, Waiting time to decide an unhealthy VM when no response.
Threshold int // num, The number of continuous health checks to change the VM status.
CspID string // Optional, May be Used by Driver.
KeyValueList []KeyValue
}
type HealthInfo struct {
AllVMs *[]IID
HealthyVMs *[]IID
UnHealthyVMs *[]IID
}
//-------- API
type NLBHandler interface {
//------ NLB Management
CreateNLB(nlbReqInfo NLBInfo) (NLBInfo, error)
ListNLB() ([]*NLBInfo, error)
GetNLB(nlbIID IID) (NLBInfo, error)
DeleteNLB(nlbIID IID) (bool, error)
GetVMGroupHealthInfo(nlbIID IID) (HealthInfo, error)
AddVMs(nlbIID IID, vmIIDs *[]IID) (VMGroupInfo, error)
RemoveVMs(nlbIID IID, vmIIDs *[]IID) (bool, error)
//---------------------------------------------------//
// @todo To support or not will be decided later. //
//---------------------------------------------------//
//------ Frontend Control
ChangeListener(nlbIID IID, listener ListenerInfo) (ListenerInfo, error)
//------ Backend Control
ChangeVMGroupInfo(nlbIID IID, vmGroup VMGroupInfo) (VMGroupInfo, error)
ChangeHealthCheckerInfo(nlbIID IID, healthChecker HealthCheckerInfo) (HealthCheckerInfo, error)
//---------------------------------------------------//
// @todo To support or not will be decided later. //
//---------------------------------------------------//
}