mirror of https://github.com/apache/cloudstack.git
Address review comments
This commit is contained in:
parent
037ac0ecbd
commit
baf02101bb
|
|
@ -128,6 +128,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
|||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.Volume.State;
|
||||
import com.cloud.storage.VolumeApiServiceImpl;
|
||||
import com.cloud.storage.VolumeDetailVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
|
|
@ -2768,7 +2769,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
@Override
|
||||
public void checkAndRepairVolumeBasedOnConfig(DataObject dataObject, Host host) {
|
||||
if (HypervisorType.KVM.equals(host.getHypervisorType()) && DataObjectType.VOLUME.equals(dataObject.getType())) {
|
||||
if (com.cloud.storage.VolumeApiServiceImpl.AllowCheckAndRepairVolume.value()) {
|
||||
if (VolumeApiServiceImpl.AllowCheckAndRepairVolume.value()) {
|
||||
s_logger.info(String.format("Trying to check and repair the volume %d", dataObject.getId()));
|
||||
String repair = CheckAndRepairVolumeCmd.RepairValues.LEAKS.name().toLowerCase();
|
||||
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class LibvirtCheckAndRepairVolumeCommandWrapper extends CommandWrapper<Ch
|
|||
QemuObject.EncryptFormat encryptFormat = QemuObject.EncryptFormat.enumValue(command.getEncryptFormat());
|
||||
byte[] passphrase = command.getPassphrase();
|
||||
try {
|
||||
String checkVolumeResult = checkAndRepairVolume(vol, repair, encryptFormat, passphrase, serverResource);
|
||||
String checkVolumeResult = checkAndRepairVolume(vol, null, encryptFormat, passphrase, serverResource);
|
||||
s_logger.info(String.format("Check Volume result for the volume %s is %s", vol.getName(), checkVolumeResult));
|
||||
CheckAndRepairVolumeAnswer answer = new CheckAndRepairVolumeAnswer(command, true, checkVolumeResult);
|
||||
answer.setVolumeCheckExecutionResult(checkVolumeResult);
|
||||
|
|
@ -77,7 +77,7 @@ public class LibvirtCheckAndRepairVolumeCommandWrapper extends CommandWrapper<Ch
|
|||
JsonNode jsonNode = objectMapper.readTree(checkVolumeResult);
|
||||
JsonNode leaksNode = jsonNode.get("leaks");
|
||||
if (leaksNode != null) {
|
||||
leaks = jsonNode.asInt();
|
||||
leaks = leaksNode.asInt();
|
||||
}
|
||||
|
||||
if (leaks == 0) {
|
||||
|
|
|
|||
|
|
@ -824,29 +824,29 @@ public class QemuImg {
|
|||
* Boolean option whether to repair any leaks
|
||||
*/
|
||||
public String checkAndRepair(final QemuImgFile file, final QemuImageOptions imageOptions, final List<QemuObject> qemuObjects, final String repair) throws QemuImgException {
|
||||
final Script s = new Script(_qemuImgPath);
|
||||
s.add("check");
|
||||
final Script script = new Script(_qemuImgPath);
|
||||
script.add("check");
|
||||
if (imageOptions == null) {
|
||||
s.add(file.getFileName());
|
||||
script.add(file.getFileName());
|
||||
}
|
||||
|
||||
for (QemuObject o : qemuObjects) {
|
||||
s.add(o.toCommandFlag());
|
||||
script.add(o.toCommandFlag());
|
||||
}
|
||||
|
||||
if (imageOptions != null) {
|
||||
s.add(imageOptions.toCommandFlag());
|
||||
script.add(imageOptions.toCommandFlag());
|
||||
}
|
||||
|
||||
s.add("--output=json");
|
||||
script.add("--output=json");
|
||||
|
||||
if (StringUtils.isNotEmpty(repair)) {
|
||||
s.add("-r");
|
||||
s.add(repair);
|
||||
script.add("-r");
|
||||
script.add(repair);
|
||||
}
|
||||
|
||||
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
|
||||
final String result = s.execute(parser);
|
||||
final String result = script.execute(parser);
|
||||
if (result != null) {
|
||||
throw new QemuImgException(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1340,7 +1340,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation was interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution exception", e);
|
||||
}
|
||||
|
||||
|
|
@ -1853,7 +1853,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution exception--", e);
|
||||
}
|
||||
|
||||
|
|
@ -1922,10 +1922,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
throw new InvalidParameterValueException("Checking volume and repairing failed due to volume:" + volumeId + " doesn't exist");
|
||||
}
|
||||
|
||||
if (volume.getState() != Volume.State.Ready) {
|
||||
throw new InvalidParameterValueException("VolumeId: " + volumeId + " is not in " + Volume.State.Ready + " state but " + volume.getState() + ". Cannot check and repair the volume.");
|
||||
}
|
||||
|
||||
CheckAndRepairVolumePayload payload = new CheckAndRepairVolumePayload(repair);
|
||||
volume.addPayload(payload);
|
||||
|
||||
|
|
@ -2132,7 +2128,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation was interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution exception", e);
|
||||
}
|
||||
|
||||
|
|
@ -2918,7 +2914,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution excetion", e);
|
||||
}
|
||||
|
||||
|
|
@ -3326,7 +3322,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution excetion", e);
|
||||
}
|
||||
|
||||
|
|
@ -3655,7 +3651,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution excetion", e);
|
||||
}
|
||||
|
||||
|
|
@ -3972,7 +3968,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
outcome.get();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Operation is interrupted", e);
|
||||
} catch (java.util.concurrent.ExecutionException e) {
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("Execution excetion", e);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue