|
17 | 17 | package com.cloud.hypervisor.kvm.storage; |
18 | 18 |
|
19 | 19 | import java.io.File; |
| 20 | +import java.io.FileWriter; |
| 21 | +import java.nio.file.Path; |
20 | 22 | import java.util.HashMap; |
21 | 23 | import java.util.List; |
22 | 24 | import java.util.Map; |
@@ -387,20 +389,20 @@ private boolean hasOtherActiveLuns(String host, int port, String iqn, String lun |
387 | 389 | */ |
388 | 390 | private void removeStaleScsiDevice(String host, int port, String iqn, String lun) { |
389 | 391 | String byPath = getByPath(host, port, "/" + iqn + "/" + lun); |
390 | | - java.nio.file.Path byPathLink = java.nio.file.Paths.get(byPath); |
391 | | - if (!java.nio.file.Files.exists(byPathLink)) { |
| 392 | + Path byPathLink = Paths.get(byPath); |
| 393 | + if (!Files.exists(byPathLink)) { |
392 | 394 | logger.debug("by-path entry for LUN " + lun + " already gone, nothing to remove"); |
393 | 395 | return; |
394 | 396 | } |
395 | 397 | try { |
396 | | - java.nio.file.Path realDevice = byPathLink.toRealPath(); |
| 398 | + Path realDevice = byPathLink.toRealPath(); |
397 | 399 | String devName = realDevice.getFileName().toString(); |
398 | | - java.io.File deleteFile = new java.io.File("/sys/block/" + devName + "/device/delete"); |
| 400 | + File deleteFile = new File("/sys/block/" + devName + "/device/delete"); |
399 | 401 | if (!deleteFile.exists()) { |
400 | 402 | logger.warn("sysfs delete entry not found for device " + devName + " — cannot remove stale SCSI device"); |
401 | 403 | return; |
402 | 404 | } |
403 | | - try (java.io.FileWriter fw = new java.io.FileWriter(deleteFile)) { |
| 405 | + try (FileWriter fw = new FileWriter(deleteFile)) { |
404 | 406 | fw.write("1"); |
405 | 407 | } |
406 | 408 | logger.info("Removed stale SCSI device " + devName + " for LUN /" + iqn + "/" + lun + " via sysfs"); |
|
0 commit comments