-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathConfigurationService.java
More file actions
392 lines (342 loc) · 14 KB
/
ConfigurationService.java
File metadata and controls
392 lines (342 loc) · 14 KB
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 com.cloud.configuration;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.cloud.network.Network;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.command.admin.config.ResetCfgCmd;
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
import org.apache.cloudstack.api.command.admin.network.CreateGuestNetworkIpv6PrefixCmd;
import org.apache.cloudstack.api.command.admin.network.CreateManagementNetworkIpRangeCmd;
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.DeleteGuestNetworkIpv6PrefixCmd;
import org.apache.cloudstack.api.command.admin.network.DeleteManagementNetworkIpRangeCmd;
import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.ListGuestNetworkIpv6PrefixesCmd;
import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
import org.apache.cloudstack.api.command.admin.network.UpdatePodManagementNetworkIpRangeCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.IsAccountAllowedToCreateOfferingsWithTagsCmd;
import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd;
import org.apache.cloudstack.api.command.admin.region.DeletePortableIpRangeCmd;
import org.apache.cloudstack.api.command.admin.region.ListPortableIpRangesCmd;
import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
import org.apache.cloudstack.api.command.admin.vlan.UpdateVlanIpRangeCmd;
import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.region.PortableIp;
import org.apache.cloudstack.region.PortableIpRange;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterGuestIpv6Prefix;
import com.cloud.dc.Pod;
import com.cloud.dc.Vlan;
import com.cloud.domain.Domain;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
public interface ConfigurationService {
/**
* Updates a configuration entry with a new value
*
* @param cmd
* - the command wrapping name and value parameters
* @return updated configuration object if successful
*/
Configuration updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException;
/**
* Resets a configuration entry with default value
*
* @param cmd
* - the command wrapping name parameter
* @return updated configuration object if successful
*/
Pair<Configuration, String> resetConfiguration(ResetCfgCmd cmd) throws InvalidParameterValueException;
/**
* Create a service offering through the API
*
* @param cmd
* the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service
* offering
* @return the newly created service offering if successful, null otherwise
*/
ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd);
/**
* Updates a service offering
*
* @param serviceOfferingId
* @param userId
* @param name
* @param displayText
* @param offerHA
* @param useVirtualNetwork
* @param tags
* @return updated service offering
*/
ServiceOffering updateServiceOffering(UpdateServiceOfferingCmd cmd);
/**
* Deletes a service offering
*
* @param userId
* @param serviceOfferingId
*/
boolean deleteServiceOffering(DeleteServiceOfferingCmd cmd);
/**
* Retrieve ID of domains for a service offering
*
* @param serviceOfferingId
*/
List<Long> getServiceOfferingDomains(Long serviceOfferingId);
/**
* Retrieve ID of domains for a service offering
*
* @param serviceOfferingId
*/
List<Long> getServiceOfferingZones(Long serviceOfferingId);
/**
* Updates a disk offering
*
* @param cmd
* - the command specifying diskOfferingId, name, description, tags
* @return updated disk offering
* @throws
*/
DiskOffering updateDiskOffering(UpdateDiskOfferingCmd cmd);
/**
* Deletes a disk offering
*
* @param cmd
* - the command specifying disk offering id
* @return true or false
* @throws
*/
boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd);
/**
* Creates a new disk offering
*
* @param domainId
* @param name
* @param description
* @param numGibibytes
* @param mirrored
* @param size
* @return ID
*/
DiskOffering createDiskOffering(CreateDiskOfferingCmd cmd);
/**
* Retrieve ID of domains for a disk offering
*
* @param diskOfferingId
*/
List<Long> getDiskOfferingDomains(Long diskOfferingId);
/**
* Retrieve ID of domains for a disk offering
*
* @param diskOfferingId
*/
List<Long> getDiskOfferingZones(Long diskOfferingId);
/**
* Creates a new pod based on the parameters specified in the command object
*
* @param zoneId
* TODO
* @param name
* TODO
* @param startIp
* TODO
* @param endIp
* TODO
* @param gateway
* TODO
* @param netmask
* TODO
* @param allocationState
* TODO
* @param storageAccessGroups
* @return the new pod if successful, null otherwise
* @throws
* @throws
*/
Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState, List<String> storageAccessGroups);
/**
* Creates a mutual exclusive IP range in the pod with same gateway, netmask.
* @param cmd - The command specifying pod ID, start IP, end IP, gateway, netmask.
* @return The new range if successful, null otherwise.
*/
Pod createPodIpRange(CreateManagementNetworkIpRangeCmd cmd);
/**
* Deletes a mutually exclusive IP range in the pod.
* @param cmd - The command specifying pod ID, start IP, end IP.
*/
void deletePodIpRange(DeleteManagementNetworkIpRangeCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
/**
* Updates a mutually exclusive IP range in the pod.
* @param cmd - The command specifying pod ID, current Start IP, current End IP, new Start IP, new End IP.
* @throws com.cloud.exception.ConcurrentOperationException
* @return Success
*/
void updatePodIpRange(UpdatePodManagementNetworkIpRangeCmd cmd) throws ConcurrentOperationException;
/**
* Creates a new IPv6 prefix for a zone. Needs to be >= /64.
*/
DataCenterGuestIpv6Prefix createDataCenterGuestIpv6Prefix(CreateGuestNetworkIpv6PrefixCmd cmd);
/**
* Lists IPv6 prefixes for a zone.
*/
List<? extends DataCenterGuestIpv6Prefix> listDataCenterGuestIpv6Prefixes(ListGuestNetworkIpv6PrefixesCmd cmd);
/**
* Deletes an existing IPv6 prefix.
*/
boolean deleteDataCenterGuestIpv6Prefix(DeleteGuestNetworkIpv6PrefixCmd cmd);
/**
* Edits a pod in the database. Will not allow you to edit pods that are being used anywhere in the system.
*
* @param UpdatePodCmd
* api command
*/
Pod editPod(UpdatePodCmd cmd);
/**
* Deletes a pod from the database. Will not allow you to delete pods that are being used anywhere in the system.
*
* @param cmd
* - the command containing podId
* @return true or false
* @throws ,
*/
boolean deletePod(DeletePodCmd cmd);
/**
* Creates a new zone
*
* @param cmd
* @return the zone if successful, null otherwise
* @throws
* @throws
*/
DataCenter createZone(CreateZoneCmd cmd);
/**
* Edits a zone in the database. Will not allow you to edit DNS values if there are VMs in the specified zone.
*
* @param cmd command object containing the id of the zone to update and relevant attributes
* @return Updated zone
*/
DataCenter editZone(UpdateZoneCmd cmd);
/**
* Deletes a zone from the database. Will not allow you to delete zones that are being used anywhere in the system.
*
* @param cmd command object containg the zoneid
*/
boolean deleteZone(DeleteZoneCmd cmd);
/**
* Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on
* the
* virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs
*
* @param userId
* @param vlanType
* - either "DomR" (VLAN for a virtual public network) or "DirectAttached" (VLAN for IPs that will be
* directly
* attached to UserVMs)
* @param zoneId
* @param accountId
* @param podId
* @param add
* @param vlanId
* @param gateway
* @param startIP
* @param endIP
* @throws ResourceAllocationException TODO
* @throws
* @return The new Vlan object
*/
Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException,
ResourceAllocationException;
/**
* Updates the IP address Range for the VLAN on the database
* @return The Updated Vlan Object
*/
Vlan updateVlanAndPublicIpRange(UpdateVlanIpRangeCmd cmd) throws ConcurrentOperationException,
ResourceUnavailableException, ResourceAllocationException;
/**
* Marks the account with the default zone-id.
*
* @param accountName
* @param domainId
* @param defaultZoneId
* @return The new account object
*/
Account markDefaultZone(String accountName, long domainId, long defaultZoneId);
boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd);
Vlan dedicatePublicIpRange(DedicatePublicIpRangeCmd cmd) throws ResourceAllocationException;
boolean releasePublicIpRange(ReleasePublicIpRangeCmd cmd);
NetworkOffering createNetworkOffering(CreateNetworkOfferingCmd cmd);
NetworkOffering updateNetworkOffering(UpdateNetworkOfferingCmd cmd);
Pair<List<? extends NetworkOffering>, Integer> searchForNetworkOfferings(ListNetworkOfferingsCmd cmd);
boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd);
/**
* Retrieve ID of domains for a network offering
*
* @param networkOfferingId
*/
List<Long> getNetworkOfferingDomains(Long networkOfferingId);
/**
* Retrieve ID of domains for a network offering
*
* @param networkOfferingId
*/
List<Long> getNetworkOfferingZones(Long networkOfferingId);
Account getVlanAccount(long vlanId);
Domain getVlanDomain(long vlanId);
List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
Long getDefaultPageSize();
PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throws ConcurrentOperationException;
boolean deletePortableIpRange(DeletePortableIpRangeCmd cmd);
List<? extends PortableIpRange> listPortableIpRanges(ListPortableIpRangesCmd cmd);
List<? extends PortableIp> listPortableIps(long id);
Boolean isAccountAllowedToCreateOfferingsWithTags(IsAccountAllowedToCreateOfferingsWithTagsCmd cmd);
public static final Map<String, String> ProviderDetailKeyMap = Map.of(
Network.Provider.Nsx.getName(), ApiConstants.NSX_DETAIL_KEY,
Network.Provider.Netris.getName(), ApiConstants.NETRIS_DETAIL_KEY
);
public static boolean IsIpRangeForProvider(Network.Provider provider) {
if (Objects.isNull(provider)) {
return false;
}
return ProviderDetailKeyMap.containsKey(provider.getName());
}
}