protected Answer execute(CreateObjectCommand cmd) { DataTO data = cmd.getData(); try { if (data.getObjectType() == DataObjectType.VOLUME) { return processor.createVolume(cmd); } else if (data.getObjectType() == DataObjectType.SNAPSHOT) { return processor.createSnapshot(cmd); } return new CreateObjectAnswer("not supported type"); } catch (Exception e) { s_logger.debug("Failed to create object: " + data.getObjectType() + ": " + e.toString()); return new CreateObjectAnswer(e.toString()); } }
SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findByStoreSnapshot(getDataStore().getRole(), getDataStore().getId(), getId()); if (answer instanceof CreateObjectAnswer) { SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CreateObjectAnswer)answer).getData(); snapshotStore.setInstallPath(snapshotTO.getPath()); snapshotStoreDao.update(snapshotStore.getId(), snapshotStore);
} else if (answer instanceof CreateObjectAnswer) { CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); VolumeVO vol = volumeDao.findById(getId()); vol.setPath(newVol.getPath());
public Answer execute(CreateObjectCommand cmd) { LOGGER.debug("execute: "+ cmd.getClass()); DataTO data = cmd.getData(); if (data.getObjectType() == DataObjectType.VOLUME) { return createVolume(cmd); } else if (data.getObjectType() == DataObjectType.SNAPSHOT) { return createSnapshot(cmd); } else if (data.getObjectType() == DataObjectType.TEMPLATE) { LOGGER.debug("Template object creation not supported."); } return new CreateObjectAnswer(data.getObjectType() + " object creation not supported"); } /**
} else if (answer instanceof CreateObjectAnswer) { CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); VolumeVO vol = volumeDao.findById(getId()); vol.setPath(newVol.getPath());
@Override public Answer deleteVolume(DeleteCommand cmd) { LOGGER.debug("execute deleteVolume: "+ cmd.getClass()); DataTO data = cmd.getData(); VolumeObjectTO volume = (VolumeObjectTO) data; try { String poolUuid = data.getDataStore().getUuid(); String uuid = volume.getUuid(); String path = getVirtualDiskPath(uuid, poolUuid); StoragePlugin sp = new StoragePlugin(c); sp.storagePluginDestroy(poolUuid, path); LOGGER.debug("Volume deletion success: " + path); } catch (Ovm3ResourceException e) { LOGGER.info("Volume deletion failed: " + e.toString(), e); return new CreateObjectAnswer(e.toString()); } return new Answer(cmd); }
size, false); if (!fp.getName().equals(file)) { return new CreateObjectAnswer("Filename mismatch: " + fp.getName() + " != " + file); newVol.setSize(fp.getSize()); newVol.setPath(volume.getUuid()); return new CreateObjectAnswer(newVol); } catch (Ovm3ResourceException | URISyntaxException e) { LOGGER.info("Volume creation failed: " + e.toString(), e); return new CreateObjectAnswer(e.toString());
@Override public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback) { CreateCmdResult result = null; try { s_logger.info("taking elastistor volume snapshot"); SnapshotObjectTO snapshotTO = (SnapshotObjectTO)snapshot.getTO(); String volumeid = snapshotTO.getVolume().getUuid(); String snapshotname = snapshotTO.getName(); Answer answer = ElastistorUtil.createElastistorVolumeSnapshot(volumeid, snapshotname); if(answer.getResult() == false){ s_logger.info("elastistor volume snapshot failed"); throw new CloudRuntimeException("elastistor volume snapshot failed"); }else{ s_logger.info("elastistor volume snapshot succesfull"); snapshotTO.setPath(answer.getDetails()); CreateObjectAnswer createObjectAnswer = new CreateObjectAnswer(snapshotTO); result = new CreateCmdResult(null, createObjectAnswer); result.setResult(null); } } catch (Throwable e) { s_logger.debug("Failed to take snapshot: " + e.getMessage()); result = new CreateCmdResult(null, null); result.setResult(e.toString()); } callback.complete(result); }
/** * Is not used in normal operation, the SSVM takes care of this. */ @Override public Answer deleteSnapshot(DeleteCommand cmd) { LOGGER.debug("execute deleteSnapshot: "+ cmd.getClass()); DataTO data = cmd.getData(); SnapshotObjectTO snap = (SnapshotObjectTO) data; String storeUrl = data.getDataStore().getUrl(); String snapUuid = snap.getPath(); try { // snapshots/accountid/volumeid String secPoolUuid = pool.setupSecondaryStorage(storeUrl); String filePath = config.getAgentSecStoragePath() + "/" + secPoolUuid + "/" + snapUuid + ".raw"; StoragePlugin sp = new StoragePlugin(c); sp.storagePluginDestroy(secPoolUuid, filePath); LOGGER.debug("Snapshot deletion success: " + filePath); return new Answer(cmd, true, "Deleted Snapshot " + filePath); } catch (Ovm3ResourceException e) { LOGGER.info("Snapshot deletion failed: " + e.toString(), e); return new CreateObjectAnswer(e.toString()); } } /**
@Override public Answer createVolume(final CreateObjectCommand cmd) { final DataTO data = cmd.getData(); final VolumeObjectTO volume = (VolumeObjectTO) data; try { final Connection conn = hypervisorResource.getConnection(); final SR poolSr = hypervisorResource.getStorageRepository(conn, data.getDataStore().getUuid()); VDI.Record vdir = new VDI.Record(); vdir.nameLabel = volume.getName(); vdir.SR = poolSr; vdir.type = Types.VdiType.USER; vdir.virtualSize = volume.getSize(); VDI vdi; vdi = VDI.create(conn, vdir); vdir = vdi.getRecord(conn); final VolumeObjectTO newVol = new VolumeObjectTO(); newVol.setName(vdir.nameLabel); newVol.setSize(vdir.virtualSize); newVol.setPath(vdir.uuid); return new CreateObjectAnswer(newVol); } catch (final Exception e) { s_logger.debug("create volume failed: " + e.toString()); return new CreateObjectAnswer(e.toString()); } }
Xen.Vm vm = xen.getVmConfig(snap.getVmName()); if (vm != null) { return new CreateObjectAnswer( "Snapshot object creation not supported for running VMs." + snap.getVmName()); return new CreateObjectAnswer(nsnap); } catch (Ovm3ResourceException e) { return new CreateObjectAnswer( "Snapshot object creation failed. " + e.getMessage());
return new CreateObjectAnswer(newSnapshot); } catch (final XenAPIException e) { details += ", reason: " + e.toString(); return new CreateObjectAnswer(details);
@Override public Answer createVolume(final CreateObjectCommand cmd) { final VolumeObjectTO volume = (VolumeObjectTO)cmd.getData(); final PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO)volume.getDataStore(); KVMStoragePool primaryPool = null; KVMPhysicalDisk vol = null; long disksize; try { primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid()); disksize = volume.getSize(); PhysicalDiskFormat format; if (volume.getFormat() == null) { format = primaryPool.getDefaultFormat(); } else { format = PhysicalDiskFormat.valueOf(volume.getFormat().toString().toUpperCase()); } vol = primaryPool.createPhysicalDisk(volume.getUuid(), format, volume.getProvisioningType(), disksize); final VolumeObjectTO newVol = new VolumeObjectTO(); if(vol != null) { newVol.setPath(vol.getName()); } newVol.setSize(volume.getSize()); newVol.setFormat(ImageFormat.valueOf(format.toString().toUpperCase())); return new CreateObjectAnswer(newVol); } catch (final Exception e) { s_logger.debug("Failed to create volume: ", e); return new CreateObjectAnswer(e.toString()); } }
if (result != null) { s_logger.debug("Failed to manage snapshot: " + result); return new CreateObjectAnswer("Failed to manage snapshot: " + result); return new CreateObjectAnswer(newSnapshot); } catch (final LibvirtException e) { s_logger.debug("Failed to manage snapshot: ", e); return new CreateObjectAnswer("Failed to manage snapshot: " + e.toString());
CreateObjectAnswer createObjectAnswer = new CreateObjectAnswer(snapshotObjectTo); LOGGER.debug(SolidFireUtil.LOG_PREFIX + "Failed to take CloudStack snapshot: " + snapshotInfo.getId(), ex); result = new CreateCmdResult(null, new CreateObjectAnswer(ex.toString()));
snapTO.setPath(parentSnapshotOnBackupStore.getInstallPath()); CreateObjectAnswer createSnapshotAnswer = new CreateObjectAnswer(snapTO);