use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class AddHostCmd method execute.
@Override
public void execute() {
try {
List<? extends Host> result = _resourceService.discoverHosts(this);
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
if (result != null && result.size() > 0) {
for (Host host : result) {
HostResponse hostResponse = _responseGenerator.createHostResponse(host);
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListEventTypesCmd method execute.
@Override
public void execute() {
String[] result = _mgr.listEventTypes();
ListResponse<EventTypeResponse> response = new ListResponse<EventTypeResponse>();
ArrayList<EventTypeResponse> responses = new ArrayList<EventTypeResponse>();
if (result != null) {
for (String eventType : result) {
EventTypeResponse eventTypeResponse = new EventTypeResponse();
eventTypeResponse.setName(eventType);
eventTypeResponse.setObjectName("eventtype");
responses.add(eventTypeResponse);
}
}
response.setResponses(responses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListEventsCmd method execute.
@Override
public void execute() {
List<? extends Event> result = _mgr.searchForEvents(this);
ListResponse<EventResponse> response = new ListResponse<EventResponse>();
List<EventResponse> eventResponses = new ArrayList<EventResponse>();
for (Event event : result) {
eventResponses.add(_responseGenerator.createEventResponse(event));
}
response.setResponses(eventResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListGuestOsCategoriesCmd method execute.
@Override
public void execute() {
List<? extends GuestOsCategory> result = _mgr.listGuestOSCategoriesByCriteria(this);
ListResponse<GuestOSCategoryResponse> response = new ListResponse<GuestOSCategoryResponse>();
List<GuestOSCategoryResponse> osCatResponses = new ArrayList<GuestOSCategoryResponse>();
for (GuestOsCategory osCategory : result) {
GuestOSCategoryResponse categoryResponse = new GuestOSCategoryResponse();
categoryResponse.setId(osCategory.getId());
categoryResponse.setName(osCategory.getName());
categoryResponse.setObjectName("oscategory");
osCatResponses.add(categoryResponse);
}
response.setResponses(osCatResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project CloudStack-archive by CloudStack-extras.
the class ListGuestOsCmd method execute.
@Override
public void execute() {
List<? extends GuestOS> result = _mgr.listGuestOSByCriteria(this);
ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
for (GuestOS guestOS : result) {
GuestOSResponse guestOSResponse = new GuestOSResponse();
guestOSResponse.setDescription(guestOS.getDisplayName());
guestOSResponse.setId(guestOS.getId());
guestOSResponse.setOsCategoryId(guestOS.getCategoryId());
guestOSResponse.setObjectName("ostype");
osResponses.add(guestOSResponse);
}
response.setResponses(osResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
Aggregations