@Test public void GetStorageVolume_BasicTest() throws Exception { VolumeInfo volOne = new VolumeInfo(); volOne.setStatus(StorageProperties.Status.available.toString()); volOne.setSize(new Integer(1)); volOne.setUserName("unittestuser0"); volOne.setVolumeId("vol-0000"); volOne.setSnapshotId("snap-0000"); volOne.setCreateTime(new Date()); volOne.setZone("eucalyptus"); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { Entities.persist(volOne); tran.commit(); } final LogicalStorageManager storageManager = context.mock(LogicalStorageManager.class); context.checking(new Expectations() { { oneOf(storageManager).getVolumeConnectionString("vol-0000"); will(returnValue("foo")); } }); StorageProperties.enableStorage = true; BlockStorageController bsc = new BlockStorageController(storageManager); GetStorageVolumeType request = new GetStorageVolumeType(); request.setVolumeId("vol-0000"); GetStorageVolumeResponseType response = bsc.GetStorageVolume(request); assertTrue("expected to receive proper volumeId in response", "vol-0000".equals(response.getVolumeId())); assertTrue("expected to receive correct size in response", "1".equals(response.getSize())); assertTrue("expected to receive correct status in response", StorageProperties.Status.available.toString().equals(response.getStatus())); assertTrue("expected to receive correct snapshotId in response", "snap-0000".equals(response.getSnapshotId())); assertTrue("expected to receive correct device name in response", "foo".equals(response.getActualDeviceName())); }
@Override public GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request) throws EucalyptusCloudException { GetStorageVolumeResponseType reply = (GetStorageVolumeResponseType) request.getReply(); if (!StorageProperties.enableStorage) { LOG.error("BlockStorage has been disabled. Please check your setup"); return reply; } String volumeId = request.getVolumeId(); LOG.info("Processing GetStorageVolume request for volume " + volumeId); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setVolumeId(volumeId); List<VolumeInfo> volumeInfos = Entities.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo foundVolumeInfo = volumeInfos.get(0); String deviceName = blockManager.getVolumeConnectionString(volumeId); reply.setVolumeId(foundVolumeInfo.getVolumeId()); reply.setSize(foundVolumeInfo.getSize().toString()); reply.setStatus(foundVolumeInfo.getStatus()); reply.setSnapshotId(foundVolumeInfo.getSnapshotId()); if (deviceName != null) reply.setActualDeviceName(deviceName); else reply.setActualDeviceName("invalid"); } else { throw new NoSuchVolumeException(volumeId); } tran.commit(); } return reply; }
BlockStorageController implements BlockStorageService { @Override public GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request) throws EucalyptusCloudException { GetStorageVolumeResponseType reply = (GetStorageVolumeResponseType) request.getReply(); if (!StorageProperties.enableStorage) { LOG.error("BlockStorage has been disabled. Please check your setup"); return reply; } String volumeId = request.getVolumeId(); LOG.info("Processing GetStorageVolume request for volume " + volumeId); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setVolumeId(volumeId); List<VolumeInfo> volumeInfos = Entities.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo foundVolumeInfo = volumeInfos.get(0); String deviceName = blockManager.getVolumeConnectionString(volumeId); reply.setVolumeId(foundVolumeInfo.getVolumeId()); reply.setSize(foundVolumeInfo.getSize().toString()); reply.setStatus(foundVolumeInfo.getStatus()); reply.setSnapshotId(foundVolumeInfo.getSnapshotId()); if (deviceName != null) reply.setActualDeviceName(deviceName); else reply.setActualDeviceName("invalid"); } else { throw new NoSuchVolumeException(volumeId); } tran.commit(); } return reply; } }
BlockStorageController implements BlockStorageService { @Override public GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request) throws EucalyptusCloudException { GetStorageVolumeResponseType reply = (GetStorageVolumeResponseType) request.getReply(); if (!StorageProperties.enableStorage) { LOG.error("BlockStorage has been disabled. Please check your setup"); return reply; } String volumeId = request.getVolumeId(); LOG.info("Processing GetStorageVolume request for volume " + volumeId); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setVolumeId(volumeId); List<VolumeInfo> volumeInfos = Entities.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo foundVolumeInfo = volumeInfos.get(0); String deviceName = blockManager.getVolumeConnectionString(volumeId); reply.setVolumeId(foundVolumeInfo.getVolumeId()); reply.setSize(foundVolumeInfo.getSize().toString()); reply.setStatus(foundVolumeInfo.getStatus()); reply.setSnapshotId(foundVolumeInfo.getSnapshotId()); if (deviceName != null) reply.setActualDeviceName(deviceName); else reply.setActualDeviceName("invalid"); } else { throw new NoSuchVolumeException(volumeId); } tran.commit(); } return reply; } BlockStorageController();  BlockStorageController(LogicalStorageManager blockManager); }
BlockStorageController implements BlockStorageService { @Override public GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request) throws EucalyptusCloudException { GetStorageVolumeResponseType reply = (GetStorageVolumeResponseType) request.getReply(); if (!StorageProperties.enableStorage) { LOG.error("BlockStorage has been disabled. Please check your setup"); return reply; } String volumeId = request.getVolumeId(); LOG.info("Processing GetStorageVolume request for volume " + volumeId); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setVolumeId(volumeId); List<VolumeInfo> volumeInfos = Entities.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo foundVolumeInfo = volumeInfos.get(0); String deviceName = blockManager.getVolumeConnectionString(volumeId); reply.setVolumeId(foundVolumeInfo.getVolumeId()); reply.setSize(foundVolumeInfo.getSize().toString()); reply.setStatus(foundVolumeInfo.getStatus()); reply.setSnapshotId(foundVolumeInfo.getSnapshotId()); if (deviceName != null) reply.setActualDeviceName(deviceName); else reply.setActualDeviceName("invalid"); } else { throw new NoSuchVolumeException(volumeId); } tran.commit(); } return reply; } BlockStorageController();  BlockStorageController(LogicalStorageManager blockManager); static void configure(); static void check(); static void stop(); static void enable(); static void disable(); static void updateStuckVolumes(); static void updateStuckSnapshots(); @Override UpdateStorageConfigurationResponseType UpdateStorageConfiguration(UpdateStorageConfigurationType request); @Override GetStorageConfigurationResponseType GetStorageConfiguration(GetStorageConfigurationType request); @Override GetVolumeTokenResponseType GetVolumeToken(GetVolumeTokenType request); @Override UnexportVolumeResponseType UnexportVolume(UnexportVolumeType request); @Override ExportVolumeResponseType ExportVolume(ExportVolumeType request); @Override GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request); @Override DeleteStorageVolumeResponseType DeleteStorageVolume(DeleteStorageVolumeType request); @Override CreateStorageSnapshotResponseType CreateStorageSnapshot(CreateStorageSnapshotType request); @Override DescribeStorageSnapshotsResponseType DescribeStorageSnapshots(DescribeStorageSnapshotsType request); @Override DeleteStorageSnapshotResponseType DeleteStorageSnapshot(DeleteStorageSnapshotType request); @Override CreateStorageVolumeResponseType CreateStorageVolume(CreateStorageVolumeType request); @Override DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request); @Override ConvertVolumesResponseType ConvertVolumes(ConvertVolumesType request); @Override AttachStorageVolumeResponseType attachVolume(AttachStorageVolumeType request); @Override DetachStorageVolumeResponseType detachVolume(DetachStorageVolumeType request); @Override CloneVolumeResponseType CloneVolume(CloneVolumeType request); }
BlockStorageController implements BlockStorageService { @Override public GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request) throws EucalyptusCloudException { GetStorageVolumeResponseType reply = (GetStorageVolumeResponseType) request.getReply(); if (!StorageProperties.enableStorage) { LOG.error("BlockStorage has been disabled. Please check your setup"); return reply; } String volumeId = request.getVolumeId(); LOG.info("Processing GetStorageVolume request for volume " + volumeId); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { VolumeInfo volumeInfo = new VolumeInfo(); volumeInfo.setVolumeId(volumeId); List<VolumeInfo> volumeInfos = Entities.query(volumeInfo); if (volumeInfos.size() > 0) { VolumeInfo foundVolumeInfo = volumeInfos.get(0); String deviceName = blockManager.getVolumeConnectionString(volumeId); reply.setVolumeId(foundVolumeInfo.getVolumeId()); reply.setSize(foundVolumeInfo.getSize().toString()); reply.setStatus(foundVolumeInfo.getStatus()); reply.setSnapshotId(foundVolumeInfo.getSnapshotId()); if (deviceName != null) reply.setActualDeviceName(deviceName); else reply.setActualDeviceName("invalid"); } else { throw new NoSuchVolumeException(volumeId); } tran.commit(); } return reply; } BlockStorageController();  BlockStorageController(LogicalStorageManager blockManager); static void configure(); static void check(); static void stop(); static void enable(); static void disable(); static void updateStuckVolumes(); static void updateStuckSnapshots(); @Override UpdateStorageConfigurationResponseType UpdateStorageConfiguration(UpdateStorageConfigurationType request); @Override GetStorageConfigurationResponseType GetStorageConfiguration(GetStorageConfigurationType request); @Override GetVolumeTokenResponseType GetVolumeToken(GetVolumeTokenType request); @Override UnexportVolumeResponseType UnexportVolume(UnexportVolumeType request); @Override ExportVolumeResponseType ExportVolume(ExportVolumeType request); @Override GetStorageVolumeResponseType GetStorageVolume(GetStorageVolumeType request); @Override DeleteStorageVolumeResponseType DeleteStorageVolume(DeleteStorageVolumeType request); @Override CreateStorageSnapshotResponseType CreateStorageSnapshot(CreateStorageSnapshotType request); @Override DescribeStorageSnapshotsResponseType DescribeStorageSnapshots(DescribeStorageSnapshotsType request); @Override DeleteStorageSnapshotResponseType DeleteStorageSnapshot(DeleteStorageSnapshotType request); @Override CreateStorageVolumeResponseType CreateStorageVolume(CreateStorageVolumeType request); @Override DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request); @Override ConvertVolumesResponseType ConvertVolumes(ConvertVolumesType request); @Override AttachStorageVolumeResponseType attachVolume(AttachStorageVolumeType request); @Override DetachStorageVolumeResponseType detachVolume(DetachStorageVolumeType request); @Override CloneVolumeResponseType CloneVolume(CloneVolumeType request);  }