Search in sources :

Example 56 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListGlobalLoadBalancerRuleCmd method execute.

@Override
public void execute() {
    List<GlobalLoadBalancerRule> globalLoadBalancers = _gslbService.listGlobalLoadBalancerRule(this);
    ListResponse<GlobalLoadBalancerResponse> gslbRuleResponse = new ListResponse<GlobalLoadBalancerResponse>();
    List<GlobalLoadBalancerResponse> gslbResponses = new ArrayList<GlobalLoadBalancerResponse>();
    if (globalLoadBalancers != null) {
        for (GlobalLoadBalancerRule gslbRule : globalLoadBalancers) {
            GlobalLoadBalancerResponse gslbResponse = _responseGenerator.createGlobalLoadBalancerResponse(gslbRule);
            gslbResponse.setObjectName("globalloadbalancerrule");
            gslbResponses.add(gslbResponse);
        }
    }
    gslbRuleResponse.setResponses(gslbResponses);
    gslbRuleResponse.setResponseName(getCommandName());
    this.setResponseObject(gslbRuleResponse);
}
Also used : GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule) ArrayList(java.util.ArrayList)

Example 57 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListHypervisorsCmd method execute.

@Override
public void execute() {
    List<String> result = _mgr.getHypervisors(getZoneId());
    ListResponse<HypervisorResponse> response = new ListResponse<HypervisorResponse>();
    ArrayList<HypervisorResponse> responses = new ArrayList<HypervisorResponse>();
    if (result != null) {
        for (String hypervisor : result) {
            HypervisorResponse hypervisorResponse = new HypervisorResponse();
            hypervisorResponse.setName(hypervisor);
            hypervisorResponse.setObjectName("hypervisor");
            responses.add(hypervisorResponse);
        }
    }
    response.setResponses(responses);
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : HypervisorResponse(org.apache.cloudstack.api.response.HypervisorResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList)

Example 58 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListSnapshotsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends Snapshot>, Integer> result = _snapshotService.listSnapshots(this);
    ListResponse<SnapshotResponse> response = new ListResponse<SnapshotResponse>();
    List<SnapshotResponse> snapshotResponses = new ArrayList<SnapshotResponse>();
    for (Snapshot snapshot : result.first()) {
        SnapshotResponse snapshotResponse = _responseGenerator.createSnapshotResponse(snapshot);
        snapshotResponse.setObjectName("snapshot");
        snapshotResponses.add(snapshotResponse);
    }
    response.setResponses(snapshotResponses, result.second());
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : Snapshot(com.cloud.storage.Snapshot) ListResponse(org.apache.cloudstack.api.response.ListResponse) SnapshotResponse(org.apache.cloudstack.api.response.SnapshotResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 59 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class ListSnapshotPoliciesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends SnapshotPolicy>, Integer> result = _snapshotService.listPoliciesforVolume(this);
    ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
    List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
    for (SnapshotPolicy policy : result.first()) {
        SnapshotPolicyResponse policyResponse = _responseGenerator.createSnapshotPolicyResponse(policy);
        policyResponse.setObjectName("snapshotpolicy");
        policyResponses.add(policyResponse);
    }
    response.setResponses(policyResponses, result.second());
    response.setResponseName(getCommandName());
    this.setResponseObject(response);
}
Also used : SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 60 with ListResponse

use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.

the class LDAPConfigCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
    if (getListAll()) {
        // return the existing conf
        LdapListConfigurationCmd listConfigurationCmd = new LdapListConfigurationCmd(_ldapManager);
        Pair<List<? extends LdapConfigurationVO>, Integer> result = _ldapManager.listConfigurations(listConfigurationCmd);
        ListResponse<LDAPConfigResponse> response = new ListResponse<LDAPConfigResponse>();
        List<LDAPConfigResponse> responses = new ArrayList<LDAPConfigResponse>();
        if (result.second() > 0) {
            boolean useSSlConfig = _ldapConfiguration.getSSLStatus(null);
            String searchBaseConfig = _ldapConfiguration.getBaseDn(null);
            String bindDnConfig = _ldapConfiguration.getBindPrincipal(null);
            for (LdapConfigurationVO ldapConfigurationVO : result.first()) {
                responses.add(createLDAPConfigResponse(ldapConfigurationVO.getHostname(), ldapConfigurationVO.getPort(), useSSlConfig, null, searchBaseConfig, bindDnConfig));
            }
        }
        response.setResponses(responses);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else if (getHostname() == null || getPort() == null) {
        throw new InvalidParameterValueException("You need to provide hostname, port to configure your LDAP server");
    } else {
        boolean result = updateLDAP();
        if (result) {
            LDAPConfigResponse lr = createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN());
            lr.setResponseName(getCommandName());
            setResponseObject(lr);
        }
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) LdapConfigurationVO(org.apache.cloudstack.ldap.LdapConfigurationVO) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LDAPConfigResponse(org.apache.cloudstack.api.response.LDAPConfigResponse) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ListResponse (org.apache.cloudstack.api.response.ListResponse)177 ArrayList (java.util.ArrayList)160 List (java.util.List)70 ServerApiException (org.apache.cloudstack.api.ServerApiException)49 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)32 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)23 Account (com.cloud.user.Account)10 Network (com.cloud.network.Network)9 Host (com.cloud.host.Host)8 NetworkResponse (org.apache.cloudstack.api.response.NetworkResponse)8 Test (org.junit.Test)8 DedicatedResources (com.cloud.dc.DedicatedResources)7 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)7 TemplateResponse (org.apache.cloudstack.api.response.TemplateResponse)7 Domain (com.cloud.domain.Domain)6 VirtualMachineTemplate (com.cloud.template.VirtualMachineTemplate)5 ApiDiscoveryResponse (org.apache.cloudstack.api.response.ApiDiscoveryResponse)5 DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)4 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)4 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4