use of com.cloud.legacymodel.to.StorageFilerTO in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method resizeVolumeOnHypervisor.
@Override
public void resizeVolumeOnHypervisor(final long volumeId, final long newSize, final long destHostId, final String instanceName) {
final String errMsg = "Resize command failed";
try {
Answer answer = null;
final Host destHost = _hostDao.findById(destHostId);
final EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost);
if (ep != null) {
final VolumeVO volume = volDao.findById(volumeId);
final PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
final ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true, instanceName);
answer = ep.sendMessage(resizeCmd);
} else {
throw new CloudRuntimeException("Could not find a remote endpoint to send command to. Check if host or SSVM is down.");
}
if (answer == null || !answer.getResult()) {
throw new CloudRuntimeException(answer != null ? answer.getDetails() : errMsg);
}
} catch (final Exception e) {
throw new CloudRuntimeException(errMsg, e);
}
}
use of com.cloud.legacymodel.to.StorageFilerTO in project cosmic by MissionCriticalCloud.
the class AbstractHyperVisorStorageMotionStrategy method buildVolumeMapping.
protected List<Pair<VolumeTO, StorageFilerTO>> buildVolumeMapping(final Map<VolumeInfo, DataStore> volumeToPool) {
final List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<>();
for (final Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
final VolumeInfo volume = entry.getKey();
final StoragePool storagePool = storagePoolDao.findById(volume.getPoolId());
final VolumeTO volumeTo = new VolumeTO(volume.getId(), volume.getVolumeType(), storagePool.getPoolType(), storagePool.getUuid(), volume.getName(), volume.getFolder(), volume.getPath(), volume.getSize(), volume.getChainInfo(), volume.getFormat(), volume.getProvisioningType());
final StorageFilerTO filerTo = new StorageFilerTO((StoragePool) entry.getValue());
volumeToFilerto.add(new Pair<>(volumeTo, filerTo));
}
return volumeToFilerto;
}
use of com.cloud.legacymodel.to.StorageFilerTO in project cosmic by MissionCriticalCloud.
the class CitrixCreateCommandWrapper method execute.
@Override
public Answer execute(final CreateCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final StorageFilerTO pool = command.getPool();
final DiskProfile dskch = command.getDiskCharacteristics();
VDI vdi = null;
try {
final SR poolSr = citrixResourceBase.getStorageRepository(conn, pool.getUuid());
if (command.getTemplateUrl() != null) {
VDI tmpltvdi = null;
tmpltvdi = citrixResourceBase.getVDIbyUuid(conn, command.getTemplateUrl());
vdi = tmpltvdi.createClone(conn, new HashMap<>());
vdi.setNameLabel(conn, dskch.getName());
} else {
final VDI.Record vdir = new VDI.Record();
vdir.nameLabel = dskch.getName();
vdir.SR = poolSr;
vdir.type = Types.VdiType.USER;
vdir.virtualSize = dskch.getSize();
vdi = VDI.create(conn, vdir);
}
final VDI.Record vdir;
vdir = vdi.getRecord(conn);
s_logger.debug("Succesfully created VDI for " + command + ". Uuid = " + vdir.uuid);
final VolumeTO vol = new VolumeTO(command.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), vdir.nameLabel, pool.getPath(), vdir.uuid, vdir.virtualSize, null, null, null);
return new CreateAnswer(command, vol);
} catch (final Exception e) {
s_logger.warn("Unable to create volume; Pool=" + pool + "; Disk: " + dskch, e);
return new CreateAnswer(command, e);
}
}
use of com.cloud.legacymodel.to.StorageFilerTO in project cosmic by MissionCriticalCloud.
the class CitrixCreateStoragePoolCommandWrapper method execute.
@Override
public Answer execute(final CreateStoragePoolCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final StorageFilerTO pool = command.getPool();
try {
if (pool.getType() == StoragePoolType.NetworkFilesystem) {
citrixResourceBase.getNfsSR(conn, Long.toString(pool.getId()), pool.getUuid(), pool.getHost(), pool.getPath(), pool.toString());
} else if (pool.getType() == StoragePoolType.IscsiLUN) {
citrixResourceBase.getIscsiSR(conn, pool.getUuid(), pool.getHost(), pool.getPath(), null, null, false);
} else if (pool.getType() == StoragePoolType.PreSetup) {
} else {
return new Answer(command, false, "The pool type: " + pool.getType().name() + " is not supported.");
}
return new Answer(command, true, "success");
} catch (final Exception e) {
final String msg = "Catch Exception " + e.getClass().getName() + ", create StoragePool failed due to " + e.toString() + " on host:" + citrixResourceBase.getHost().getUuid() + " pool: " + pool.getHost() + pool.getPath();
s_logger.warn(msg, e);
return new Answer(command, false, msg);
}
}
use of com.cloud.legacymodel.to.StorageFilerTO in project cosmic by MissionCriticalCloud.
the class CitrixDeleteStoragePoolCommandWrapper method execute.
@Override
public Answer execute(final DeleteStoragePoolCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final StorageFilerTO poolTO = command.getPool();
try {
final SR sr = citrixResourceBase.getStorageRepository(conn, poolTO.getUuid());
citrixResourceBase.removeSR(conn, sr);
final Answer answer = new Answer(command, true, "success");
return answer;
} catch (final Exception e) {
final String msg = "DeleteStoragePoolCommand XenAPIException:" + e.getMessage() + " host:" + citrixResourceBase.getHost().getUuid() + " pool: " + poolTO.getHost() + poolTO.getPath();
s_logger.warn(msg, e);
return new Answer(command, false, msg);
}
}
Aggregations