@Test public void DescribeStorageVolumes_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(SnapshotInfo.class)) { Entities.persist(volOne); tran.commit(); } final LogicalStorageManager storageManager = context.mock(LogicalStorageManager.class); context.checking(new Expectations() { { } }); BlockStorageController bsc = new BlockStorageController(storageManager); DescribeStorageVolumesType request = new DescribeStorageVolumesType(); DescribeStorageVolumesResponseType response = bsc.DescribeStorageVolumes(request); assertTrue("expected at least one volume in the response", response != null && response.getVolumeSet() != null && response.getVolumeSet().size() > 0); assertTrue("expected to find manually created snapshot in the response", response.getVolumeSet().get(0).getVolumeId().equals("vol-0000")); }
@Override public DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request) throws EucalyptusCloudException { DescribeStorageVolumesResponseType reply = (DescribeStorageVolumesResponseType) request.getReply(); List<String> volumeSet = request.getVolumeSet(); ArrayList<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { if ((volumeSet != null) && !volumeSet.isEmpty()) { for (String volumeSetEntry : volumeSet) { VolumeInfo volumeInfo = new VolumeInfo(volumeSetEntry); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); if (foundVolumeInfos.size() > 0) { volumeInfos.add(foundVolumeInfos.get(0)); } } } else { VolumeInfo volumeInfo = new VolumeInfo(); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); for (VolumeInfo volInfo : foundVolumeInfos) { volumeInfos.add(volInfo); } } ArrayList<StorageVolume> volumes = reply.getVolumeSet(); for (VolumeInfo volumeInfo : volumeInfos) { volumes.add(convertVolumeInfo(volumeInfo)); } tran.commit(); } return reply; }
BlockStorageController implements BlockStorageService { @Override public DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request) throws EucalyptusCloudException { DescribeStorageVolumesResponseType reply = (DescribeStorageVolumesResponseType) request.getReply(); List<String> volumeSet = request.getVolumeSet(); ArrayList<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { if ((volumeSet != null) && !volumeSet.isEmpty()) { for (String volumeSetEntry : volumeSet) { VolumeInfo volumeInfo = new VolumeInfo(volumeSetEntry); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); if (foundVolumeInfos.size() > 0) { volumeInfos.add(foundVolumeInfos.get(0)); } } } else { VolumeInfo volumeInfo = new VolumeInfo(); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); for (VolumeInfo volInfo : foundVolumeInfos) { volumeInfos.add(volInfo); } } ArrayList<StorageVolume> volumes = reply.getVolumeSet(); for (VolumeInfo volumeInfo : volumeInfos) { volumes.add(convertVolumeInfo(volumeInfo)); } tran.commit(); } return reply; } }
BlockStorageController implements BlockStorageService { @Override public DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request) throws EucalyptusCloudException { DescribeStorageVolumesResponseType reply = (DescribeStorageVolumesResponseType) request.getReply(); List<String> volumeSet = request.getVolumeSet(); ArrayList<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { if ((volumeSet != null) && !volumeSet.isEmpty()) { for (String volumeSetEntry : volumeSet) { VolumeInfo volumeInfo = new VolumeInfo(volumeSetEntry); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); if (foundVolumeInfos.size() > 0) { volumeInfos.add(foundVolumeInfos.get(0)); } } } else { VolumeInfo volumeInfo = new VolumeInfo(); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); for (VolumeInfo volInfo : foundVolumeInfos) { volumeInfos.add(volInfo); } } ArrayList<StorageVolume> volumes = reply.getVolumeSet(); for (VolumeInfo volumeInfo : volumeInfos) { volumes.add(convertVolumeInfo(volumeInfo)); } tran.commit(); } return reply; } BlockStorageController();  BlockStorageController(LogicalStorageManager blockManager); }
BlockStorageController implements BlockStorageService { @Override public DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request) throws EucalyptusCloudException { DescribeStorageVolumesResponseType reply = (DescribeStorageVolumesResponseType) request.getReply(); List<String> volumeSet = request.getVolumeSet(); ArrayList<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { if ((volumeSet != null) && !volumeSet.isEmpty()) { for (String volumeSetEntry : volumeSet) { VolumeInfo volumeInfo = new VolumeInfo(volumeSetEntry); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); if (foundVolumeInfos.size() > 0) { volumeInfos.add(foundVolumeInfos.get(0)); } } } else { VolumeInfo volumeInfo = new VolumeInfo(); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); for (VolumeInfo volInfo : foundVolumeInfos) { volumeInfos.add(volInfo); } } ArrayList<StorageVolume> volumes = reply.getVolumeSet(); for (VolumeInfo volumeInfo : volumeInfos) { volumes.add(convertVolumeInfo(volumeInfo)); } 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 DescribeStorageVolumesResponseType DescribeStorageVolumes(DescribeStorageVolumesType request) throws EucalyptusCloudException { DescribeStorageVolumesResponseType reply = (DescribeStorageVolumesResponseType) request.getReply(); List<String> volumeSet = request.getVolumeSet(); ArrayList<VolumeInfo> volumeInfos = new ArrayList<VolumeInfo>(); try (TransactionResource tran = Entities.transactionFor(VolumeInfo.class)) { if ((volumeSet != null) && !volumeSet.isEmpty()) { for (String volumeSetEntry : volumeSet) { VolumeInfo volumeInfo = new VolumeInfo(volumeSetEntry); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); if (foundVolumeInfos.size() > 0) { volumeInfos.add(foundVolumeInfos.get(0)); } } } else { VolumeInfo volumeInfo = new VolumeInfo(); List<VolumeInfo> foundVolumeInfos = Entities.query(volumeInfo); for (VolumeInfo volInfo : foundVolumeInfos) { volumeInfos.add(volInfo); } } ArrayList<StorageVolume> volumes = reply.getVolumeSet(); for (VolumeInfo volumeInfo : volumeInfos) { volumes.add(convertVolumeInfo(volumeInfo)); } 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);  }