Search in sources :

Example 26 with Cluster

use of com.cloud.org.Cluster in project cloudstack by apache.

the class CiscoNexusVSMElement method getCiscoNexusVSMs.

@Override
public List<CiscoNexusVSMDeviceVO> getCiscoNexusVSMs(ListCiscoNexusVSMsCmd cmd) {
    // If clusterId is defined, then it takes precedence, and we will return
    // the VSM associated with this cluster.
    Long clusterId = cmd.getClusterId();
    Long zoneId = cmd.getZoneId();
    List<CiscoNexusVSMDeviceVO> result = new ArrayList<CiscoNexusVSMDeviceVO>();
    if (clusterId != null && clusterId.longValue() != 0) {
        // Find the VSM associated with this clusterId and return a list.
        CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(cmd.getClusterId());
        if (vsm == null) {
            throw new CloudRuntimeException("No Cisco VSM associated with specified Cluster Id");
        }
        // Else, add it to a list and return the list.
        result.add(vsm);
        return result;
    }
    // in the zone, and then for each cluster, pull the VSM and prepare a list.
    if (zoneId != null && zoneId.longValue() != 0) {
        ManagementService ref = _mgr;
        ;
        List<? extends Cluster> clusterList = ref.searchForClusters(zoneId, cmd.getStartIndex(), cmd.getPageSizeVal(), "VMware");
        if (clusterList.size() == 0) {
            throw new CloudRuntimeException("No VMWare clusters found in the specified zone!");
        }
        // Else, iterate through each vmware cluster, pull its VSM if it has one, and add to the list.
        for (Cluster clus : clusterList) {
            CiscoNexusVSMDeviceVO vsm = getCiscoVSMbyClusId(clus.getId());
            if (vsm != null)
                result.add(vsm);
        }
        return result;
    }
    // If neither is defined, we will simply return the entire list of VSMs
    // configured in the management server.
    // TODO: Is this a safe thing to do? Only ROOT admin can invoke this call.
    result = _vsmDao.listAllVSMs();
    return result;
}
Also used : ManagementService(com.cloud.server.ManagementService) CiscoNexusVSMDeviceVO(com.cloud.network.CiscoNexusVSMDeviceVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) Cluster(com.cloud.org.Cluster)

Aggregations

Cluster (com.cloud.org.Cluster)26 ArrayList (java.util.ArrayList)13 HostVO (com.cloud.host.HostVO)8 ServerApiException (org.apache.cloudstack.api.ServerApiException)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)6 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)6 DataCenter (com.cloud.dc.DataCenter)5 Pod (com.cloud.dc.Pod)5 DeployDestination (com.cloud.deploy.DeployDestination)5 DataCenterVO (com.cloud.dc.DataCenterVO)4 DiscoveryException (com.cloud.exception.DiscoveryException)4 ResourceInUseException (com.cloud.exception.ResourceInUseException)4 Host (com.cloud.host.Host)4 StoragePool (com.cloud.storage.StoragePool)4 ClusterResponse (org.apache.cloudstack.api.response.ClusterResponse)4 ClusterResponse (com.cloud.api.response.ClusterResponse)3 ClusterDetailsVO (com.cloud.dc.ClusterDetailsVO)3 ClusterVO (com.cloud.dc.ClusterVO)3 List (java.util.List)3 ServerApiException (com.cloud.api.ServerApiException)2