Search in sources :

Example 1 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class IrsProxy method getPrioritizedVdsInPool.

private List<VDS> getPrioritizedVdsInPool() {
    Guid curVdsId = (currentVdsId != null) ? currentVdsId : Guid.Empty;
    // Gets a list of the hosts in the storagePool, that are "UP", ordered
    // by vds_spm_priority (not including -1) and secondly ordered by RANDOM(), to
    // deal with the case that there are several hosts with the same priority.
    List<VDS> allVds = vdsDao.getListForSpmSelection(storagePoolId);
    List<VDS> vdsRelevantForSpmSelection = new ArrayList<>();
    Guid preferredHost = getIrsProxyManager().getProxy(storagePoolId).getPreferredHostId();
    getIrsProxyManager().getProxy(storagePoolId).setPreferredHostId(null);
    for (VDS vds : allVds) {
        if (!triedVdssList.contains(vds.getId()) && !vds.getId().equals(curVdsId)) {
            if (vds.getId().equals(preferredHost)) {
                vdsRelevantForSpmSelection.add(0, vds);
            } else {
                vdsRelevantForSpmSelection.add(vds);
            }
        }
    }
    return vdsRelevantForSpmSelection;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class IrsProxy method hostsStorageConnectionsAndPoolMetadataRefresh.

@OnTimerMethodAnnotation("hostsStorageConnectionsAndPoolMetadataRefresh")
public void hostsStorageConnectionsAndPoolMetadataRefresh() {
    Map<Guid, Guid> reportsToHandle = procceedReportsThreatmenet();
    if (reportsToHandle.isEmpty()) {
        return;
    }
    List<Callable<Void>> connectStorageTasks = new ArrayList<>();
    final List<Callable<Void>> refreshStoragePoolTasks = new ArrayList<>();
    final StoragePool storagePool = storagePoolDao.get(storagePoolId);
    final Guid masterDomainId = storageDomainDao.getMasterStorageDomainIdForPool(storagePoolId);
    final List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    Map<String, Pair<String, String>> acquiredLocks = new HashMap<>();
    try {
        for (Map.Entry<Guid, Guid> entry : reportsToHandle.entrySet()) {
            Guid vdsId = entry.getKey();
            Guid currentReportId = entry.getValue();
            vdsHandeledReportsOnUnseenDomains.put(vdsId, currentReportId);
            Map<String, Pair<String, String>> lockMap = Collections.singletonMap(vdsId.toString(), new Pair<>(LockingGroup.VDS_POOL_AND_STORAGE_CONNECTIONS.toString(), EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED.toString()));
            EngineLock engineLock = new EngineLock(lockMap, null);
            if (!lockManager.acquireLock(engineLock).getFirst()) {
                log.info("Failed to acquire lock to refresh storage connection and pool metadata for host '{}', skipping it", vdsId);
                continue;
            }
            final VDS vds = vdsDao.get(entry.getKey());
            if (vds.getStatus() != VDSStatus.Up) {
                log.info("Skipping storage connection and pool metadata information for host '{}' as it's no longer in status UP", vdsId);
                lockManager.releaseLock(engineLock);
                continue;
            }
            acquiredLocks.putAll(lockMap);
            connectStorageTasks.add(() -> {
                getEventListener().connectHostToDomainsInActiveOrUnknownStatus(vds);
                return null;
            });
            refreshStoragePoolTasks.add(() -> {
                storagePoolDomainHelper.refreshHostPoolMetadata(vds, storagePool, masterDomainId, storagePoolIsoMap);
                return null;
            });
        }
        final Set<String> handledHosts = acquiredLocks.keySet();
        log.info("Running storage connections refresh for hosts '{}'", handledHosts);
        ThreadPoolUtil.invokeAll(connectStorageTasks);
        log.info("Submitting to the event queue pool refresh for hosts '{}'", handledHosts);
        getEventQueue().submitEventSync(new Event(storagePoolId, null, null, EventType.POOLREFRESH, ""), () -> {
            log.info("Running storage pool metadata refresh for hosts '{}'", handledHosts);
            ThreadPoolUtil.invokeAll(refreshStoragePoolTasks);
            return new EventResult(true, EventType.POOLREFRESH);
        });
    } finally {
        if (!acquiredLocks.isEmpty()) {
            lockManager.releaseLock(new EngineLock(acquiredLocks, null));
        }
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) VDS(org.ovirt.engine.core.common.businessentities.VDS) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) Callable(java.util.concurrent.Callable) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) Event(org.ovirt.engine.core.common.eventqueue.Event) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Pair(org.ovirt.engine.core.common.utils.Pair) OnTimerMethodAnnotation(org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation)

Example 3 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class VirtMonitoringStrategy method checkIfNotMixingRhels.

/**
 * Sets the new host to non-operational if adding a RHEL6 machine to a cluster with RHEL7s or RHEL7 to cluster with RHEL6s
 *
 * It tries to be as non-invasive as possible and only if the above is the case, turns the host into non-operational.
 */
