use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class ClusterPolicyListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeClusterPolicyTitle());
model.setHelpTag(HelpTag.remove_cluster_policy);
// $NON-NLS-1$
model.setHashName("remove_cluster_policy");
if (getSelectedItems() == null) {
return;
}
ArrayList<String> list = new ArrayList<>();
for (ClusterPolicy item : getSelectedItems()) {
list.add(item.getName());
}
model.setItems(list);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class ClusterPolicyListModel method cloneEntity.
private void cloneEntity() {
ClusterPolicy clusterPolicy = (ClusterPolicy) Cloner.clone(getSelectedItem());
clusterPolicy.setId(null);
clusterPolicy.setLocked(false);
clusterPolicy.setName(COPY_OF + clusterPolicy.getName());
initClusterPolicy(CommandType.Clone, clusterPolicy);
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class NewClusterPolicyModel method save.
private void save() {
if (getProgress() != null) {
return;
}
if (!validate()) {
return;
}
startProgress();
ClusterPolicy policy = new ClusterPolicy();
policy.setId(clusterPolicy.getId());
policy.setName(getName().getEntity());
policy.setDescription(getDescription().getEntity());
ArrayList<Guid> keys = new ArrayList<>();
for (PolicyUnit clusterPolicy : getUsedFilters()) {
keys.add(clusterPolicy.getId());
}
policy.setFilters(keys);
policy.setFilterPositionMap(getFilterPositionMap());
ArrayList<Pair<Guid, Integer>> pairs = new ArrayList<>();
for (Pair<PolicyUnit, Integer> pair : getUsedFunctions()) {
pairs.add(new Pair<>(pair.getFirst().getId(), pair.getSecond()));
}
policy.setFunctions(pairs);
policy.setBalance(getLoadBalanceList().getSelectedItem().getId());
policy.setParameterMap(KeyValueModel.convertProperties(getCustomPropertySheet().serialize()));
Frontend.getInstance().runAction(commandType == CommandType.Edit ? ActionType.EditClusterPolicy : ActionType.AddClusterPolicy, new ClusterPolicyCRUDParameters(policy.getId(), policy), result -> {
NewClusterPolicyModel.this.stopProgress();
if (result.getReturnValue().getSucceeded()) {
NewClusterPolicyModel.this.cancel();
}
});
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class SchedulingManager method performLoadBalancingImpl.
private void performLoadBalancingImpl() {
log.debug("Load Balancer timer entered.");
List<Cluster> clusters = clusterDao.getAll();
for (Cluster cluster : clusters) {
ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
PolicyUnitImpl policyUnit = policyUnits.get(policy.getBalance());
Optional<BalanceResult> balanceResult = Optional.empty();
if (policyUnit.getPolicyUnit().isEnabled()) {
List<VDS> hosts = vdsDao.getAllForClusterWithoutMigrating(cluster.getId());
if (policyUnit.getPolicyUnit().isInternal()) {
balanceResult = internalRunBalance(policyUnit, cluster, hosts);
} else if (Config.<Boolean>getValue(ConfigValues.ExternalSchedulerEnabled)) {
balanceResult = externalRunBalance(policyUnit, cluster, hosts);
}
}
if (balanceResult.isPresent() && balanceResult.get().isValid()) {
migrationHandler.migrateVM(balanceResult.get().getCandidateHosts(), balanceResult.get().getVmToMigrate(), MessageBundler.getMessage(AuditLogType.MIGRATION_REASON_LOAD_BALANCING));
}
}
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class SchedulingManager method loadClusterPolicies.
private void loadClusterPolicies() {
// Load internal cluster policies
policyMap.putAll(InternalClusterPolicies.getClusterPolicies());
Map<Guid, PolicyUnitType> internalTypes = new HashMap<>();
for (PolicyUnitImpl unit : policyUnits.values()) {
internalTypes.put(unit.getGuid(), unit.getType());
}
// Get all user provided cluster policies
List<ClusterPolicy> allClusterPolicies = clusterPolicyDao.getAll(Collections.unmodifiableMap(internalTypes));
for (ClusterPolicy clusterPolicy : allClusterPolicies) {
policyMap.put(clusterPolicy.getId(), clusterPolicy);
}
}
Aggregations