-
Notifications
You must be signed in to change notification settings - Fork 253
/
types.go
323 lines (274 loc) · 12.3 KB
/
types.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha7
// OpenStackMachineTemplateResource describes the data needed to create a OpenStackMachine from a template.
type OpenStackMachineTemplateResource struct {
// Spec is the specification of the desired behavior of the machine.
Spec OpenStackMachineSpec `json:"spec"`
}
type ExternalRouterIPParam struct {
// The FixedIP in the corresponding subnet
FixedIP string `json:"fixedIP,omitempty"`
// The subnet in which the FixedIP is used for the Gateway of this router
Subnet SubnetFilter `json:"subnet"`
}
type SecurityGroupFilter struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ProjectID string `json:"projectId,omitempty"`
Tags string `json:"tags,omitempty"`
TagsAny string `json:"tagsAny,omitempty"`
NotTags string `json:"notTags,omitempty"`
NotTagsAny string `json:"notTagsAny,omitempty"`
}
type NetworkFilter struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ProjectID string `json:"projectId,omitempty"`
ID string `json:"id,omitempty"`
Tags string `json:"tags,omitempty"`
TagsAny string `json:"tagsAny,omitempty"`
NotTags string `json:"notTags,omitempty"`
NotTagsAny string `json:"notTagsAny,omitempty"`
}
type SubnetFilter struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ProjectID string `json:"projectId,omitempty"`
IPVersion int `json:"ipVersion,omitempty"`
GatewayIP string `json:"gateway_ip,omitempty"`
CIDR string `json:"cidr,omitempty"`
IPv6AddressMode string `json:"ipv6AddressMode,omitempty"`
IPv6RAMode string `json:"ipv6RaMode,omitempty"`
ID string `json:"id,omitempty"`
Tags string `json:"tags,omitempty"`
TagsAny string `json:"tagsAny,omitempty"`
NotTags string `json:"notTags,omitempty"`
NotTagsAny string `json:"notTagsAny,omitempty"`
}
type RouterFilter struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
ProjectID string `json:"projectId,omitempty"`
Tags string `json:"tags,omitempty"`
TagsAny string `json:"tagsAny,omitempty"`
NotTags string `json:"notTags,omitempty"`
NotTagsAny string `json:"notTagsAny,omitempty"`
}
type PortOpts struct {
// Network is a query for an openstack network that the port will be created or discovered on.
// This will fail if the query returns more than one network.
Network *NetworkFilter `json:"network,omitempty"`
// Used to make the name of the port unique. If unspecified, instead the 0-based index of the port in the list is used.
NameSuffix string `json:"nameSuffix,omitempty"`
Description string `json:"description,omitempty"`
AdminStateUp *bool `json:"adminStateUp,omitempty"`
MACAddress string `json:"macAddress,omitempty"`
// Specify pairs of subnet and/or IP address. These should be subnets of the network with the given NetworkID.
FixedIPs []FixedIP `json:"fixedIPs,omitempty"`
// The names, uuids, filters or any combination these of the security groups to assign to the instance
SecurityGroupFilters []SecurityGroupFilter `json:"securityGroupFilters,omitempty"`
AllowedAddressPairs []AddressPair `json:"allowedAddressPairs,omitempty"`
// Enables and disables trunk at port level. If not provided, openStackMachine.Spec.Trunk is inherited.
Trunk *bool `json:"trunk,omitempty"`
// The ID of the host where the port is allocated
HostID string `json:"hostId,omitempty"`
// The virtual network interface card (vNIC) type that is bound to the neutron port.
VNICType string `json:"vnicType,omitempty"`
// Profile is a set of key-value pairs that are used for binding details.
// We intentionally don't expose this as a map[string]string because we only want to enable
// the users to set the values of the keys that are known to work in OpenStack Networking API.
// See https://docs.openstack.org/api-ref/network/v2/index.html?expanded=create-port-detail#create-port
Profile BindingProfile `json:"profile,omitempty"`
// DisablePortSecurity enables or disables the port security when set.
// When not set, it takes the value of the corresponding field at the network level.
DisablePortSecurity *bool `json:"disablePortSecurity,omitempty"`
// PropageteUplinkStatus enables or disables the propagate uplink status on the port.
PropagateUplinkStatus *bool `json:"propagateUplinkStatus,omitempty"`
// Tags applied to the port (and corresponding trunk, if a trunk is configured.)
// These tags are applied in addition to the instance's tags, which will also be applied to the port.
// +listType=set
Tags []string `json:"tags,omitempty"`
// Value specs are extra parameters to include in the API request with OpenStack.
// This is an extension point for the API, so what they do and if they are supported,
// depends on the specific OpenStack implementation.
// +optional
// +listType=map
// +listMapKey=name
ValueSpecs []ValueSpec `json:"valueSpecs,omitempty"`
}
type BindingProfile struct {
// OVSHWOffload enables or disables the OVS hardware offload feature.
OVSHWOffload bool `json:"ovsHWOffload,omitempty"`
// TrustedVF enables or disables the “trusted mode” for the VF.
TrustedVF bool `json:"trustedVF,omitempty"`
}
type FixedIP struct {
// Subnet is an openstack subnet query that will return the id of a subnet to create
// the fixed IP of a port in. This query must not return more than one subnet.
Subnet *SubnetFilter `json:"subnet"`
IPAddress string `json:"ipAddress,omitempty"`
}
type AddressPair struct {
IPAddress string `json:"ipAddress,omitempty"`
MACAddress string `json:"macAddress,omitempty"`
}
type BastionStatus struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
SSHKeyName string `json:"sshKeyName,omitempty"`
State InstanceState `json:"state,omitempty"`
IP string `json:"ip,omitempty"`
FloatingIP string `json:"floatingIP,omitempty"`
}
type RootVolume struct {
Size int `json:"diskSize,omitempty"`
VolumeType string `json:"volumeType,omitempty"`
AvailabilityZone string `json:"availabilityZone,omitempty"`
}
type AdditionalBlockDevice struct {
// Name of the Cinder volume in the context of a machine.
// It will be combined with the machine name to make the actual volume name.
Name string `json:"name"`
// Size is the size in GB of the volume.
Size int `json:"diskSize"`
// VolumeType is the volume type of the volume.
// If omitted, the default type will be used.
VolumeType string `json:"volumeType,omitempty"`
// AvailabilityZone is the volume availability zone to create the volume in.
// If omitted, the availability zone of the server will be used.
AvailabilityZone string `json:"availabilityZone,omitempty"`
}
// NetworkStatus contains basic information about an existing neutron network.
type NetworkStatus struct {
Name string `json:"name"`
ID string `json:"id"`
//+optional
Tags []string `json:"tags,omitempty"`
}
// NetworkStatusWithSubnets represents basic information about an existing neutron network and an associated set of subnets.
type NetworkStatusWithSubnets struct {
NetworkStatus `json:",inline"`
// Subnets is a list of subnets associated with the default cluster network. Machines which use the default cluster network will get an address from all of these subnets.
Subnets []Subnet `json:"subnets,omitempty"`
}
// Subnet represents basic information about the associated OpenStack Neutron Subnet.
type Subnet struct {
Name string `json:"name"`
ID string `json:"id"`
CIDR string `json:"cidr"`
//+optional
Tags []string `json:"tags,omitempty"`
}
// Router represents basic information about the associated OpenStack Neutron Router.
type Router struct {
Name string `json:"name"`
ID string `json:"id"`
//+optional
Tags []string `json:"tags,omitempty"`
//+optional
IPs []string `json:"ips,omitempty"`
}
// LoadBalancer represents basic information about the associated OpenStack LoadBalancer.
type LoadBalancer struct {
Name string `json:"name"`
ID string `json:"id"`
IP string `json:"ip"`
InternalIP string `json:"internalIP"`
//+optional
AllowedCIDRs []string `json:"allowedCIDRs,omitempty"`
//+optional
Tags []string `json:"tags,omitempty"`
}
// SecurityGroup represents the basic information of the associated
// OpenStack Neutron Security Group.
type SecurityGroup struct {
Name string `json:"name"`
ID string `json:"id"`
Rules []SecurityGroupRule `json:"rules"`
}
// SecurityGroupRule represent the basic information of the associated OpenStack
// Security Group Role.
type SecurityGroupRule struct {
Description string `json:"description"`
ID string `json:"name"`
Direction string `json:"direction"`
EtherType string `json:"etherType"`
SecurityGroupID string `json:"securityGroupID"`
PortRangeMin int `json:"portRangeMin"`
PortRangeMax int `json:"portRangeMax"`
Protocol string `json:"protocol"`
RemoteGroupID string `json:"remoteGroupID"`
RemoteIPPrefix string `json:"remoteIPPrefix"`
}
// Equal checks if two SecurityGroupRules are the same.
func (r SecurityGroupRule) Equal(x SecurityGroupRule) bool {
return (r.Direction == x.Direction &&
r.Description == x.Description &&
r.EtherType == x.EtherType &&
r.PortRangeMin == x.PortRangeMin &&
r.PortRangeMax == x.PortRangeMax &&
r.Protocol == x.Protocol &&
r.RemoteGroupID == x.RemoteGroupID &&
r.RemoteIPPrefix == x.RemoteIPPrefix)
}
// InstanceState describes the state of an OpenStack instance.
type InstanceState string
var (
// InstanceStateBuilding is the string representing an instance in a building state.
InstanceStateBuilding = InstanceState("BUILDING")
// InstanceStateActive is the string representing an instance in an active state.
InstanceStateActive = InstanceState("ACTIVE")
// InstanceStateError is the string representing an instance in an error state.
InstanceStateError = InstanceState("ERROR")
// InstanceStateStopped is the string representing an instance in a stopped state.
InstanceStateStopped = InstanceState("STOPPED")
// InstanceStateShutoff is the string representing an instance in a shutoff state.
InstanceStateShutoff = InstanceState("SHUTOFF")
// InstanceStateDeleted is the string representing an instance in a deleted state.
InstanceStateDeleted = InstanceState("DELETED")
)
// Bastion represents basic information about the bastion node.
type Bastion struct {
//+optional
Enabled bool `json:"enabled"`
// Instance for the bastion itself
Instance OpenStackMachineSpec `json:"instance,omitempty"`
//+optional
AvailabilityZone string `json:"availabilityZone,omitempty"`
}
type APIServerLoadBalancer struct {
// Enabled defines whether a load balancer should be created.
Enabled bool `json:"enabled,omitempty"`
// AdditionalPorts adds additional tcp ports to the load balancer.
AdditionalPorts []int `json:"additionalPorts,omitempty"`
// AllowedCIDRs restrict access to all API-Server listeners to the given address CIDRs.
AllowedCIDRs []string `json:"allowedCidrs,omitempty"`
// Octavia Provider Used to create load balancer
Provider string `json:"provider,omitempty"`
}
// ValueSpec represents a single value_spec key-value pair.
type ValueSpec struct {
// Name is the name of the key-value pair.
// This is just for identifying the pair and will not be sent to the OpenStack API.
// +kubebuilder:validation:Required
Name string `json:"name"`
// Key is the key in the key-value pair.
// +kubebuilder:validation:Required
Key string `json:"key"`
// Value is the value in the key-value pair.
// +kubebuilder:validation:Required
Value string `json:"value"`
}