use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class InstallVdsInternalCommand method runAnsibleHostDeployPlaybook.
private void runAnsibleHostDeployPlaybook(Cluster hostCluster) throws IOException, InterruptedException {
// TODO: Remove when we remove support for legacy oVirt node:
if (getVds().getVdsType().equals(VDSType.oVirtVintageNode)) {
log.warn("Skipping Ansible runner, because it isn't supported for legacy oVirt node.");
return;
}
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("host_deploy_cluster_version", hostCluster.getCompatibilityVersion()), new Pair<>("host_deploy_cluster_name", hostCluster.getName()), new Pair<>("host_deploy_gluster_enabled", hostCluster.supportsGlusterService()), new Pair<>("host_deploy_virt_enabled", hostCluster.supportsVirtService()), new Pair<>("host_deploy_vdsm_port", getVds().getPort()), new Pair<>("host_deploy_override_firewall", getParameters().getOverrideFirewall()), new Pair<>("host_deploy_firewall_type", hostCluster.getFirewallType().name()), new Pair<>("ansible_port", getVds().getSshPort()), new Pair<>("host_deploy_post_tasks", AnsibleConstants.HOST_DEPLOY_POST_TASKS_FILE_PATH), new Pair<>("host_deploy_ovn_tunneling_interface", NetworkUtils.getHostIp(getVds())), new Pair<>("host_deploy_ovn_central", getOvnCentral())).logFileDirectory(VdsDeployBase.HOST_DEPLOY_LOG_DIRECTORY).logFilePrefix("ovirt-host-deploy-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.HOST_DEPLOY_PLAYBOOK);
AuditLogable logable = new AuditLogableImpl();
logable.setVdsName(getVds().getName());
logable.setVdsId(getVds().getId());
logable.setCorrelationId(getCorrelationId());
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_STARTED);
AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
throw new VdsInstallException(VDSStatus.InstallFailed, String.format("Failed to execute Ansible host-deploy role. Please check logs for more details: %1$s", command.logFile()));
}
auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_FINISHED);
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class GetGlusterVolumeSnapshotConfigQuery method getConfigPair.
private Pair<List<GlusterVolumeSnapshotConfig>, List<GlusterVolumeSnapshotConfig>> getConfigPair(List<GlusterVolumeSnapshotConfig> configs) {
List<GlusterVolumeSnapshotConfig> clusterCfgs = new ArrayList<>();
List<GlusterVolumeSnapshotConfig> volumeCfgs = new ArrayList<>();
for (GlusterVolumeSnapshotConfig config : configs) {
if (Guid.isNullOrEmpty(config.getVolumeId())) {
clusterCfgs.add(config);
} else if (getParameters().getVolumeId() != null && config.getVolumeId().equals(getParameters().getVolumeId())) {
volumeCfgs.add(config);
}
}
return new Pair<>(clusterCfgs, volumeCfgs);
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class UpdateVmDiskCommand method loadVmDiskAttachedToInfo.
private void loadVmDiskAttachedToInfo() {
if (getOldDisk() != null) {
List<Pair<VM, VmDevice>> attachedVmsInfo = vmDao.getVmsWithPlugInfo(getOldDisk().getId());
for (Pair<VM, VmDevice> pair : attachedVmsInfo) {
VM vm = pair.getFirst();
vmsDiskOrSnapshotAttachedTo.add(vm);
if (Boolean.TRUE.equals(pair.getSecond().isPlugged())) {
if (pair.getSecond().getSnapshotId() != null) {
vmsDiskSnapshotPluggedTo.add(vm);
} else {
vmsDiskPluggedTo.add(vm);
}
vmsDiskOrSnapshotPluggedTo.add(vm);
}
if (vm.getId().equals(getParameters().getVmId())) {
vmDeviceForVm = pair.getSecond();
}
}
}
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class BaseImagesCommand method lockVmSnapshotsWithWait.
protected void lockVmSnapshotsWithWait(VM vm) {
snapshotsEngineLock = new EngineLock();
Map<String, Pair<String, String>> snapshotsExlusiveLockMap = Collections.singletonMap(vm.getId().toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.VM_SNAPSHOTS, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
snapshotsEngineLock.setExclusiveLocks(snapshotsExlusiveLockMap);
lockManager.acquireLockWait(snapshotsEngineLock);
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class ConnectStorageToVdsCommand method connectHostToStorage.
protected Pair<Boolean, Integer> connectHostToStorage() {
List<StorageServerConnections> connections = Arrays.asList(getConnection());
if (getConnection().getStorageType() == StorageType.ISCSI) {
connections = iscsiStorageHelper.updateIfaces(connections, getVds().getId());
}
Map<String, String> result = (HashMap<String, String>) runVdsCommand(VDSCommandType.ConnectStorageServer, new StorageServerConnectionManagementVDSParameters(getVds().getId(), Guid.Empty, getConnection().getStorageType(), connections)).getReturnValue();
return new Pair<>(storageHelperDirector.getItem(getConnection().getStorageType()).isConnectSucceeded(result, connections), Integer.parseInt(result.values().iterator().next()));
}
Aggregations