Skip to content

Commit 5c2d7f4

Browse files
committed
Merge branch '858-quota-updates' into 2.x
2 parents b6e0377 + 9c6b1fc commit 5c2d7f4

File tree

6 files changed

+243
-14
lines changed

6 files changed

+243
-14
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/organizationadmin/DefaultOrganizationAdmin.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ public Mono<OrganizationQuota> updateQuota(UpdateQuotaRequest request) {
123123
private static Mono<CreateOrganizationQuotaDefinitionResponse> createOrganizationQuota(CloudFoundryClient cloudFoundryClient, CreateQuotaRequest request) {
124124
return requestCreateOrganizationQuota(
125125
cloudFoundryClient,
126+
Optional.ofNullable(request.getApplicationInstanceLimit()).orElse(-1),
126127
Optional.ofNullable(request.getInstanceMemoryLimit()).orElse(-1),
127128
Optional.ofNullable(request.getMemoryLimit()).orElse(0),
128129
request.getName(),
129130
Optional.ofNullable(request.getAllowPaidServicePlans()).orElse(false),
131+
Optional.ofNullable(request.getTotalReservedRoutePorts()).orElse(0),
130132
Optional.ofNullable(request.getTotalRoutes()).orElse(0),
131133
Optional.ofNullable(request.getTotalServices()).orElse(0));
132134
}
@@ -154,14 +156,17 @@ private static Mono<String> getOrganizationQuotaId(CloudFoundryClient cloudFound
154156
.map(ResourceUtils::getId);
155157
}
156158

157-
private static Mono<CreateOrganizationQuotaDefinitionResponse> requestCreateOrganizationQuota(CloudFoundryClient cloudFoundryClient, Integer instanceMemoryLimit, Integer memoryLimit, String name,
158-
Boolean nonBasicServicesAllowed, Integer totalRoutes, Integer totalServices) {
159+
private static Mono<CreateOrganizationQuotaDefinitionResponse> requestCreateOrganizationQuota(CloudFoundryClient cloudFoundryClient, Integer applicationInstanceLimit, Integer instanceMemoryLimit,
160+
Integer memoryLimit, String name, Boolean nonBasicServicesAllowed, Integer totalReservedRoutePorts,
161+
Integer totalRoutes, Integer totalServices) {
159162
return cloudFoundryClient.organizationQuotaDefinitions()
160163
.create(CreateOrganizationQuotaDefinitionRequest.builder()
164+
.applicationInstanceLimit(applicationInstanceLimit)
161165
.instanceMemoryLimit(instanceMemoryLimit)
162166
.memoryLimit(memoryLimit)
163167
.name(name)
164168
.nonBasicServicesAllowed(nonBasicServicesAllowed)
169+
.totalReservedRoutePorts(totalReservedRoutePorts)
165170
.totalRoutes(totalRoutes)
166171
.totalServices(totalServices)
167172
.build());
@@ -209,16 +214,19 @@ private static Mono<UpdateOrganizationResponse> requestUpdateOrganization(CloudF
209214
.build());
210215
}
211216

212-
private static Mono<UpdateOrganizationQuotaDefinitionResponse> requestUpdateOrganizationQuota(CloudFoundryClient cloudFoundryClient, String organizationQuotaDefinitionId,
213-
Integer instanceMemoryLimit, Integer memoryLimit, String name, Boolean nonBasicServicesAllowed,
214-
Integer totalRoutes, Integer totalServices) {
217+
private static Mono<UpdateOrganizationQuotaDefinitionResponse> requestUpdateOrganizationQuota(CloudFoundryClient cloudFoundryClient, Integer applicationInstanceLimit, Integer instanceMemoryLimit,
218+
Integer memoryLimit, String name, Boolean nonBasicServicesAllowed,
219+
String organizationQuotaDefinitionId, Integer totalReservedRoutePorts, Integer totalRoutes,
220+
Integer totalServices) {
215221
return cloudFoundryClient.organizationQuotaDefinitions()
216222
.update(UpdateOrganizationQuotaDefinitionRequest.builder()
223+
.applicationInstanceLimit(applicationInstanceLimit)
217224
.instanceMemoryLimit(instanceMemoryLimit)
218225
.memoryLimit(memoryLimit)
219226
.name(name)
220227
.organizationQuotaDefinitionId(organizationQuotaDefinitionId)
221228
.nonBasicServicesAllowed(nonBasicServicesAllowed)
229+
.totalReservedRoutePorts(totalReservedRoutePorts)
222230
.totalRoutes(totalRoutes)
223231
.totalServices(totalServices)
224232
.build());
@@ -234,6 +242,7 @@ private static OrganizationQuota toOrganizationQuota(AbstractOrganizationQuotaDe
234242
.instanceMemoryLimit(entity.getInstanceMemoryLimit())
235243
.memoryLimit(entity.getMemoryLimit())
236244
.name(entity.getName())
245+
.totalReservedRoutePorts(entity.getTotalReservedRoutePorts())
237246
.totalRoutes(entity.getTotalRoutes())
238247
.totalServices(entity.getTotalServices())
239248
.build();
@@ -245,11 +254,11 @@ private static Mono<UpdateOrganizationQuotaDefinitionResponse> updateOrganizatio
245254

246255
return requestUpdateOrganizationQuota(
247256
cloudFoundryClient,
257+
Optional.ofNullable(request.getApplicationInstanceLimit()).orElse(-1),
258+
Optional.ofNullable(request.getInstanceMemoryLimit()).orElse(existing.getInstanceMemoryLimit()), Optional.ofNullable(request.getMemoryLimit()).orElse(existing.getMemoryLimit()),
259+
Optional.ofNullable(request.getNewName()).orElse(existing.getName()), Optional.ofNullable(request.getAllowPaidServicePlans()).orElse(existing.getNonBasicServicesAllowed()),
248260
ResourceUtils.getId(resource),
249-
Optional.ofNullable(request.getInstanceMemoryLimit()).orElse(existing.getInstanceMemoryLimit()),
250-
Optional.ofNullable(request.getMemoryLimit()).orElse(existing.getMemoryLimit()),
251-
Optional.ofNullable(request.getNewName()).orElse(existing.getName()),
252-
Optional.ofNullable(request.getAllowPaidServicePlans()).orElse(existing.getNonBasicServicesAllowed()),
261+
Optional.ofNullable(request.getTotalReservedRoutePorts()).orElse(0),
253262
Optional.ofNullable(request.getTotalRoutes()).orElse(existing.getTotalRoutes()),
254263
Optional.ofNullable(request.getTotalServices()).orElse(existing.getTotalServices()));
255264
}

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/organizationadmin/_CreateQuotaRequest.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,25 @@
2626
abstract class _CreateQuotaRequest {
2727

2828
/**
29-
* The allow paid service plans flag
29+
* Can provision instances of paid service plans
3030
*/
3131
@Nullable
3232
abstract Boolean getAllowPaidServicePlans();
3333

3434
/**
35-
* The instance memory limit
35+
* Total number of application instances
36+
*/
37+
@Nullable
38+
abstract Integer getApplicationInstanceLimit();
39+
40+
/**
41+
* The application instance memory limit in mb
3642
*/
3743
@Nullable
3844
abstract Integer getInstanceMemoryLimit();
3945

4046
/**
41-
* The memory limit
47+
* Total amount of memory a space can have in mb
4248
*/
4349
@Nullable
4450
abstract Integer getMemoryLimit();
@@ -49,13 +55,19 @@ abstract class _CreateQuotaRequest {
4955
abstract String getName();
5056

5157
/**
52-
* The total routes
58+
* Maximum number of routes that may be created with reserved ports
59+
*/
60+
@Nullable
61+
abstract Integer getTotalReservedRoutePorts();
62+
63+
/**
64+
* The total number of routes
5365
*/
5466
@Nullable
5567
abstract Integer getTotalRoutes();
5668

5769
/**
58-
* The total services
70+
* Total number of service instances
5971
*/
6072
@Nullable
6173
abstract Integer getTotalServices();

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/organizationadmin/_OrganizationQuota.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ abstract class _OrganizationQuota {
5454
*/
5555
abstract String getName();
5656

57+
/**
58+
* Maximum number of routes that may be created with reserved ports
59+
*/
60+
abstract Integer getTotalReservedRoutePorts();
61+
5762
/**
5863
* The total routes
5964
*/

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/organizationadmin/_UpdateQuotaRequest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ abstract class _UpdateQuotaRequest {
3131
@Nullable
3232
abstract Boolean getAllowPaidServicePlans();
3333

34+
/**
35+
* Total number of application instances
36+
*/
37+
@Nullable
38+
abstract Integer getApplicationInstanceLimit();
39+
3440
/**
3541
* The instance memory limit
3642
*/
@@ -54,6 +60,12 @@ abstract class _UpdateQuotaRequest {
5460
@Nullable
5561
abstract String getNewName();
5662

63+
/**
64+
* Maximum number of routes that may be created with reserved ports
65+
*/
66+
@Nullable
67+
abstract Integer getTotalReservedRoutePorts();
68+
5769
/**
5870
* The total routes
5971
*/

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/organizationadmin/DefaultOrganizationAdminTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void createQuota() {
6767
.instanceMemoryLimit(3)
6868
.memoryLimit(4)
6969
.name("test-quota")
70+
.totalReservedRoutePorts(0)
7071
.totalRoutes(1)
7172
.totalServices(2)
7273
.build())
@@ -101,6 +102,7 @@ public void getQuota() {
101102
.instanceMemoryLimit(1)
102103
.memoryLimit(1)
103104
.name("test-quota-name")
105+
.totalReservedRoutePorts(1)
104106
.totalRoutes(1)
105107
.totalServices(1)
106108
.build())
@@ -133,6 +135,7 @@ public void listQuotas() {
133135
.instanceMemoryLimit(1)
134136
.memoryLimit(1)
135137
.name("test-quota-name")
138+
.totalReservedRoutePorts(1)
136139
.totalRoutes(1)
137140
.totalServices(1)
138141
.build())
@@ -205,6 +208,7 @@ public void updateQuota() {
205208
.instanceMemoryLimit(3)
206209
.memoryLimit(4)
207210
.name("new-test-quota")
211+
.totalReservedRoutePorts(0)
208212
.totalRoutes(1)
209213
.totalServices(2)
210214
.build())
@@ -229,9 +233,11 @@ private static void requestCreateOrganizationQuota(CloudFoundryClient cloudFound
229233
Integer totalRoutes, Integer totalServices, String quotaDefinitionId) {
230234
when(cloudFoundryClient.organizationQuotaDefinitions()
231235
.create(CreateOrganizationQuotaDefinitionRequest.builder()
236+
.applicationInstanceLimit(-1)
232237
.instanceMemoryLimit(instanceMemoryLimit)
233238
.memoryLimit(memoryLimit)
234239
.nonBasicServicesAllowed(nonBasicServicesAllowed)
240+
.totalReservedRoutePorts(0)
235241
.totalRoutes(totalRoutes)
236242
.totalServices(totalServices)
237243
.name(name)
@@ -249,6 +255,7 @@ private static void requestCreateOrganizationQuota(CloudFoundryClient cloudFound
249255
.applicationTaskLimit(-1)
250256
.name("test-quota")
251257
.nonBasicServicesAllowed(nonBasicServicesAllowed)
258+
.totalReservedRoutePorts(0)
252259
.totalPrivateDomains(-1)
253260
.totalRoutes(totalRoutes)
254261
.build())
@@ -258,9 +265,11 @@ private static void requestCreateOrganizationQuota(CloudFoundryClient cloudFound
258265
private static void requestCreateOrganizationQuotaError(CloudFoundryClient cloudFoundryClient, String name) {
259266
when(cloudFoundryClient.organizationQuotaDefinitions()
260267
.create(CreateOrganizationQuotaDefinitionRequest.builder()
268+
.applicationInstanceLimit(-1)
261269
.instanceMemoryLimit(-1)
262270
.memoryLimit(0)
263271
.nonBasicServicesAllowed(false)
272+
.totalReservedRoutePorts(0)
264273
.totalRoutes(0)
265274
.totalServices(0)
266275
.name(name)
@@ -343,11 +352,13 @@ private static void requestUpdateOrganizationQuota(CloudFoundryClient cloudFound
343352
Boolean nonBasicServicesAllowed, Integer totalRoutes, Integer totalServices) {
344353
when(cloudFoundryClient.organizationQuotaDefinitions()
345354
.update(UpdateOrganizationQuotaDefinitionRequest.builder()
355+
.applicationInstanceLimit(-1)
346356
.instanceMemoryLimit(instanceMemoryLimit)
347357
.memoryLimit(memoryLimit)
348358
.name(name)
349359
.nonBasicServicesAllowed(nonBasicServicesAllowed)
350360
.organizationQuotaDefinitionId(organizationQuotaDefinitionId)
361+
.totalReservedRoutePorts(0)
351362
.totalRoutes(totalRoutes)
352363
.totalServices(totalServices)
353364
.build()))
@@ -361,6 +372,7 @@ private static void requestUpdateOrganizationQuota(CloudFoundryClient cloudFound
361372
.memoryLimit(memoryLimit)
362373
.name(name)
363374
.nonBasicServicesAllowed(nonBasicServicesAllowed)
375+
.totalReservedRoutePorts(0)
364376
.totalPrivateDomains(-1)
365377
.totalRoutes(totalRoutes)
366378
.totalServices(totalServices)

0 commit comments

Comments
 (0)