Skip to content

Commit d99b1b9

Browse files
committed
Merge branch '4.18' into 4.19
2 parents b82ea3d + 223a9b8 commit d99b1b9

File tree

15 files changed

+98
-11
lines changed

15 files changed

+98
-11
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.cloudstack.ha.HAConfig;
3232
import org.apache.cloudstack.storage.object.Bucket;
3333
import org.apache.cloudstack.storage.object.ObjectStore;
34+
import org.apache.cloudstack.quota.QuotaTariff;
3435
import org.apache.cloudstack.usage.Usage;
3536
import org.apache.cloudstack.vm.schedule.VMSchedule;
3637

@@ -729,6 +730,11 @@ public class EventTypes {
729730
public static final String EVENT_BUCKET_DELETE = "BUCKET.DELETE";
730731
public static final String EVENT_BUCKET_UPDATE = "BUCKET.UPDATE";
731732

733+
// Quota
734+
public static final String EVENT_QUOTA_TARIFF_CREATE = "QUOTA.TARIFF.CREATE";
735+
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
736+
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";
737+
732738
static {
733739

734740
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@@ -1178,6 +1184,11 @@ public class EventTypes {
11781184
entityEventDetails.put(EVENT_BUCKET_CREATE, Bucket.class);
11791185
entityEventDetails.put(EVENT_BUCKET_UPDATE, Bucket.class);
11801186
entityEventDetails.put(EVENT_BUCKET_DELETE, Bucket.class);
1187+
1188+
// Quota
1189+
entityEventDetails.put(EVENT_QUOTA_TARIFF_CREATE, QuotaTariff.class);
1190+
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
1191+
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);
11811192
}
11821193

11831194
public static String getEntityForEvent(String eventName) {

api/src/main/java/org/apache/cloudstack/api/ApiCommandResourceType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public enum ApiCommandResourceType {
8181
ManagementServer(org.apache.cloudstack.management.ManagementServerHost.class),
8282
ObjectStore(org.apache.cloudstack.storage.object.ObjectStore.class),
8383
Bucket(org.apache.cloudstack.storage.object.Bucket.class);
84+
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class);
8485

8586
private final Class<?> clazz;
8687

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.quota;
19+
20+
import org.apache.cloudstack.api.Identity;
21+
import org.apache.cloudstack.api.InternalIdentity;
22+
23+
public interface QuotaTariff extends InternalIdentity, Identity {
24+
25+
}

engine/schema/src/main/java/com/cloud/network/security/dao/SecurityGroupVMMapDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public List<SecurityGroupVMMapVO> listBySecurityGroup(long securityGroupId, Stat
131131
SearchCriteria<SecurityGroupVMMapVO> sc = ListBySecurityGroupAndStates.create();
132132
sc.setParameters("securityGroupId", securityGroupId);
133133
sc.setParameters("states", (Object[])vmStates);
134-
return listBy(sc, null, true);
134+
return listBy(sc, null);
135135
}
136136

137137
@Override

framework/db/src/main/java/com/cloud/utils/db/GenericDaoBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,9 +1496,9 @@ public T persist(final T entity) {
14961496
} else {
14971497
_idField.set(entity, id);
14981498
}
1499-
} else {
1500-
id = (ID)_idField.get(entity);
15011499
}
1500+
1501+
id = (ID)_idField.get(entity);
15021502
}
15031503
} catch (final IllegalAccessException e) {
15041504
throw new CloudRuntimeException("Yikes! ", e);

framework/quota/src/main/java/org/apache/cloudstack/quota/dao/QuotaTariffDaoImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,14 @@ public QuotaTariffVO findByUuid(String uuid) {
231231

232232
return quotaTariffs.get(0);
233233
}
234+
235+
@Override
236+
public QuotaTariffVO findByIdIncludingRemoved(Long id) {
237+
return Transaction.execute(TransactionLegacy.USAGE_DB, (TransactionCallback<QuotaTariffVO>) status -> super.findByIdIncludingRemoved(id));
238+
}
239+
240+
@Override
241+
public QuotaTariffVO findByUuidIncludingRemoved(String uuid) {
242+
return Transaction.execute(TransactionLegacy.USAGE_DB, (TransactionCallback<QuotaTariffVO>) status -> super.findByUuidIncludingRemoved(uuid));
243+
}
234244
}

framework/quota/src/main/java/org/apache/cloudstack/quota/vo/QuotaTariffVO.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//under the License.
1717
package org.apache.cloudstack.quota.vo;
1818

19-
import org.apache.cloudstack.api.InternalIdentity;
19+
import org.apache.cloudstack.quota.QuotaTariff;
2020
import org.apache.cloudstack.quota.constant.QuotaTypes;
2121
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
2222

