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;
}
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));
}
}
}
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);
}
}
}
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();
}
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);
}
Aggregations