2929import com .linbit .linstor .api .model .ResourceDefinitionModify ;
3030import com .linbit .linstor .api .model .ResourceGroupSpawn ;
3131import com .linbit .linstor .api .model .ResourceMakeAvailable ;
32- import com .linbit .linstor .api .model .ResourceWithVolumes ;
3332import com .linbit .linstor .api .model .Snapshot ;
3433import com .linbit .linstor .api .model .SnapshotRestore ;
3534import com .linbit .linstor .api .model .VolumeDefinition ;
@@ -342,25 +341,6 @@ private String checkLinstorAnswers(@Nonnull ApiCallRcList answers) {
342341 return answers .stream ().filter (ApiCallRc ::isError ).findFirst ().map (ApiCallRc ::getMessage ).orElse (null );
343342 }
344343
345- private String getDeviceName (DevelopersApi linstorApi , String rscName ) throws ApiException {
346- List <ResourceWithVolumes > resources = linstorApi .viewResources (
347- Collections .emptyList (),
348- Collections .singletonList (rscName ),
349- Collections .emptyList (),
350- null ,
351- null ,
352- null );
353- if (!resources .isEmpty () && !resources .get (0 ).getVolumes ().isEmpty ())
354- {
355- s_logger .info ("Linstor: Created drbd device: " + resources .get (0 ).getVolumes ().get (0 ).getDevicePath ());
356- return resources .get (0 ).getVolumes ().get (0 ).getDevicePath ();
357- } else
358- {
359- s_logger .error ("Linstor: viewResources didn't return resources or volumes." );
360- throw new CloudRuntimeException ("Linstor: viewResources didn't return resources or volumes." );
361- }
362- }
363-
364344 private void applyQoSSettings (StoragePoolVO storagePool , DevelopersApi api , String rscName , Long maxIops )
365345 throws ApiException
366346 {
@@ -446,7 +426,7 @@ private String createResourceBase(
446426
447427 applyAuxProps (api , rscName , volName , vmName );
448428
449- return getDeviceName (api , rscName );
429+ return LinstorUtil . getDevicePath (api , rscName );
450430 } catch (ApiException apiEx )
451431 {
452432 s_logger .error ("Linstor: ApiEx - " + apiEx .getMessage ());
@@ -466,7 +446,7 @@ private String createResource(VolumeInfo vol, StoragePoolVO storagePoolVO) {
466446 {
467447 applyQoSSettings (storagePoolVO , linstorApi , rscName , vol .getMaxIops ());
468448
469- return deviceName ;
449+ return LinstorUtil . getDevicePath ( linstorApi , rscName ) ;
470450 } catch (ApiException apiEx )
471451 {
472452 s_logger .error ("Linstor: ApiEx - " + apiEx .getMessage ());
@@ -519,7 +499,7 @@ private String cloneResource(long csCloneId, VolumeInfo volumeInfo, StoragePoolV
519499 applyAuxProps (linstorApi , rscName , volumeInfo .getName (), volumeInfo .getAttachedVmName ());
520500 applyQoSSettings (storagePoolVO , linstorApi , rscName , volumeInfo .getMaxIops ());
521501
522- return getDeviceName (linstorApi , rscName );
502+ return LinstorUtil . getDevicePath (linstorApi , rscName );
523503 } catch (ApiException apiEx ) {
524504 s_logger .error ("Linstor: ApiEx - " + apiEx .getMessage ());
525505 throw new CloudRuntimeException (apiEx .getBestMessage (), apiEx );
@@ -571,7 +551,7 @@ private String createResourceFromSnapshot(long csSnapshotId, String rscName, Sto
571551 applyAuxProps (linstorApi , rscName , volumeVO .getName (), null );
572552 applyQoSSettings (storagePoolVO , linstorApi , rscName , volumeVO .getMaxIops ());
573553
574- return getDeviceName (linstorApi , rscName );
554+ return LinstorUtil . getDevicePath (linstorApi , rscName );
575555 } catch (ApiException apiEx ) {
576556 s_logger .error ("Linstor: ApiEx - " + apiEx .getMessage ());
577557 throw new CloudRuntimeException (apiEx .getBestMessage (), apiEx );
@@ -940,7 +920,7 @@ private String restoreResourceFromSnapshot(
940920
941921 api .resourceSnapshotRestore (rscName , snapshotName , sr );
942922
943- return getDeviceName (api , restoredName );
923+ return LinstorUtil . getDevicePath (api , restoredName );
944924 }
945925
946926 private Answer copyTemplate (DataObject srcData , DataObject dstData ) {
0 commit comments