|
45 | 45 | import com.linbit.linstor.api.model.ApiCallRcList;
|
46 | 46 | import com.linbit.linstor.api.model.Properties;
|
47 | 47 | import com.linbit.linstor.api.model.ProviderKind;
|
| 48 | +import com.linbit.linstor.api.model.Resource; |
48 | 49 | import com.linbit.linstor.api.model.ResourceDefinition;
|
49 | 50 | import com.linbit.linstor.api.model.ResourceDefinitionModify;
|
50 | 51 | import com.linbit.linstor.api.model.ResourceGroup;
|
@@ -306,7 +307,7 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S
|
306 | 307 | public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool)
|
307 | 308 | {
|
308 | 309 | s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath);
|
309 |
| - return true; |
| 310 | + return false; |
310 | 311 | }
|
311 | 312 |
|
312 | 313 | @Override
|
@@ -342,40 +343,44 @@ public boolean disconnectPhysicalDiskByPath(String localPath)
|
342 | 343 | s_logger.debug("Linstor: Using storpool: " + pool.getUuid());
|
343 | 344 | final DevelopersApi api = getLinstorAPI(pool);
|
344 | 345 |
|
345 |
| - try |
346 |
| - { |
| 346 | + Optional<ResourceWithVolumes> optRsc; |
| 347 | + try { |
347 | 348 | List<ResourceWithVolumes> resources = api.viewResources(
|
348 |
| - Collections.singletonList(localNodeName), |
349 |
| - null, |
350 |
| - null, |
351 |
| - null, |
352 |
| - null, |
353 |
| - null); |
354 |
| - |
355 |
| - Optional<ResourceWithVolumes> rsc = getResourceByPath(resources, localPath); |
| 349 | + Collections.singletonList(localNodeName), |
| 350 | + null, |
| 351 | + null, |
| 352 | + null, |
| 353 | + null, |
| 354 | + null); |
| 355 | + |
| 356 | + optRsc = getResourceByPath(resources, localPath); |
| 357 | + } catch (ApiException apiEx) { |
| 358 | + // couldn't query linstor controller |
| 359 | + s_logger.error(apiEx.getBestMessage()); |
| 360 | + return false; |
| 361 | + } |
356 | 362 |
|
357 |
| - if (rsc.isPresent()) |
358 |
| - { |
| 363 | + if (optRsc.isPresent()) { |
| 364 | + try { |
| 365 | + Resource rsc = optRsc.get(); |
359 | 366 | ResourceDefinitionModify rdm = new ResourceDefinitionModify();
|
360 | 367 | rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries"));
|
361 |
| - ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm); |
362 |
| - if (answers.hasError()) |
363 |
| - { |
| 368 | + ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm); |
| 369 | + if (answers.hasError()) { |
364 | 370 | s_logger.error(
|
365 | 371 | String.format("Failed to remove 'allow-two-primaries' on %s: %s",
|
366 |
| - rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers))); |
| 372 | + rsc.getName(), LinstorUtil.getBestErrorMessage(answers))); |
367 | 373 | // do not fail here as removing allow-two-primaries property isn't fatal
|
368 | 374 | }
|
369 |
| - |
370 |
| - return true; |
| 375 | + } catch(ApiException apiEx){ |
| 376 | + s_logger.error(apiEx.getBestMessage()); |
| 377 | + // do not fail here as removing allow-two-primaries property isn't fatal |
371 | 378 | }
|
372 |
| - s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath); |
373 |
| - } catch (ApiException apiEx) { |
374 |
| - s_logger.error(apiEx.getBestMessage()); |
375 |
| - // do not fail here as removing allow-two-primaries property isn't fatal |
| 379 | + return true; |
376 | 380 | }
|
377 | 381 | }
|
378 |
| - return true; |
| 382 | + s_logger.info("Linstor: Couldn't find resource for this path: " + localPath); |
| 383 | + return false; |
379 | 384 | }
|
380 | 385 |
|
381 | 386 | @Override
|
|
0 commit comments