Search in sources :

Example 6 with AnsibleReturnValue

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();
}
Also used : AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) EngineException(org.ovirt.engine.core.common.errors.EngineException) IOException(java.io.IOException)

Aggregations

AnsibleCommandBuilder (org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder)6 AnsibleReturnValue (org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue)6 IOException (java.io.IOException)3 Pair (org.ovirt.engine.core.common.utils.Pair)3 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)3 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 ArrayList (java.util.ArrayList)1 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)1 StorageDevice (org.ovirt.engine.core.common.businessentities.gluster.StorageDevice)1 SizeUnit (org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit)1