use of com.cloud.storage.Volume in project CloudStack-archive by CloudStack-extras.
the class MigrateVolumeCmd method execute.
@Override
public void execute() {
Volume result;
try {
result = _storageService.migrateVolume(getVolumeId(), getStoragePoolId());
if (result != null) {
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
} catch (ConcurrentOperationException e) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate volume: ");
}
}
use of com.cloud.storage.Volume in project CloudStack-archive by CloudStack-extras.
the class DeployDestination method toString.
@Override
public String toString() {
Long dcId = null;
Long podId = null;
Long clusterId = null;
Long hostId = null;
if (_dc != null) {
dcId = _dc.getId();
}
if (_pod != null) {
podId = _pod.getId();
}
if (_cluster != null) {
clusterId = _cluster.getId();
}
if (_host != null) {
hostId = _host.getId();
}
StringBuilder destination = new StringBuilder("Dest[Zone(Id)-Pod(Id)-Cluster(Id)-Host(Id)-Storage(Volume(Id|Type-->Pool(Id))] : Dest[");
destination.append("Zone(").append(dcId).append(")").append("-");
destination.append("Pod(").append(podId).append(")").append("-");
destination.append("Cluster(").append(clusterId).append(")").append("-");
destination.append("Host(").append(hostId).append(")").append("-");
destination.append("Storage(");
if (_storage != null) {
String storageStr = "";
for (Volume vol : _storage.keySet()) {
if (!storageStr.equals("")) {
storageStr = storageStr + ", ";
}
storageStr = storageStr + "Volume(" + vol.getId() + "|" + vol.getVolumeType().name() + "-->Pool(" + _storage.get(vol).getId() + ")";
}
destination.append(storageStr);
}
return destination.append(")]").toString();
}
use of com.cloud.storage.Volume in project CloudStack-archive by CloudStack-extras.
the class ListVolumesCmd method execute.
@Override
public void execute() {
List<? extends Volume> volumes = _storageService.searchForVolumes(this);
ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
List<VolumeResponse> volResponses = new ArrayList<VolumeResponse>();
for (Volume volume : volumes) {
VolumeResponse volResponse = _responseGenerator.createVolumeResponse(volume);
volResponse.setObjectName("volume");
volResponses.add(volResponse);
}
response.setResponses(volResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.storage.Volume in project CloudStack-archive by CloudStack-extras.
the class CreateSnapshotCmd method getEntityOwnerId.
@Override
public long getEntityOwnerId() {
Volume volume = _entityMgr.findById(Volume.class, getVolumeId());
if (volume == null) {
throw new InvalidParameterValueException("Unable to find volume by id=" + volumeId);
}
Account account = _accountService.getAccount(volume.getAccountId());
//Can create templates for enabled projects/accounts only
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
Project project = _projectService.findByProjectAccountId(volume.getAccountId());
if (project.getState() != Project.State.Active) {
throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
}
} else if (account.getState() == Account.State.disabled) {
throw new PermissionDeniedException("The owner of template is disabled: " + account);
}
return volume.getAccountId();
}
use of com.cloud.storage.Volume in project CloudStack-archive by CloudStack-extras.
the class CreateSnapshotPolicyCmd method getEntityOwnerId.
@Override
public long getEntityOwnerId() {
Volume volume = _entityMgr.findById(Volume.class, getVolumeId());
if (volume == null) {
throw new InvalidParameterValueException("Unable to find volume by id=" + volumeId);
}
Account account = _accountService.getAccount(volume.getAccountId());
//Can create templates for enabled projects/accounts only
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
Project project = _projectService.findByProjectAccountId(volume.getAccountId());
if (project.getState() != Project.State.Active) {
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
ex.addProxyObject(project, project.getId(), "projectId");
throw ex;
}
} else if (account.getState() == Account.State.disabled) {
throw new PermissionDeniedException("The owner of template is disabled: " + account);
}
return volume.getAccountId();
}
Aggregations