Search in sources :

Example 1 with ZoneResponse

use of com.cloud.api.response.ZoneResponse in project CloudStack-archive by CloudStack-extras.

the class ListZonesByCmd method execute.

@Override
public void execute() {
    List<? extends DataCenter> dataCenters = _mgr.listDataCenters(this);
    ListResponse<ZoneResponse> response = new ListResponse<ZoneResponse>();
    List<ZoneResponse> zoneResponses = new ArrayList<ZoneResponse>();
    for (DataCenter dataCenter : dataCenters) {
        ZoneResponse zoneResponse = _responseGenerator.createZoneResponse(dataCenter, showCapacities);
        zoneResponse.setObjectName("zone");
        zoneResponses.add(zoneResponse);
    }
    response.setResponses(zoneResponses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : ZoneResponse(com.cloud.api.response.ZoneResponse) DataCenter(com.cloud.dc.DataCenter) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 2 with ZoneResponse

use of com.cloud.api.response.ZoneResponse in project CloudStack-archive by CloudStack-extras.

the class CreateZoneCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Zone Name: " + getZoneName());
    DataCenter result = _configService.createZone(this);
    if (result != null) {
        ZoneResponse response = _responseGenerator.createZoneResponse(result, false);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a zone");
    }
}
Also used : ZoneResponse(com.cloud.api.response.ZoneResponse) DataCenter(com.cloud.dc.DataCenter) ServerApiException(com.cloud.api.ServerApiException)

Example 3 with ZoneResponse

use of com.cloud.api.response.ZoneResponse in project CloudStack-archive by CloudStack-extras.

the class UpdateZoneCmd method execute.

@Override
public void execute() {
    UserContext.current().setEventDetails("Zone Id: " + getId());
    DataCenter result = _configService.editZone(this);
    if (result != null) {
        ZoneResponse response = _responseGenerator.createZoneResponse(result, false);
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update zone; internal error.");
    }
}
Also used : ZoneResponse(com.cloud.api.response.ZoneResponse) DataCenter(com.cloud.dc.DataCenter) ServerApiException(com.cloud.api.ServerApiException)

Aggregations

ZoneResponse (com.cloud.api.response.ZoneResponse)3 DataCenter (com.cloud.dc.DataCenter)3 ServerApiException (com.cloud.api.ServerApiException)2 ListResponse (com.cloud.api.response.ListResponse)1 ArrayList (java.util.ArrayList)1