private void checkIfNotMixingRhels(VDS vds, Cluster cluster) {
    if (vds.getHostOs() == null) {
        return;
    }
    String[] hostOsInfo = vds.getHostOs().split("-");
    if (hostOsInfo.length != 3) {
        return;
    }
    String newOsName = hostOsInfo[0].trim();
    String newRelease = hostOsInfo[2].trim();
    // both the CentOS and RHEL has osName RHEL
    if (newOsName.equals("RHEL") || newOsName.equals("oVirt Node") || newOsName.equals("RHEV Hypervisor")) {
        VDS beforeRhel = vdsDao.getFirstUpRhelForCluster(cluster.getId());
        boolean firstHostInCluster = beforeRhel == null;
        if (firstHostInCluster) {
            // no need to do any checks
            return;
        }
        // if not first host in cluster, need to check if the version is the same
        if (beforeRhel.getHostOs() == null) {
            return;
        }
        String[] prevOsInfo = beforeRhel.getHostOs().split("-");
        if (prevOsInfo.length != 3) {
            return;
        }
        String prevRelease = prevOsInfo[2].trim();
        boolean addingRhel6toRhel7 = newRelease.contains("el6") && prevRelease.contains("el7");
        boolean addingRhel7toRhel6 = newRelease.contains("el7") && prevRelease.contains("el6");
        if (addingRhel7toRhel6 || addingRhel6toRhel7) {
            Map<String, String> customLogValues = new HashMap<>();
            customLogValues.put("previousRhel", beforeRhel.getHostOs());
            customLogValues.put("addingRhel", vds.getHostOs());
            vdsNonOperational(vds, NonOperationalReason.MIXING_RHEL_VERSIONS_IN_CLUSTER, customLogValues);
            vds.setStatus(VDSStatus.NonOperational);
        }
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap)

Example 4 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class ClusterGuideModel method updateOptionsNonLocalFS.

private void updateOptionsNonLocalFS() {
    if (hosts == null || allHosts == null || !isUpHostCheckCompleted()) {
        return;
    }
    if (getEntity() == null) {
        stopProgress();
        setWindow(null);
        return;
    }
    // Add host action.
    UICommand addHostAction = new UICommand(ADD_HOST, this);
    if (hosts.size() > 1) {
        hosts.remove(0);
    }
    if (hosts.isEmpty()) {
        addHostAction.setTitle(clusterConfigureHostsActionTitle);
        getCompulsoryActions().add(addHostAction);
    } else if (isAnyUpHostInCluster()) {
        addHostAction.setTitle(clusterAddAnotherHostActionTitle);
        getOptionalActions().add(addHostAction);
    }
    if (getEntity().getStoragePoolId() == null) {
        addHostAction.getExecuteProhibitionReasons().add(ConstantsManager.getInstance().getConstants().theClusterIsntAttachedToADcClusterGuide());
        addHostAction.setIsExecutionAllowed(false);
        return;
    }
    ArrayList<VDS> availableHosts = new ArrayList<>();
    for (VDS vds : allHosts) {
        if (!getEntity().getId().equals(vds.getClusterId()) && (vds.getStatus() == VDSStatus.Maintenance || vds.getStatus() == VDSStatus.PendingApproval) && vds.getSupportedClusterVersionsSet() != null && vds.getSupportedClusterVersionsSet().contains(getEntity().getCompatibilityVersion())) {
            availableHosts.add(vds);
        }
    }
    // Select host action.
    UICommand selectHostAction = new UICommand(SELECT_HOST, this);
    if (availableHosts.size() > 0) {
        if (hosts.isEmpty()) {
            selectHostAction.setTitle(selectHostsActionTitle);
            getCompulsoryActions().add(selectHostAction);
        } else if (isAnyUpHostInCluster()) {
            selectHostAction.setTitle(selectHostsActionTitle);
            getOptionalActions().add(selectHostAction);
        }
    }
    stopProgress();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 5 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class ClusterGuideModel method onAddHost.

public void onAddHost() {
    cancelConfirm();
    HostModel model = (HostModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    // Save changes.
    VDS host = new VDS();
    host.setVdsName(model.getName().getEntity());
    host.setHostName(model.getHost().getEntity());
    host.setPort(model.getPort().getEntity());
    host.setSshPort(model.getAuthSshPort().getEntity());
    host.setSshUsername(model.getUserName().getEntity());
    host.setSshKeyFingerprint(model.getFetchSshFingerprint().getEntity());
    host.setClusterId(model.getCluster().getSelectedItem().getId());
    host.setVdsSpmPriority(model.getSpmPriorityValue());
    // Save other PM parameters.
    host.setPmEnabled(model.getIsPm().getEntity());
    host.setDisablePowerManagementPolicy(model.getDisableAutomaticPowerManagement().getEntity());
    host.setPmKdumpDetection(model.getPmKdumpDetection().getEntity());
    AddVdsActionParameters vdsActionParams = new AddVdsActionParameters();
    vdsActionParams.setvds(host);
    vdsActionParams.setVdsId(host.getId());
    if (model.getUserPassword().getEntity() != null) {
        vdsActionParams.setPassword(model.getUserPassword().getEntity());
    }
    vdsActionParams.setAuthMethod(model.getAuthenticationMethod());
    vdsActionParams.setOverrideFirewall(model.getOverrideIpTables().getEntity());
    vdsActionParams.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
    model.startProgress();
    Frontend.getInstance().runAction(ActionType.AddVds, vdsActionParams, result -> {
        ClusterGuideModel localModel = (ClusterGuideModel) result.getState();
        localModel.postOnAddHost(result.getReturnValue());
    }, this);
}
Also used : HostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel) NewHostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.NewHostModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)

Aggregations

VDS (org.ovirt.engine.core.common.businessentities.VDS)578 ArrayList (java.util.ArrayList)160 Test (org.junit.Test)138 Guid (org.ovirt.engine.core.compat.Guid)132 List (java.util.List)78 VM (org.ovirt.engine.core.common.businessentities.VM)65 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)55 HashMap (java.util.HashMap)53 HashSet (java.util.HashSet)48 Map (java.util.Map)45 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)42 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)42 Set (java.util.Set)40 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)39 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)38 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)38 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)37 Frontend (org.ovirt.engine.ui.frontend.Frontend)35