-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
143 lines (118 loc) · 3.49 KB
/
provider.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package api
import (
"net/url"
"time"
)
// Modified version from https://github.com/codedellemc/libstorage as an example.
// This is a minimal definition. Ultimately, this will be the simplest and
// most concise definition that consolidates the goodness from muliple
// service management drivers.
// Service definition. (TBD)
type Service struct {
}
// ServiceSpec are options when creating a new data service.
type ServiceSpec struct {
AvailabilityZone *string
IOPS *int64
Size *int64
Encrypted *bool
EncryptionKey *string
Options map[string]string
}
type Capability int
const (
CapabilityEncryption Capability = iota
CapabilityCompresssion
CapabilityDeduplication
CapabilityReplication
CapabilityDR
CapabilityMulitAZ
CapabilityConverged
)
type DataService struct {
// ServiceType could be a string such as object, block, file.
ServiceType string
Size uint64
Iops uint64
Capabilities []Capability
}
type CreateOptions struct {
// SrcID Create service from source ID
SrcID string
// LateBinding allow creation of volume but defers resource allocation
// to when the service is instantiated.
LateBinding bool
}
// Provder implements a data service provider. This interface implements the
// union of the the data service's CRUD commands as well as it's
// lifecycle operations.
type Provider interface {
// Type returns the type of storage the driver provides.
Type() (string, error)
// ServiceType advertises the type of service (block, object, file etc)
// offered by this provider on a given node.
ServiceType() (DataService, error)
// SchedulerQuery returns a list of nodes (IPs) that are preferred nodes
// to run a container on, given a set of opts.
SchedulerQuery(
opts map[string]string,
) ([]string, error)
// Enumerate all services that satisfy contraints defined by opts.
Enumerate(opts map[string]string) ([]*Service, error)
// Inspect inspects a single service.
Inspect(
ID string,
opts map[string]string,
) (*Service, error)
// Create creates a new service.
Create(
name string,
spec *ServiceSpec,
createOpts *CreateOptions,
opts map[string]string,
) (*Service, error)
// Backup to provider.
Backup(ID string, provider Provider)
// Snapshot snapshots a service.
Snapshot(
ID, snapshotName string,
opts map[string]string,
) (*Service, error)
// Remove removes a service.
Remove(
ID string,
opts map[string]string,
) error
// Attach attaches a service and provides a token clients can use
// to validate that device has appeared locally.
Attach(
ID string,
opts map[string]string,
) (*Service, string, error)
// Detach detaches a service.
Detach(
ID string,
opts map[string]string,
) (*Service, error)
// Mount service to specific path.
Mount(
ID, mountpoint string,
opts map[string]string,
) error
// Unmount service to specific path.
Unmount(
ID, mountpoint string,
opts map[string]string,
) error
// Stat returns the service and network statistics for this provider
// on a given node.
Stat() (ServiceStat, NetStat, error)
// LogStats provides an logging URL for the provider dump
// service stats to. An interval of 0 stops the logging.
LogStats(url url.URL, interval time.Duration) error
// Alerts returns the alerts for this provider on a given node.
Alerts() ([]Alert, error)
// LogAlerts provides an alerting URL for the provider dump
// service alerts to. An interval of 0 stops the logging.
LogAlerts(url url.URL, interval time.Duration) error
}