Skip to content

Commit fdb9a71

Browse files
committed
fix api response
1 parent 294696d commit fdb9a71

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

api/src/main/java/com/cloud/network/as/AutoScaleService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public interface AutoScaleService {
7070

7171
Counter createCounter(CreateCounterCmd cmd);
7272

73+
Counter getCounter(long counterId);
74+
7375
boolean deleteCounter(long counterId) throws ResourceInUseException;
7476

7577
List<? extends Counter> listCounters(ListCountersCmd cmd);

api/src/main/java/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.cloudstack.api.command.admin.autoscale;
1919

20+
import org.apache.cloudstack.context.CallContext;
2021
import org.apache.log4j.Logger;
2122

2223
import org.apache.cloudstack.api.APICommand;
@@ -91,16 +92,18 @@ public void create() {
9192
if (ctr != null) {
9293
this.setEntityId(ctr.getId());
9394
this.setEntityUuid(ctr.getUuid());
94-
CounterResponse response = _responseGenerator.createCounterResponse(ctr);
95-
response.setResponseName(getCommandName());
96-
this.setResponseObject(response);
9795
} else {
9896
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
9997
}
10098
}
10199

102100
@Override
103101
public void execute() {
102+
CallContext.current().setEventDetails("Guest OS Id: " + getEntityId());
103+
Counter ctr = _autoScaleService.getCounter(getEntityId());
104+
CounterResponse response = _responseGenerator.createCounterResponse(ctr);
105+
response.setResponseName(getCommandName());
106+
this.setResponseObject(response);
104107
}
105108

106109
@Override

server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,12 @@ public Counter createCounter(CreateCounterCmd cmd) {
14741474
return counter;
14751475
}
14761476

1477+
@Override
1478+
@ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription = "Creating a counter", async = true)
1479+
public Counter getCounter(long counterId) {
1480+
return counterDao.findById(counterId);
1481+
}
1482+
14771483
@Override
14781484
@ActionEvent(eventType = EventTypes.EVENT_CONDITION_CREATE, eventDescription = "Condition", create = true)
14791485
public Condition createCondition(CreateConditionCmd cmd) {

0 commit comments

Comments
 (0)