public Answer execute(DestroyCommand cmd) { try { OvmVolume.destroy(_conn, cmd.getVolume().getPoolUuid(), cmd.getVolume().getPath()); return new Answer(cmd, true, "Success"); } catch (Exception e) { s_logger.debug("Destroy volume " + cmd.getVolume().getName() + " failed", e); return new Answer(cmd, false, e.getMessage()); } }
public Answer execute(DestroyCommand cmd) { LOGGER.debug("execute: "+ cmd.getClass()); VolumeTO vol = cmd.getVolume(); String vmName = cmd.getVmName(); try { StoragePlugin store = new StoragePlugin(c); store.storagePluginDestroy(vol.getPoolUuid(), vol.getPath()); return new Answer(cmd, true, "Success"); } catch (Ovm3ResourceException e) { LOGGER.debug("Destroy volume " + vol.getName() + " failed for " + vmName + " ", e); return new Answer(cmd, false, e.getMessage()); } }
@Test public final void testCreateCommand() { String sample = "{\"volId\":10,\"pool\":{\"id\":201,\"uuid\":\"" + s_testLocalStoreUUID + "\",\"host\":\"10.70.176.29\"" + ",\"path\":" + s_testLocalStorePathJSON + ",\"port\":0,\"type\":\"Filesystem\"}," + "\"diskCharacteristics\":{\"size\":0," + "\"tags\":[],\"type\":\"ROOT\",\"name\":\"ROOT-9\"," + "\"useLocalStorage\":true,\"recreatable\":true," + "\"diskOfferingId\":11," + "\"volumeId\":10,\"hyperType\":\"Hyperv\"}," + "\"templateUrl\":" + s_testSampleTemplateURLJSON + ",\"contextMap\":{},\"wait\":0}"; File destDir = new File(s_testLocalStorePath); Assert.assertTrue(destDir.isDirectory()); File testSampleTemplateURLFile = new File(s_testLocalStorePath + File.separator + s_gson.fromJson(s_testSampleTemplateURLJSON, String.class)); Assert.assertTrue("The template that create should make" + " volumes from is missing from path " + testSampleTemplateURLFile.getPath(), testSampleTemplateURLFile.exists()); int fileCount = destDir.listFiles().length; s_logger.debug(" test local store has " + fileCount + "files"); // Test requires there to be a template at the tempalteUrl, which is its // location in the local file system. CreateCommand cmd = s_gson.fromJson(sample, CreateCommand.class); CreateAnswer ans = (CreateAnswer)s_hypervresource.executeRequest(cmd); Assert.assertTrue(ans.getDetails(), ans.getResult()); Assert.assertTrue("CreateCommand should add a file to the folder", fileCount + 1 == destDir.listFiles().length); File newFile = new File(ans.getVolume().getPath()); Assert.assertTrue("The new file should have a size greater than zero", newFile.length() > 0); newFile.delete(); }
final VolumeTO vol = command.getVolume(); final String volumeUUID = vol.getPath(); VDI vdi = null; try {
@Override public Answer execute(final DestroyCommand command, final LibvirtComputingResource libvirtComputingResource) { final VolumeTO vol = command.getVolume(); try { final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); final KVMStoragePool pool = storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid()); pool.deletePhysicalDisk(vol.getPath(), null); return new Answer(command, true, "Success"); } catch (final CloudRuntimeException e) { s_logger.debug("Failed to delete volume: " + e.toString()); return new Answer(command, false, e.toString()); } } }
final StorageFilerTO storageFiler = entry.second(); final VolumeTO volume = entry.first(); vdiMap.put(xenServer610Resource.getVDIbyUuid(connection, volume.getPath()), xenServer610Resource.getStorageRepository(connection, storageFiler.getUuid()));
if (entry.second() instanceof SR) { final SR sr = (SR)entry.second(); final VDI vdi = xenServer610Resource.getVDIbyUuid(connection, entry.first().getPath()); vdiMap.put(vdi, sr); } else {