use of org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType in project ovirt-engine by oVirt.
the class FenceProxyModel method setCurrentProxies.
private void setCurrentProxies(ListModel<FenceProxyModel> currentProxies) {
this.currentProxies = currentProxies;
// Determine the already selected proxy types.
List<FenceProxySourceType> currentSourceTypes = new ArrayList<>();
for (FenceProxyModel currentProxyModel : currentProxies.getItems()) {
if (currentProxyModel.getEntity() != null) {
currentSourceTypes.add(currentProxyModel.getEntity());
}
}
this.availableProxies.setItems(null);
// Determine the available proxy types.
List<FenceProxyModel> availableProxiesList = new ArrayList<>();
for (FenceProxySourceType type : FenceProxySourceType.values()) {
if (!currentSourceTypes.contains(type)) {
FenceProxyModel newModel = new FenceProxyModel();
newModel.setEntity(type);
availableProxiesList.add(newModel);
}
}
this.availableProxies.setItems(availableProxiesList);
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType in project ovirt-engine by oVirt.
the class HostMapper method map.
@Mapping(from = PowerManagement.class, to = VdsStatic.class)
public static VdsStatic map(PowerManagement model, VdsStatic template) {
VdsStatic entity = template != null ? template : new VdsStatic();
if (model.isSetEnabled()) {
entity.setPmEnabled(model.isEnabled());
}
if (model.isSetAutomaticPmEnabled()) {
entity.setDisablePowerManagementPolicy(!model.isAutomaticPmEnabled());
}
if (model.isSetPmProxies()) {
List<FenceProxySourceType> fenceProxySources = model.getPmProxies().getPmProxies().stream().map(pmProxy -> FenceProxySourceType.forValue(pmProxy.getType().toString())).collect(toCollection(LinkedList::new));
entity.setFenceProxySources(fenceProxySources);
}
if (model.isSetKdumpDetection()) {
entity.setPmKdumpDetection(model.isKdumpDetection());
}
return entity;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType in project ovirt-engine by oVirt.
the class FenceProxyLocator method findProxyHost.
public VDS findProxyHost(boolean withRetries, Guid excludedHostId) {
int retries = getFindFenceProxyRetries();
long delayInMs = getDelayBetweenRetries();
VDS proxyHost = null;
// get PM Proxy preferences or use defaults if not defined
for (FenceProxySourceType fenceProxySource : getFenceProxySources()) {
proxyHost = selectBestProxy(fenceProxySource, excludedHostId);
int count = 0;
// If can not find a proxy host retry and delay between retries as configured.
while (proxyHost == null && withRetries && count < retries) {
log.warn("Attempt {} to find fence proxy for host '{}' failed...", ++count, fencedHost.getHostName());
ThreadUtils.sleep(delayInMs);
proxyHost = selectBestProxy(fenceProxySource, excludedHostId);
}
if (proxyHost != null) {
break;
}
}
if (proxyHost == null) {
log.error("Can not run fence action on host '{}', no suitable proxy host was found.", fencedHost.getName());
return null;
}
return proxyHost;
}
use of org.ovirt.engine.core.common.businessentities.pm.FenceProxySourceType in project ovirt-engine by oVirt.
the class HostMapper method map.
@Mapping(from = VDS.class, to = PowerManagement.class)
public static PowerManagement map(VDS entity, PowerManagement template) {
PowerManagement model = template != null ? template : new PowerManagement();
if (entity.getFenceProxySources() != null) {
PmProxies pmProxies = new PmProxies();
for (FenceProxySourceType fenceProxySource : entity.getFenceProxySources()) {
PmProxy pmProxy = new PmProxy();
pmProxy.setType(map(fenceProxySource, null));
pmProxies.getPmProxies().add(pmProxy);
}
model.setPmProxies(pmProxies);
}
model.setKdumpDetection(entity.isPmKdumpDetection());
model.setEnabled(entity.isPmEnabled());
model.setAutomaticPmEnabled(!entity.isDisablePowerManagementPolicy());
return model;
}
Aggregations