use of org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue in project ovirt-engine by oVirt.
the class GetVmFromOvaQuery method runAnsibleQueryOvaInfoPlaybook.
private String runAnsibleQueryOvaInfoPlaybook() {
String hostname = vdsStaticDao.get(getParameters().getVdsId()).getHostName();
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(hostname).variables(new Pair<>("ovirt_query_ova_path", getParameters().getPath())).logFileDirectory(ExtractOvaCommand.IMPORT_OVA_LOG_DIRECTORY).logFilePrefix("ovirt-query-ova-ansible").logFileName(hostname).verboseLevel(AnsibleVerbosity.LEVEL0).stdoutCallback(AnsibleConstants.OVA_QUERY_CALLBACK_PLUGIN).playbook(AnsibleConstants.QUERY_OVA_PLAYBOOK);
boolean succeeded = false;
AnsibleReturnValue ansibleReturnValue = null;
try {
ansibleReturnValue = ansibleExecutor.runCommand(command);
succeeded = ansibleReturnValue.getAnsibleReturnCode() == AnsibleReturnCode.OK;
} catch (IOException | InterruptedException e) {
log.debug("Failed to query OVA info", e);
}
if (!succeeded) {
log.error("Failed to query OVA info");
throw new EngineException(EngineError.GeneralException, "Failed to query OVA info");
}
return ansibleReturnValue.getStdout();
}
Aggregations