@Test public void getVolumePath_BasicTest() throws Exception { final String volId = "foo"; final String sanVolId = "fooprefix" + volId + "foosuffix"; final String volIqn = "foo-iqn"; final SANVolumeInfo existing = new SANVolumeInfo(volId); existing.setSanVolumeId(sanVolId); existing.setIqn(volIqn); 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).connectTarget(volIqn, null); will(returnValue(new StorageResource(volId, "foopath", StorageResource.Type.FILE) { @Override public Long getSize() throws Exception { return null; } @Override public InputStream getInputStream() throws Exception { return null; } @Override public OutputStream getOutputStream() throws Exception { return null; } @Override public Boolean isDownloadSynchronous() { return Boolean.TRUE; } })); } }); SANManager test = new SANManager(sanProvider); String path = test.getVolumePath(volId); assertTrue("expected the returned value to be 'foopath', but it was '" + path + "'", "foopath".equals(path)); }
public String getVolumePath(String volumeId) throws EucalyptusCloudException { try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { SANVolumeInfo volumeInfo = Entities.uniqueResult(new SANVolumeInfo(volumeId)); String iqn = volumeInfo.getIqn(); String deviceName = connectionManager.connectTarget(iqn, null).getPath(); return deviceName; } catch (TransactionException | NoSuchElementException ex) { LOG.warn("Block storage backend database record not found for " + volumeId); throw new EucalyptusCloudException("Block storage backend database record not found for " + volumeId, ex); } }
SANManager implements LogicalStorageManager { public String getVolumePath(String volumeId) throws EucalyptusCloudException { try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { SANVolumeInfo volumeInfo = Entities.uniqueResult(new SANVolumeInfo(volumeId)); String iqn = volumeInfo.getIqn(); String deviceName = connectionManager.connectTarget(iqn, null).getPath(); return deviceName; } catch (TransactionException | NoSuchElementException ex) { LOG.warn("Block storage backend database record not found for " + volumeId); throw new EucalyptusCloudException("Block storage backend database record not found for " + volumeId, ex); } } }
SANManager implements LogicalStorageManager { public String getVolumePath(String volumeId) throws EucalyptusCloudException { try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { SANVolumeInfo volumeInfo = Entities.uniqueResult(new SANVolumeInfo(volumeId)); String iqn = volumeInfo.getIqn(); String deviceName = connectionManager.connectTarget(iqn, null).getPath(); return deviceName; } catch (TransactionException | NoSuchElementException ex) { LOG.warn("Block storage backend database record not found for " + volumeId); throw new EucalyptusCloudException("Block storage backend database record not found for " + volumeId, ex); } } SANManager();   SANManager(SANProvider connectionManager); }
SANManager implements LogicalStorageManager { public String getVolumePath(String volumeId) throws EucalyptusCloudException { try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { SANVolumeInfo volumeInfo = Entities.uniqueResult(new SANVolumeInfo(volumeId)); String iqn = volumeInfo.getIqn(); String deviceName = connectionManager.connectTarget(iqn, null).getPath(); return deviceName; } catch (TransactionException | NoSuchElementException ex) { LOG.warn("Block storage backend database record not found for " + volumeId); throw new EucalyptusCloudException("Block storage backend database record not found for " + volumeId, ex); } } 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 { public String getVolumePath(String volumeId) throws EucalyptusCloudException { try (TransactionResource tran = Entities.transactionFor(SANVolumeInfo.class)) { SANVolumeInfo volumeInfo = Entities.uniqueResult(new SANVolumeInfo(volumeId)); String iqn = volumeInfo.getIqn(); String deviceName = connectionManager.connectTarget(iqn, null).getPath(); return deviceName; } catch (TransactionException | NoSuchElementException ex) { LOG.warn("Block storage backend database record not found for " + volumeId); throw new EucalyptusCloudException("Block storage backend database record not found for " + volumeId, ex); } } 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);  }