|
28 | 28 | import com.linbit.linstor.api.model.ResourceDefinitionCreate; |
29 | 29 | import com.linbit.linstor.api.model.ResourceDefinitionModify; |
30 | 30 | import com.linbit.linstor.api.model.ResourceGroupSpawn; |
31 | | -import com.linbit.linstor.api.model.ResourceWithVolumes; |
32 | 31 | import com.linbit.linstor.api.model.Snapshot; |
33 | 32 | import com.linbit.linstor.api.model.SnapshotRestore; |
34 | 33 | import com.linbit.linstor.api.model.VolumeDefinition; |
|
38 | 37 | import javax.inject.Inject; |
39 | 38 |
|
40 | 39 | import java.util.Arrays; |
41 | | -import java.util.Collections; |
42 | 40 | import java.util.HashMap; |
43 | 41 | import java.util.List; |
44 | 42 | import java.util.Map; |
@@ -315,25 +313,6 @@ private String checkLinstorAnswers(@Nonnull ApiCallRcList answers) { |
315 | 313 | return answers.stream().filter(ApiCallRc::isError).findFirst().map(ApiCallRc::getMessage).orElse(null); |
316 | 314 | } |
317 | 315 |
|
318 | | - private String getDeviceName(DevelopersApi linstorApi, String rscName) throws ApiException { |
319 | | - List<ResourceWithVolumes> resources = linstorApi.viewResources( |
320 | | - Collections.emptyList(), |
321 | | - Collections.singletonList(rscName), |
322 | | - Collections.emptyList(), |
323 | | - null, |
324 | | - null, |
325 | | - null); |
326 | | - if (!resources.isEmpty() && !resources.get(0).getVolumes().isEmpty()) |
327 | | - { |
328 | | - s_logger.info("Linstor: Created drbd device: " + resources.get(0).getVolumes().get(0).getDevicePath()); |
329 | | - return resources.get(0).getVolumes().get(0).getDevicePath(); |
330 | | - } else |
331 | | - { |
332 | | - s_logger.error("Linstor: viewResources didn't return resources or volumes."); |
333 | | - throw new CloudRuntimeException("Linstor: viewResources didn't return resources or volumes."); |
334 | | - } |
335 | | - } |
336 | | - |
337 | 316 | private void applyQoSSettings(StoragePoolVO storagePool, DevelopersApi api, String rscName, Long maxIops) |
338 | 317 | throws ApiException |
339 | 318 | { |
@@ -420,7 +399,7 @@ private String createResource(VolumeInfo vol, StoragePoolVO storagePoolVO) |
420 | 399 | applyAuxProps(linstorApi, rscName, vol.getName(), vol.getAttachedVmName()); |
421 | 400 | applyQoSSettings(storagePoolVO, linstorApi, rscName, vol.getMaxIops()); |
422 | 401 |
|
423 | | - return getDeviceName(linstorApi, rscName); |
| 402 | + return LinstorUtil.getDevicePath(linstorApi, rscName); |
424 | 403 | } catch (ApiException apiEx) |
425 | 404 | { |
426 | 405 | s_logger.error("Linstor: ApiEx - " + apiEx.getMessage()); |
@@ -473,7 +452,7 @@ private String cloneResource(long csCloneId, VolumeInfo volumeInfo, StoragePoolV |
473 | 452 | applyAuxProps(linstorApi, rscName, volumeInfo.getName(), volumeInfo.getAttachedVmName()); |
474 | 453 | applyQoSSettings(storagePoolVO, linstorApi, rscName, volumeInfo.getMaxIops()); |
475 | 454 |
|
476 | | - return getDeviceName(linstorApi, rscName); |
| 455 | + return LinstorUtil.getDevicePath(linstorApi, rscName); |
477 | 456 | } catch (ApiException apiEx) { |
478 | 457 | s_logger.error("Linstor: ApiEx - " + apiEx.getMessage()); |
479 | 458 | throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx); |
@@ -520,7 +499,7 @@ private String createResourceFromSnapshot(long csSnapshotId, String rscName, Sto |
520 | 499 | applyAuxProps(linstorApi, rscName, volumeVO.getName(), null); |
521 | 500 | applyQoSSettings(storagePoolVO, linstorApi, rscName, volumeVO.getMaxIops()); |
522 | 501 |
|
523 | | - return getDeviceName(linstorApi, rscName); |
| 502 | + return LinstorUtil.getDevicePath(linstorApi, rscName); |
524 | 503 | } catch (ApiException apiEx) { |
525 | 504 | s_logger.error("Linstor: ApiEx - " + apiEx.getMessage()); |
526 | 505 | throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx); |
|
0 commit comments