@Test public void deleteSnapshot_NoSANSnapshot() throws Exception { final String volId = "foo"; final String iqn = "foo-iqn"; final String snapshotPointId = "snap-point-foo"; final SANVolumeInfo existing = new SANVolumeInfo(volId).withSanVolumeId("fooprefix" + volId + "foosuffix"); existing.setIqn(iqn); try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { Entities.persist(existing); tran.commit(); } final SANProvider sanProvider = context.mock(SANProvider.class); context.checking(new Expectations() { { oneOf(sanProvider).deleteSnapshot(existing.getSanVolumeId(), iqn, snapshotPointId); will(returnValue(Boolean.FALSE)); oneOf(sanProvider).snapshotExists(existing.getSanVolumeId(), iqn); will(returnValue(Boolean.FALSE)); } }); SANManager test = new SANManager(sanProvider); test.deleteSnapshot(volId, snapshotPointId); try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { List<SANVolumeInfo> results = Entities.query(new SANVolumeInfo()); assertTrue("expected no SANVolumeInfos to exist", results == null || results.size() == 0); } }
@Override public void deleteSnapshot(String snapshotId, String snapshotPointId) throws EucalyptusCloudException { SANVolumeInfo sanSnapshot = null; String sanSnapshotId = null; String iqn = null; try { sanSnapshot = lookup(snapshotId); sanSnapshotId = sanSnapshot.getSanVolumeId(); iqn = sanSnapshot.getIqn(); } catch (Exception ex) { LOG.debug("Skipping deletion for " + snapshotId); return; } boolean deleteEntity = false; LOG.info("Deleting " + sanSnapshotId + " on backend"); if (connectionManager.deleteSnapshot(sanSnapshotId, iqn, snapshotPointId)) { deleteEntity = true; } else { LOG.debug("Unable to delete " + sanSnapshotId + " on backend. Checking to see if the resource exists"); if (!connectionManager.snapshotExists(sanSnapshotId, iqn)) { LOG.debug("Resource not found on backend for " + sanSnapshotId + ". Safe to delete database record for " + snapshotId); deleteEntity = true; } else { LOG.warn("Failed to delete backend resource " + sanSnapshotId); throw new EucalyptusCloudException("Failed to delete backend resource " + sanSnapshotId); } } if (deleteEntity) { try { Transactions.delete(new SANVolumeInfo(snapshotId).withSanVolumeId(sanSnapshotId)); } catch (Exception e) { LOG.warn("Failed to remove database record post deletion for " + snapshotId, e); throw new EucalyptusCloudException("Failed to remove database record post deletion for " + snapshotId, e); } } }
SANManager implements LogicalStorageManager { @Override public void deleteSnapshot(String snapshotId, String snapshotPointId) throws EucalyptusCloudException { SANVolumeInfo sanSnapshot = null; String sanSnapshotId = null; String iqn = null; try { sanSnapshot = lookup(snapshotId); sanSnapshotId = sanSnapshot.getSanVolumeId(); iqn = sanSnapshot.getIqn(); } catch (Exception ex) { LOG.debug("Skipping deletion for " + snapshotId); return; } boolean deleteEntity = false; LOG.info("Deleting " + sanSnapshotId + " on backend"); if (connectionManager.deleteSnapshot(sanSnapshotId, iqn, snapshotPointId)) { deleteEntity = true; } else { LOG.debug("Unable to delete " + sanSnapshotId + " on backend. Checking to see if the resource exists"); if (!connectionManager.snapshotExists(sanSnapshotId, iqn)) { LOG.debug("Resource not found on backend for " + sanSnapshotId + ". Safe to delete database record for " + snapshotId); deleteEntity = true; } else { LOG.warn("Failed to delete backend resource " + sanSnapshotId); throw new EucalyptusCloudException("Failed to delete backend resource " + sanSnapshotId); } } if (deleteEntity) { try { Transactions.delete(new SANVolumeInfo(snapshotId).withSanVolumeId(sanSnapshotId)); } catch (Exception e) { LOG.warn("Failed to remove database record post deletion for " + snapshotId, e); throw new EucalyptusCloudException("Failed to remove database record post deletion for " + snapshotId, e); } } } }
SANManager implements LogicalStorageManager { @Override public void deleteSnapshot(String snapshotId, String snapshotPointId) throws EucalyptusCloudException { SANVolumeInfo sanSnapshot = null; String sanSnapshotId = null; String iqn = null; try { sanSnapshot = lookup(snapshotId); sanSnapshotId = sanSnapshot.getSanVolumeId(); iqn = sanSnapshot.getIqn(); } catch (Exception ex) { LOG.debug("Skipping deletion for " + snapshotId); return; } boolean deleteEntity = false; LOG.info("Deleting " + sanSnapshotId + " on backend"); if (connectionManager.deleteSnapshot(sanSnapshotId, iqn, snapshotPointId)) { deleteEntity = true; } else { LOG.debug("Unable to delete " + sanSnapshotId + " on backend. Checking to see if the resource exists"); if (!connectionManager.snapshotExists(sanSnapshotId, iqn)) { LOG.debug("Resource not found on backend for " + sanSnapshotId + ". Safe to delete database record for " + snapshotId); deleteEntity = true; } else { LOG.warn("Failed to delete backend resource " + sanSnapshotId); throw new EucalyptusCloudException("Failed to delete backend resource " + sanSnapshotId); } } if (deleteEntity) { try { Transactions.delete(new SANVolumeInfo(snapshotId).withSanVolumeId(sanSnapshotId)); } catch (Exception e) { LOG.warn("Failed to remove database record post deletion for " + snapshotId, e); throw new EucalyptusCloudException("Failed to remove database record post deletion for " + snapshotId, e); } } } SANManager();   SANManager(SANProvider connectionManager); }
SANManager implements LogicalStorageManager { @Override public void deleteSnapshot(String snapshotId, String snapshotPointId) throws EucalyptusCloudException { SANVolumeInfo sanSnapshot = null; String sanSnapshotId = null; String iqn = null; try { sanSnapshot = lookup(snapshotId); sanSnapshotId = sanSnapshot.getSanVolumeId(); iqn = sanSnapshot.getIqn(); } catch (Exception ex) { LOG.debug("Skipping deletion for " + snapshotId); return; } boolean deleteEntity = false; LOG.info("Deleting " + sanSnapshotId + " on backend"); if (connectionManager.deleteSnapshot(sanSnapshotId, iqn, snapshotPointId)) { deleteEntity = true; } else { LOG.debug("Unable to delete " + sanSnapshotId + " on backend. Checking to see if the resource exists"); if (!connectionManager.snapshotExists(sanSnapshotId, iqn)) { LOG.debug("Resource not found on backend for " + sanSnapshotId + ". Safe to delete database record for " + snapshotId); deleteEntity = true; } else { LOG.warn("Failed to delete backend resource " + sanSnapshotId); throw new EucalyptusCloudException("Failed to delete backend resource " + sanSnapshotId); } } if (deleteEntity) { try { Transactions.delete(new SANVolumeInfo(snapshotId).withSanVolumeId(sanSnapshotId)); } catch (Exception e) { LOG.warn("Failed to remove database record post deletion for " + snapshotId, e); throw new EucalyptusCloudException("Failed to remove database record post deletion for " + snapshotId, e); } } } SANManager();   SANManager(SANProvider connectionManager); static LogicalStorageManager getInstance(); void addSnapshot(String snapshotId); void checkPreconditions(); @Override void cleanSnapshot(String snapshotId, String snapshotPointId); void cleanVolume(String volumeId); void configure(); StorageResource createSnapshot(String volumeId, String snapshotId, String snapshotPointId, Boolean shouldTransferSnapshots); void createSnapshot(String volumeId, String snapshotId, String snapshotPointId); void createVolume(String volumeId, int size); int createVolume(String volumeId, String snapshotId, int size); void cloneVolume(String volumeId, String parentVolumeId); @Override void deleteSnapshot(String snapshotId, String snapshotPointId); void deleteVolume(String volumeId); int getSnapshotSize(String snapshotId); String getVolumeConnectionString(String volumeId); void initialize(); void loadSnapshots(List<String> snapshotSet, List<String> snapshotFileNames); List<String> prepareForTransfer(String snapshotId); void reload(); void startupChecks(); void finishVolume(String snapshotId); StorageResourceWithCallback prepSnapshotForDownload(final String snapshotId, int sizeExpected, long actualSizeInMB); ArrayList<ComponentProperty> getStorageProps(); void setStorageProps(ArrayList<ComponentProperty> storageProps); String getStorageRootDirectory(); String getVolumePath(String volumeId); void importVolume(String volumeId, String volumePath, int size); String getSnapshotPath(String snapshotId); void importSnapshot(String snapshotId, String volumeId, String snapPath, int size); String exportVolume(String volumeId, String nodeIqn); void unexportVolumeFromAll(String volumeId); void unexportVolume(String volumeId, String nodeIqn); void checkReady(); void stop(); void disable(); void enable(); boolean getFromBackend(String snapshotId, int size); void checkVolume(String volumeId); List<CheckerTask> getCheckers(); String createSnapshotPoint(String parentVolumeId, String volumeId); void deleteSnapshotPoint(String parentVolumeId, String volumeId, String snapshotPointId); @Override boolean supportsIncrementalSnapshots(); @Override StorageResourceWithCallback prepIncrementalSnapshotForUpload(String volumeId, String snapshotId, String snapPointId, String prevSnapshotId,
      String prevSnapPointId); @Override StorageResource prepSnapshotForUpload(String volumeId, String snapshotId, String snapPointId); @Override StorageResourceWithCallback prepSnapshotBaseForRestore(final String snapshotId, final int size, final String snapshotPointId); @Override void restoreSnapshotDelta(String currentSnapId, String prevSnapId, String baseId, StorageResource sr); @Override void completeSnapshotRestorationFromDeltas(String snapshotId); @Override T executeCallback(Function<F, T> callback, F input); }