@@ -37,7 +37,7 @@
3737

3838
@Entity
3939
@Table(name = "quota_tariff")
40-
public class QuotaTariffVO implements InternalIdentity {
40+
public class QuotaTariffVO implements QuotaTariff {
4141
private static final long serialVersionUID = -7117933766387653203L;
4242

4343
@Id
@@ -240,6 +240,7 @@ public String getDescription() {
240240
return description;
241241
}
242242

243+
@Override
243244
public String getUuid() {
244245
return uuid;
245246
}

plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaTariffCreateCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020

2121
import org.apache.cloudstack.acl.RoleType;
2222
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiCommandResourceType;
2324
import org.apache.cloudstack.api.ApiConstants;
2425
import org.apache.cloudstack.api.ApiErrorCode;
2526
import org.apache.cloudstack.api.BaseCmd;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.ServerApiException;
2829
import org.apache.cloudstack.api.response.QuotaResponseBuilder;
2930
import org.apache.cloudstack.api.response.QuotaTariffResponse;
31+
import org.apache.cloudstack.context.CallContext;
3032
import org.apache.cloudstack.quota.vo.QuotaTariffVO;
3133
import org.apache.log4j.Logger;
3234

@@ -70,6 +72,7 @@ public class QuotaTariffCreateCmd extends BaseCmd {
7072

7173
@Override
7274
public void execute() {
75+
CallContext.current().setEventDetails(String.format("Tariff: %s, description: %s, value: %s", getName(), getDescription(), getValue()));
7376
QuotaTariffVO result = responseBuilder.createQuotaTariff(this);
7477

7578
if (result == null) {
@@ -134,4 +137,8 @@ public void setEndDate(Date endDate) {
134137
this.endDate = endDate;
135138
}
136139

140+
@Override
141+
public ApiCommandResourceType getApiResourceType() {
142+
return ApiCommandResourceType.QuotaTariff;
143+
}
137144
}

plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaTariffDeleteCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
import org.apache.cloudstack.acl.RoleType;
2222
import org.apache.cloudstack.api.APICommand;
2323
import org.apache.cloudstack.api.ApiArgValidator;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.BaseCmd;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.response.QuotaResponseBuilder;
2829
import org.apache.cloudstack.api.response.QuotaTariffResponse;
2930
import org.apache.cloudstack.api.response.SuccessResponse;
31+
import org.apache.cloudstack.context.CallContext;
3032
import org.apache.log4j.Logger;
3133

3234
import javax.inject.Inject;
@@ -49,6 +51,7 @@ public String getId() {
4951

5052
@Override
5153
public void execute() {
54+
CallContext.current().setEventDetails(String.format("Tariff id: %s", getId()));
5255
boolean result = responseBuilder.deleteQuotaTariff(getId());
5356
SuccessResponse response = new SuccessResponse(getCommandName());
5457
response.setSuccess(result);
@@ -60,4 +63,8 @@ public long getEntityOwnerId() {
6063
return Account.ACCOUNT_ID_SYSTEM;
6164
}
6265

66+
@Override
67+
public ApiCommandResourceType getApiResourceType() {
68+
return ApiCommandResourceType.QuotaTariff;
69+
}
6370
}

plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020

2121
import org.apache.cloudstack.acl.RoleType;
2222
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiCommandResourceType;
2324
import org.apache.cloudstack.api.ApiConstants;
2425
import org.apache.cloudstack.api.ApiErrorCode;
2526
import org.apache.cloudstack.api.BaseCmd;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.ServerApiException;
2829
import org.apache.cloudstack.api.response.QuotaResponseBuilder;
2930
import org.apache.cloudstack.api.response.QuotaTariffResponse;
31+
import org.apache.cloudstack.context.CallContext;
3032
import org.apache.cloudstack.quota.vo.QuotaTariffVO;
3133
import org.apache.log4j.Logger;
3234

@@ -111,6 +113,7 @@ public QuotaTariffUpdateCmd() {
111113

112114
@Override
113115
public void execute() {
116+
CallContext.current().setEventDetails(String.format("Tariff: %s, description: %s, value: %s", getName(), getDescription(), getValue()));
114117
final QuotaTariffVO result = _responseBuilder.updateQuotaTariffPlan(this);
115118
if (result == null) {
116119
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update quota tariff plan");
@@ -125,4 +128,8 @@ public long getEntityOwnerId() {
125128
return Account.ACCOUNT_ID_SYSTEM;
126129
}
127130

131+
@Override
132+
public ApiCommandResourceType getApiResourceType() {
133+
return ApiCommandResourceType.QuotaTariff;
134+
}
128135
}

0 commit comments

Comments
 (0)