Search in sources :

Example 96 with ListResponse

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());
    }
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ServerApiException(com.cloud.api.ServerApiException) HostResponse(com.cloud.api.response.HostResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) DiscoveryException(com.cloud.exception.DiscoveryException)

Example 97 with ListResponse

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);
}
Also used : EventTypeResponse(com.cloud.api.response.EventTypeResponse) ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 98 with ListResponse

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);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) EventResponse(com.cloud.api.response.EventResponse) ArrayList(java.util.ArrayList) Event(com.cloud.event.Event)

Example 99 with ListResponse

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);
}
Also used : GuestOSCategoryResponse(com.cloud.api.response.GuestOSCategoryResponse) ListResponse(com.cloud.api.response.ListResponse) GuestOsCategory(com.cloud.storage.GuestOsCategory) ArrayList(java.util.ArrayList)

Example 100 with ListResponse

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);
}
Also used : ListResponse(com.cloud.api.response.ListResponse) ArrayList(java.util.ArrayList) GuestOS(com.cloud.storage.GuestOS) GuestOSResponse(com.cloud.api.response.GuestOSResponse)

Aggregations

ListResponse (com.cloud.api.response.ListResponse)156 ArrayList (java.util.ArrayList)139 List (java.util.List)60 ServerApiException (com.cloud.api.ServerApiException)30 TemplateResponse (com.cloud.api.response.TemplateResponse)13 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)11 ResponseView (com.cloud.api.ResponseObject.ResponseView)10 Network (com.cloud.network.Network)9 DedicatedResources (com.cloud.dc.DedicatedResources)8 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)8 DomainResponse (com.cloud.api.response.DomainResponse)7 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)7 Domain (com.cloud.domain.Domain)7 VirtualMachine (com.cloud.vm.VirtualMachine)7 StoragePoolResponse (com.cloud.api.response.StoragePoolResponse)6 UserResponse (com.cloud.api.response.UserResponse)6 UserVmResponse (com.cloud.api.response.UserVmResponse)6 Host (com.cloud.host.Host)6 AccountResponse (com.cloud.api.response.AccountResponse)5 HostResponse (com.cloud.api.response.HostResponse)5