Search in sources :

Example 1 with DedicatedResourceVO

use of com.cloud.dc.DedicatedResourceVO in project cloudstack by apache.

the class ListDedicatedClustersCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedClusters(this);
    ListResponse<DedicateClusterResponse> response = new ListResponse<DedicateClusterResponse>();
    List<DedicateClusterResponse> Responses = new ArrayList<DedicateClusterResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateClusterResponse clusterResponse = dedicatedService.createDedicateClusterResponse(resource);
            Responses.add(clusterResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated clusters");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) DedicateClusterResponse(org.apache.cloudstack.api.response.DedicateClusterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 2 with DedicatedResourceVO

use of com.cloud.dc.DedicatedResourceVO in project cloudstack by apache.

the class ListDedicatedHostsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
    ListResponse<DedicateHostResponse> response = new ListResponse<DedicateHostResponse>();
    List<DedicateHostResponse> Responses = new ArrayList<DedicateHostResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
            Responses.add(hostResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
    }
}
Also used : DedicateHostResponse(org.apache.cloudstack.api.response.DedicateHostResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 3 with DedicatedResourceVO

use of com.cloud.dc.DedicatedResourceVO in project cloudstack by apache.

the class ListDedicatedPodsCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
    ListResponse<DedicatePodResponse> response = new ListResponse<DedicatePodResponse>();
    List<DedicatePodResponse> Responses = new ArrayList<DedicatePodResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
            Responses.add(podresponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatePodResponse(org.apache.cloudstack.api.response.DedicatePodResponse) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 4 with DedicatedResourceVO

use of com.cloud.dc.DedicatedResourceVO in project cloudstack by apache.

the class ListDedicatedZonesCmd method execute.

@Override
public void execute() {
    Pair<List<? extends DedicatedResourceVO>, Integer> result = _dedicatedservice.listDedicatedZones(this);
    ListResponse<DedicateZoneResponse> response = new ListResponse<DedicateZoneResponse>();
    List<DedicateZoneResponse> Responses = new ArrayList<DedicateZoneResponse>();
    if (result != null) {
        for (DedicatedResources resource : result.first()) {
            DedicateZoneResponse zoneResponse = _dedicatedservice.createDedicateZoneResponse(resource);
            Responses.add(zoneResponse);
        }
        response.setResponses(Responses, result.second());
        response.setResponseName(getCommandName());
        this.setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated zones");
    }
}
Also used : ListResponse(org.apache.cloudstack.api.response.ListResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) DedicatedResources(com.cloud.dc.DedicatedResources) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DedicateZoneResponse(org.apache.cloudstack.api.response.DedicateZoneResponse) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO)

Example 5 with DedicatedResourceVO

use of com.cloud.dc.DedicatedResourceVO in project cloudstack by apache.

the class ConfigurationManagerImpl method deletePod.

@Override
@DB
public boolean deletePod(final DeletePodCmd cmd) {
    final Long podId = cmd.getId();
    // Make sure the pod exists
    if (!validPod(podId)) {
        throw new InvalidParameterValueException("A pod with ID: " + podId + " does not exist.");
    }
    checkIfPodIsDeletable(podId);
    final HostPodVO pod = _podDao.findById(podId);
    Transaction.execute(new TransactionCallbackNoReturn() {

        @Override
        public void doInTransactionWithoutResult(final TransactionStatus status) {
            // Delete private ip addresses for the pod if there are any
            final List<DataCenterIpAddressVO> privateIps = _privateIpAddressDao.listByPodIdDcId(podId, pod.getDataCenterId());
            if (!privateIps.isEmpty()) {
                if (!_privateIpAddressDao.deleteIpAddressByPod(podId)) {
                    throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
                }
            }
            // Delete link local ip addresses for the pod
            final List<DataCenterLinkLocalIpAddressVO> localIps = _linkLocalIpAllocDao.listByPodIdDcId(podId, pod.getDataCenterId());
            if (!localIps.isEmpty()) {
                if (!_linkLocalIpAllocDao.deleteIpAddressByPod(podId)) {
                    throw new CloudRuntimeException("Failed to cleanup private ip addresses for pod " + podId);
                }
            }
            // Delete vlans associated with the pod
            final List<? extends Vlan> vlans = _networkModel.listPodVlans(podId);
            if (vlans != null && !vlans.isEmpty()) {
                for (final Vlan vlan : vlans) {
                    _vlanDao.remove(vlan.getId());
                }
            }
            // Delete corresponding capacity records
            _capacityDao.removeBy(null, null, podId, null, null);
            // Delete the pod
            if (!_podDao.remove(podId)) {
                throw new CloudRuntimeException("Failed to delete pod " + podId);
            }
            // remove from dedicated resources
            final DedicatedResourceVO dr = _dedicatedDao.findByPodId(podId);
            if (dr != null) {
                _dedicatedDao.remove(dr.getId());
            }
        }
    });
    return true;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) ArrayList(java.util.ArrayList) List(java.util.List) Vlan(com.cloud.dc.Vlan) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) HostPodVO(com.cloud.dc.HostPodVO) DB(com.cloud.utils.db.DB)

Aggregations

DedicatedResourceVO (com.cloud.dc.DedicatedResourceVO)29 ArrayList (java.util.ArrayList)15 List (java.util.List)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)12 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)11 DB (com.cloud.utils.db.DB)10 TransactionStatus (com.cloud.utils.db.TransactionStatus)9 DataCenterVO (com.cloud.dc.DataCenterVO)8 ClusterVO (com.cloud.dc.ClusterVO)7 HostPodVO (com.cloud.dc.HostPodVO)7 HostVO (com.cloud.host.HostVO)7 ActionEvent (com.cloud.event.ActionEvent)6 ConfigurationException (javax.naming.ConfigurationException)6 AffinityGroup (org.apache.cloudstack.affinity.AffinityGroup)5 DedicatedResources (com.cloud.dc.DedicatedResources)4 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)4 ServerApiException (org.apache.cloudstack.api.ServerApiException)4 ListResponse (org.apache.cloudstack.api.response.ListResponse)4 Test (org.junit.Test)4 Account (com.cloud.user.Account)3