|
41 | 41 | import com.linbit.linstor.api.model.ApiCallRcList; |
42 | 42 | import com.linbit.linstor.api.model.Properties; |
43 | 43 | import com.linbit.linstor.api.model.ProviderKind; |
| 44 | +import com.linbit.linstor.api.model.Resource; |
44 | 45 | import com.linbit.linstor.api.model.ResourceDefinition; |
45 | 46 | import com.linbit.linstor.api.model.ResourceDefinitionModify; |
46 | 47 | import com.linbit.linstor.api.model.ResourceGroupSpawn; |
@@ -293,7 +294,7 @@ public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<S |
293 | 294 | public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool pool) |
294 | 295 | { |
295 | 296 | s_logger.debug("Linstor: disconnectPhysicalDisk " + pool.getUuid() + ":" + volumePath); |
296 | | - return true; |
| 297 | + return false; |
297 | 298 | } |
298 | 299 |
|
299 | 300 | @Override |
@@ -329,40 +330,44 @@ public boolean disconnectPhysicalDiskByPath(String localPath) |
329 | 330 | s_logger.debug("Linstor: Using storpool: " + pool.getUuid()); |
330 | 331 | final DevelopersApi api = getLinstorAPI(pool); |
331 | 332 |
|
332 | | - try |
333 | | - { |
| 333 | + Optional<ResourceWithVolumes> optRsc; |
| 334 | + try { |
334 | 335 | List<ResourceWithVolumes> resources = api.viewResources( |
335 | | - Collections.singletonList(localNodeName), |
336 | | - null, |
337 | | - null, |
338 | | - null, |
339 | | - null, |
340 | | - null); |
341 | | - |
342 | | - Optional<ResourceWithVolumes> rsc = getResourceByPath(resources, localPath); |
| 336 | + Collections.singletonList(localNodeName), |
| 337 | + null, |
| 338 | + null, |
| 339 | + null, |
| 340 | + null, |
| 341 | + null); |
| 342 | + |
| 343 | + optRsc = getResourceByPath(resources, localPath); |
| 344 | + } catch (ApiException apiEx) { |
| 345 | + // couldn't query linstor controller |
| 346 | + s_logger.error(apiEx.getBestMessage()); |
| 347 | + return false; |
| 348 | + } |
343 | 349 |
|
344 | | - if (rsc.isPresent()) |
345 | | - { |
| 350 | + if (optRsc.isPresent()) { |
| 351 | + try { |
| 352 | + Resource rsc = optRsc.get(); |
346 | 353 | ResourceDefinitionModify rdm = new ResourceDefinitionModify(); |
347 | 354 | rdm.deleteProps(Collections.singletonList("DrbdOptions/Net/allow-two-primaries")); |
348 | | - ApiCallRcList answers = api.resourceDefinitionModify(rsc.get().getName(), rdm); |
349 | | - if (answers.hasError()) |
350 | | - { |
| 355 | + ApiCallRcList answers = api.resourceDefinitionModify(rsc.getName(), rdm); |
| 356 | + if (answers.hasError()) { |
351 | 357 | s_logger.error( |
352 | 358 | String.format("Failed to remove 'allow-two-primaries' on %s: %s", |
353 | | - rsc.get().getName(), LinstorUtil.getBestErrorMessage(answers))); |
| 359 | + rsc.getName(), LinstorUtil.getBestErrorMessage(answers))); |
354 | 360 | // do not fail here as removing allow-two-primaries property isn't fatal |
355 | 361 | } |
356 | | - |
357 | | - return true; |
| 362 | + } catch(ApiException apiEx){ |
| 363 | + s_logger.error(apiEx.getBestMessage()); |
| 364 | + // do not fail here as removing allow-two-primaries property isn't fatal |
358 | 365 | } |
359 | | - s_logger.warn("Linstor: Couldn't find resource for this path: " + localPath); |
360 | | - } catch (ApiException apiEx) { |
361 | | - s_logger.error(apiEx.getBestMessage()); |
362 | | - // do not fail here as removing allow-two-primaries property isn't fatal |
| 366 | + return true; |
363 | 367 | } |
364 | 368 | } |
365 | | - return true; |
| 369 | + s_logger.info("Linstor: Couldn't find resource for this path: " + localPath); |
| 370 | + return false; |
366 | 371 | } |
367 | 372 |
|
368 | 373 | @Override |
|
0 commit comments