-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.go
129 lines (94 loc) · 2.96 KB
/
example.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package main
import (
"os"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
"github.com/cloudfoundry/bosh-cpi-go/apiv1"
"github.com/cloudfoundry/bosh-cpi-go/rpc"
)
type CPIFactory struct{}
type CPI struct{}
var _ apiv1.CPIFactory = CPIFactory{}
var _ apiv1.CPI = CPI{}
func main() {
logger := boshlog.NewLogger(boshlog.LevelNone)
cli := rpc.NewFactory(logger).NewCLI(CPIFactory{})
err := cli.ServeOnce()
if err != nil {
logger.Error("main", "Serving once: %s", err)
os.Exit(1)
}
}
// Empty CPI implementation
func (f CPIFactory) New(_ apiv1.CallContext) (apiv1.CPI, error) {
return CPI{}, nil
}
func (c CPI) Info() (apiv1.Info, error) {
return apiv1.Info{}, nil
}
func (c CPI) CreateStemcell(imagePath string, _ apiv1.StemcellCloudProps) (apiv1.StemcellCID, error) {
return apiv1.NewStemcellCID("stemcell-cid"), nil
}
func (c CPI) DeleteStemcell(cid apiv1.StemcellCID) error {
return nil
}
func (c CPI) CreateVM(
agentID apiv1.AgentID, stemcellCID apiv1.StemcellCID,
cloudProps apiv1.VMCloudProps, networks apiv1.Networks,
associatedDiskCIDs []apiv1.DiskCID, env apiv1.VMEnv) (apiv1.VMCID, error) {
return apiv1.NewVMCID("vm-cid"), nil
}
func (c CPI) CreateVMV2(
agentID apiv1.AgentID, stemcellCID apiv1.StemcellCID,
cloudProps apiv1.VMCloudProps, networks apiv1.Networks,
associatedDiskCIDs []apiv1.DiskCID, env apiv1.VMEnv) (apiv1.VMCID, apiv1.Networks, error) {
return apiv1.NewVMCID("vm-cid"), networks, nil
}
func (c CPI) DeleteVM(cid apiv1.VMCID) error {
return nil
}
func (c CPI) CalculateVMCloudProperties(res apiv1.VMResources) (apiv1.VMCloudProps, error) {
return apiv1.NewVMCloudPropsFromMap(map[string]interface{}{}), nil
}
func (c CPI) SetVMMetadata(cid apiv1.VMCID, metadata apiv1.VMMeta) error {
return nil
}
func (c CPI) HasVM(cid apiv1.VMCID) (bool, error) {
return false, nil
}
func (c CPI) RebootVM(cid apiv1.VMCID) error {
return nil
}
func (c CPI) GetDisks(cid apiv1.VMCID) ([]apiv1.DiskCID, error) {
return []apiv1.DiskCID{}, nil
}
func (c CPI) CreateDisk(size int,
cloudProps apiv1.DiskCloudProps, associatedVMCID *apiv1.VMCID) (apiv1.DiskCID, error) {
return apiv1.NewDiskCID("disk-cid"), nil
}
func (c CPI) DeleteDisk(cid apiv1.DiskCID) error {
return nil
}
func (c CPI) AttachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error {
return nil
}
func (c CPI) AttachDiskV2(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) (apiv1.DiskHint, error) {
return apiv1.NewDiskHintFromString(""), nil
}
func (c CPI) DetachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error {
return nil
}
func (c CPI) HasDisk(cid apiv1.DiskCID) (bool, error) {
return false, nil
}
func (c CPI) SetDiskMetadata(cid apiv1.DiskCID, metadata apiv1.DiskMeta) error {
return nil
}
func (c CPI) ResizeDisk(cid apiv1.DiskCID, size int) error {
return nil
}
func (c CPI) SnapshotDisk(cid apiv1.DiskCID, meta apiv1.DiskMeta) (apiv1.SnapshotCID, error) {
return apiv1.NewSnapshotCID("snap-cid"), nil
}
func (c CPI) DeleteSnapshot(cid apiv1.SnapshotCID) error {
return nil
}