This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
VMHandler.go
106 lines (80 loc) · 2.55 KB
/
VMHandler.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
98
99
100
101
102
103
104
105
106
// 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, 2020.04.
// by CB-Spider Team, 2019.06.
package resources
import (
"time"
)
type VMReqInfo struct {
IId IID // {NameId, SystemId}
ImageIID IID
VpcIID IID
SubnetIID IID
SecurityGroupIIDs []IID
VMSpecName string
KeyPairIID IID
VMUserId string
VMUserPasswd string
}
type VMStatusInfo struct {
IId IID // {NameId, SystemId}
VmStatus VMStatus
}
// GO do not support Enum. So, define like this.
type VMStatus string
const (
Creating VMStatus = "Creating" // from launch to running
Running VMStatus = "Running"
Suspending VMStatus = "Suspending" // from running to suspended
Suspended VMStatus = "Suspended"
Resuming VMStatus = "Resuming" // from suspended to running
Rebooting VMStatus = "Rebooting" // from running to running
Terminating VMStatus = "Terminating" // from running, suspended to terminated
Terminated VMStatus = "Terminated"
NotExist VMStatus = "NotExist" // VM does not exist
Failed VMStatus = "Failed"
)
type RegionInfo struct {
Region string
Zone string
}
type VMInfo struct {
IId IID // {NameId, SystemId}
StartTime time.Time // Timezone: based on cloud-barista server location.
Region RegionInfo // ex) {us-east1, us-east1-c} or {ap-northeast-2}
ImageIId IID
VMSpecName string // instance type or flavour, etc... ex) t2.micro or f1.micro
VpcIID IID
SubnetIID IID // AWS, ex) subnet-8c4a53e4
SecurityGroupIIds []IID // AWS, ex) sg-0b7452563e1121bb6
KeyPairIId IID
VMUserId string // ex) user1
VMUserPasswd string
NetworkInterface string // ex) eth0
PublicIP string
PublicDNS string
PrivateIP string
PrivateDNS string
VMBootDisk string // ex) /dev/sda1
VMBlockDisk string // ex)
SSHAccessPoint string // ex) 10.2.3.2:22, 123.456.789.123:4321
KeyValueList []KeyValue
}
type VMHandler interface {
StartVM(vmReqInfo VMReqInfo) (VMInfo, error)
SuspendVM(vmIID IID) (VMStatus, error)
ResumeVM(vmIID IID) (VMStatus, error)
RebootVM(vmIID IID) (VMStatus, error)
TerminateVM(vmIID IID) (VMStatus, error)
ListVMStatus() ([]*VMStatusInfo, error)
GetVMStatus(vmIID IID) (VMStatus, error)
ListVM() ([]*VMInfo, error)
GetVM(vmIID IID) (VMInfo, error)
}