SANManager implements LogicalStorageManager { @Override public void deleteSnapshot(String snapshotId, String snapshotPointId) throws EucalyptusCloudException { SANVolumeInfo sanSnapshot = null; String sanSnapshotId = null; String iqn = null; try { sanSnapshot = lookup(snapshotId); sanSnapshotId = sanSnapshot.getSanVolumeId(); iqn = sanSnapshot.getIqn(); } catch (Exception ex) { LOG.debug("Skipping deletion for " + snapshotId); return; } boolean deleteEntity = false; LOG.info("Deleting " + sanSnapshotId + " on backend"); if (connectionManager.deleteSnapshot(sanSnapshotId, iqn, snapshotPointId)) { deleteEntity = true; } else { LOG.debug("Unable to delete " + sanSnapshotId + " on backend. Checking to see if the resource exists"); if (!connectionManager.snapshotExists(sanSnapshotId, iqn)) { LOG.debug("Resource not found on backend for " + sanSnapshotId + ". Safe to delete database record for " + snapshotId); deleteEntity = true; } else { LOG.warn("Failed to delete backend resource " + sanSnapshotId); throw new EucalyptusCloudException("Failed to delete backend resource " + sanSnapshotId); } } if (deleteEntity) { try { Transactions.delete(new SANVolumeInfo(snapshotId).withSanVolumeId(sanSnapshotId)); } catch (Exception e) { LOG.warn("Failed to remove database record post deletion for " + snapshotId, e); throw new EucalyptusCloudException("Failed to remove database record post deletion for " + snapshotId, e); } } } SANManager();   SANManager(SANProvider connectionManager); static LogicalStorageManager getInstance(); void addSnapshot(String snapshotId); void checkPreconditions(); @Override void cleanSnapshot(String snapshotId, String snapshotPointId); void cleanVolume(String volumeId); void configure(); StorageResource createSnapshot(String volumeId, String snapshotId, String snapshotPointId, Boolean shouldTransferSnapshots); void createSnapshot(String volumeId, String snapshotId, String snapshotPointId); void createVolume(String volumeId, int size); int createVolume(String volumeId, String snapshotId, int size); void cloneVolume(String volumeId, String parentVolumeId); @Override void deleteSnapshot(String snapshotId, String snapshotPointId); void deleteVolume(String volumeId); int getSnapshotSize(String snapshotId); String getVolumeConnectionString(String volumeId); void initialize(); void loadSnapshots(List<String> snapshotSet, List<String> snapshotFileNames); List<String> prepareForTransfer(String snapshotId); void reload(); void startupChecks(); void finishVolume(String snapshotId); StorageResourceWithCallback prepSnapshotForDownload(final String snapshotId, int sizeExpected, long actualSizeInMB); ArrayList<ComponentProperty> getStorageProps(); void setStorageProps(ArrayList<ComponentProperty> storageProps); String getStorageRootDirectory(); String getVolumePath(String volumeId); void importVolume(String volumeId, String volumePath, int size); String getSnapshotPath(String snapshotId); void importSnapshot(String snapshotId, String volumeId, String snapPath, int size); String exportVolume(String volumeId, String nodeIqn); void unexportVolumeFromAll(String volumeId); void unexportVolume(String volumeId, String nodeIqn); void checkReady(); void stop(); void disable(); void enable(); boolean getFromBackend(String snapshotId, int size); void checkVolume(String volumeId); List<CheckerTask> getCheckers(); String createSnapshotPoint(String parentVolumeId, String volumeId); void deleteSnapshotPoint(String parentVolumeId, String volumeId, String snapshotPointId); @Override boolean supportsIncrementalSnapshots(); @Override StorageResourceWithCallback prepIncrementalSnapshotForUpload(String volumeId, String snapshotId, String snapPointId, String prevSnapshotId,
      String prevSnapPointId); @Override StorageResource prepSnapshotForUpload(String volumeId, String snapshotId, String snapPointId); @Override StorageResourceWithCallback prepSnapshotBaseForRestore(final String snapshotId, final int size, final String snapshotPointId); @Override void restoreSnapshotDelta(String currentSnapId, String prevSnapId, String baseId, StorageResource sr); @Override void completeSnapshotRestorationFromDeltas(String snapshotId); @Override T executeCallback(Function<F, T> callback, F input);  }