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");
}
}
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");
}
}
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");
}
}
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");
}
}
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;
}
Aggregations