-
Notifications
You must be signed in to change notification settings - Fork 241
/
api.go
181 lines (154 loc) · 5.38 KB
/
api.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Copyright 2017 Microsoft. All rights reserved.
// MIT License
package cns
import "encoding/json"
// Container Network Service remote API Contract
const (
SetEnvironmentPath = "/network/environment"
CreateNetworkPath = "/network/create"
DeleteNetworkPath = "/network/delete"
CreateHnsNetworkPath = "/network/hns/create"
DeleteHnsNetworkPath = "/network/hns/delete"
ReserveIPAddressPath = "/network/ip/reserve"
ReleaseIPAddressPath = "/network/ip/release"
GetHostLocalIPPath = "/network/ip/hostlocal"
GetIPAddressUtilizationPath = "/network/ip/utilization"
GetUnhealthyIPAddressesPath = "/network/ipaddresses/unhealthy"
GetHealthReportPath = "/network/health"
NumberOfCPUCoresPath = "/hostcpucores"
CreateHostNCApipaEndpointPath = "/network/createhostncapipaendpoint"
DeleteHostNCApipaEndpointPath = "/network/deletehostncapipaendpoint"
V1Prefix = "/v0.1"
V2Prefix = "/v0.2"
)
// SetEnvironmentRequest describes the Request to set the environment in CNS.
type SetEnvironmentRequest struct {
Location string
NetworkType string
}
// OverlayConfiguration describes configuration for all the nodes that are part of overlay.
type OverlayConfiguration struct {
NodeCount int
LocalNodeIP string
OverlaySubent Subnet
NodeConfig []NodeConfiguration
}
// CreateNetworkRequest describes request to create the network.
type CreateNetworkRequest struct {
NetworkName string
OverlayConfiguration OverlayConfiguration
Options map[string]interface{}
}
// DeleteNetworkRequest describes request to delete the network.
type DeleteNetworkRequest struct {
NetworkName string
}
// CreateHnsNetworkRequest describes request to create the HNS network.
type CreateHnsNetworkRequest struct {
NetworkName string
NetworkType string
NetworkAdapterName string `json:",omitempty"`
SourceMac string `json:",omitempty"`
Policies []json.RawMessage `json:",omitempty"`
MacPools []MacPool `json:",omitempty"`
Subnets []SubnetInfo
DNSSuffix string `json:",omitempty"`
DNSServerList string `json:",omitempty"`
DNSServerCompartment uint32 `json:",omitempty"`
ManagementIP string `json:",omitempty"`
AutomaticDNS bool `json:",omitempty"`
}
// SubnetInfo is assoicated with HNS network and represents a list
// of subnets available to the network
type SubnetInfo struct {
AddressPrefix string
GatewayAddress string
Policies []json.RawMessage `json:",omitempty"`
}
// MacPool is assoicated with HNS network and represents a list
// of macaddresses available to the network
type MacPool struct {
StartMacAddress string
EndMacAddress string
}
// DeleteHnsNetworkRequest describes request to delete the HNS network.
type DeleteHnsNetworkRequest struct {
NetworkName string
}
// ReserveIPAddressRequest describes request to reserve an IP Address
type ReserveIPAddressRequest struct {
ReservationID string
}
// ReserveIPAddressResponse describes response to reserve an IP address.
type ReserveIPAddressResponse struct {
Response Response
IPAddress string
}
// ReleaseIPAddressRequest describes request to release an IP Address.
type ReleaseIPAddressRequest struct {
ReservationID string
}
// IPAddressesUtilizationResponse describes response for ip address utilization.
type IPAddressesUtilizationResponse struct {
Response Response
Available int
Reserved int
Unhealthy int
}
// GetIPAddressesResponse describes response containing requested ip addresses.
type GetIPAddressesResponse struct {
Response Response
IPAddresses []string
}
// HostLocalIPAddressResponse describes reponse that returns the host local IP Address.
type HostLocalIPAddressResponse struct {
Response Response
IPAddress string
}
// Subnet contains the ip address and the number of bits in prefix.
type Subnet struct {
IPAddress string
PrefixLength int
}
// NodeConfiguration describes confguration for a node in overlay network.
type NodeConfiguration struct {
NodeIP string
NodeID string
NodeSubnet Subnet
}
// Response describes generic response from CNS.
type Response struct {
ReturnCode int
Message string
}
// NumOfCPUCoresResponse describes num of cpu cores present on host.
type NumOfCPUCoresResponse struct {
Response Response
NumOfCPUCores int
}
// OptionMap describes generic options that can be passed to CNS.
type OptionMap map[string]interface{}
// Response to a failed request.
type errorResponse struct {
Err string
}
// CreateHostNCApipaEndpointRequest describes request for create apipa endpoint
// for host container connectivity for the given network container
type CreateHostNCApipaEndpointRequest struct {
NetworkContainerID string
}
// CreateHostNCApipaEndpointResponse describes response for create apipa endpoint request
// for host container connectivity.
type CreateHostNCApipaEndpointResponse struct {
Response Response
EndpointID string
}
// DeleteHostNCApipaEndpointRequest describes request for deleting apipa endpoint created
// for host NC connectivity.
type DeleteHostNCApipaEndpointRequest struct {
NetworkContainerID string
}
// DeleteHostNCApipaEndpointResponse describes response for delete host NC apipa endpoint request.
type DeleteHostNCApipaEndpointResponse struct {
Response Response
}