@Override public Answer execute(final ResizeVolumeCommand command, final CitrixResourceBase citrixResourceBase) { Connection conn = citrixResourceBase.getConnection(); String volId = command.getPath(); long newSize = command.getNewSize(); try { if (command.getCurrentSize() >= newSize) { s_logger.info("No need to resize volume: " + volId +", current size " + command.getCurrentSize() + " is same as new size " + newSize); return new ResizeVolumeAnswer(command, true, "success", newSize); } if (command.isManaged()) { resizeSr(conn, command); } VDI vdi = citrixResourceBase.getVDIbyUuid(conn, volId); vdi.resize(conn, newSize); return new ResizeVolumeAnswer(command, true, "success", newSize); } catch (Exception ex) { s_logger.warn("Unable to resize volume", ex); String error = "Failed to resize volume: " + ex; return new ResizeVolumeAnswer(command, false, error); } }
String iScsiName = command.get_iScsiName();
@Override public Answer execute(final ResizeVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { final String volid = command.getPath(); final long newSize = command.getNewSize(); final long currentSize = command.getCurrentSize(); final String vmInstanceName = command.getInstanceName(); final boolean shrinkOk = command.getShrinkOk(); final StorageFilerTO spool = command.getPool(); final String notifyOnlyType = "NOTIFYONLY";
@Override public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { VolumeObject vol = (VolumeObject) data; StoragePool pool = (StoragePool) data.getDataStore(); ResizeVolumePayload resizeParameter = (ResizeVolumePayload) vol.getpayload(); ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(), resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName); CreateCmdResult result = new CreateCmdResult(null, null); try { ResizeVolumeAnswer answer = (ResizeVolumeAnswer) storageMgr.sendToPool(pool, resizeParameter.hosts, resizeCmd); if (answer != null && answer.getResult()) { long finalSize = answer.getNewSize(); s_logger.debug("Resize: volume started at size " + vol.getSize() + " and ended at size " + finalSize); vol.setSize(finalSize); vol.update(); } else if (answer != null) { result.setResult(answer.getDetails()); } else { s_logger.debug("return a null answer, mark it as failed for unknown reason"); result.setResult("return a null answer, mark it as failed for unknown reason"); } } catch (Exception e) { s_logger.debug("sending resize command failed", e); result.setResult(e.toString()); } callback.complete(result); }
@Override public void resizeVolumeOnHypervisor(long volumeId, long newSize, long destHostId, String instanceName) { final String errMsg = "Resize command failed"; try { Answer answer = null; Host destHost = _hostDao.findById(destHostId); EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost); if (ep != null) { VolumeVO volume = volDao.findById(volumeId); PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId()); ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true, instanceName, primaryDataStore.isManaged(), volume.get_iScsiName()); 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 (Exception e) { throw new CloudRuntimeException(errMsg, e); } }