use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class RegisterEntityModel method updateExternalVnicProfilesPerTargetCluster.
/**
* on first call: create new mappings with no target profile for each interface of the entities being registered.
* on subsequent calls: repopulate with existing mappings and user selections
*/
private Map<Cluster, Set<VnicProfileMappingEntity>> updateExternalVnicProfilesPerTargetCluster() {
Map<Cluster, Set<VnicProfileMappingEntity>> updated = new HashMap<>();
// the update may be for several VMs or VmTemplates over various clusters
for (E importEntityData : getEntities().getItems()) {
Cluster cluster = importEntityData.getCluster().getSelectedItem();
// get the set of profiles being updated for the cluster or create new
Set<VnicProfileMappingEntity> clusterVnicProfileMappings;
if (updated.containsKey(cluster)) {
clusterVnicProfileMappings = updated.get(cluster);
} else {
clusterVnicProfileMappings = new HashSet<>();
updated.put(cluster, clusterVnicProfileMappings);
}
// get the previous set of profiles for the cluster or create new
Set<VnicProfileMappingEntity> previousClusterVnicProfileMappings;
if (externalVnicProfilesPerTargetCluster.containsKey(cluster)) {
previousClusterVnicProfileMappings = externalVnicProfilesPerTargetCluster.get(cluster);
} else {
previousClusterVnicProfileMappings = new HashSet<>();
}
// create or set mappings according to currently existing interfaces and previous user selections
Set<VnicProfileMappingEntity> vmVnicProfiles = getNewVnicProfileMappings(getInterfaces(importEntityData), previousClusterVnicProfileMappings);
clusterVnicProfileMappings.addAll(vmVnicProfiles);
}
return updated;
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class RegisterEntityModel method updateClusterQuota.
private void updateClusterQuota(List<Cluster> clusters) {
if (!isQuotaEnabled()) {
return;
}
List<QueryType> queries = new ArrayList<>();
List<QueryParametersBase> params = new ArrayList<>();
for (Cluster cluster : clusters) {
queries.add(QueryType.GetAllRelevantQuotasForCluster);
params.add(new IdQueryParameters(cluster.getId()));
}
Frontend.getInstance().runMultipleQueries(queries, params, result -> {
Map<Guid, List<Quota>> clusterQuotasMap = new HashMap<>();
for (int i = 0; i < result.getReturnValues().size(); i++) {
List<Quota> quotas = result.getReturnValues().get(i).getReturnValue();
Guid clusterId = ((IdQueryParameters) result.getParameters().get(i)).getId();
clusterQuotasMap.put(clusterId, quotas);
}
getClusterQuotasMap().setEntity(clusterQuotasMap);
});
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class RegisterEntityModel method onVnicProfileMappingCommand.
private void onVnicProfileMappingCommand() {
Map<Cluster, Set<VnicProfileMappingEntity>> result = updateExternalVnicProfilesPerTargetCluster();
setExternalVnicProfilesPerTargetCluster(result);
// pass the updated profile mappings to the model so it can display updated values in the dialog
vnicProfileMappingModel = new VnicProfileMappingModel(this, externalVnicProfilesPerTargetCluster);
// while initializing the model the current vnic profiles are fetched from the backend and the target profiles
// are adjusted accordingly
vnicProfileMappingModel.initialize();
setWindow(vnicProfileMappingModel);
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateCustomCpu.
/*
* Updates the cpu model combobox after a cluster change occurs
*/
protected void updateCustomCpu() {
Cluster cluster = getModel().getSelectedCluster();
if (cluster == null || cluster.getCpuName() == null) {
return;
}
AsyncDataProvider.getInstance().getSupportedCpuList(new AsyncQuery<>(returnValue -> {
if (returnValue != null) {
List<String> cpuList = new ArrayList<>();
// $NON-NLS-1$
cpuList.add("");
for (ServerCpu cpu : returnValue) {
cpuList.add(cpu.getVdsVerbData());
}
String oldVal = getModel().getCustomCpu().getSelectedItem();
getModel().getCustomCpu().setItems(cpuList);
getModel().getCustomCpu().setSelectedItem(oldVal);
}
}), cluster.getCpuName());
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateQuotaByCluster.
protected void updateQuotaByCluster(final Guid defaultQuota, final String quotaName) {
if (getModel().getQuota().getIsAvailable()) {
Cluster cluster = getModel().getSelectedCluster();
if (cluster == null) {
return;
}
AsyncDataProvider.getInstance().getAllRelevantQuotasForClusterSorted(new AsyncQuery<>(quotaList -> {
UnitVmModel vmModel = getModel();
if (quotaList == null) {
return;
}
if (!quotaList.isEmpty()) {
vmModel.getQuota().setItems(quotaList);
}
if (defaultQuota != null && !Guid.Empty.equals(defaultQuota)) {
boolean hasQuotaInList = false;
if (!quotaList.isEmpty()) {
hasQuotaInList = defaultQuota.equals(quotaList.get(0).getId());
}
// Add the quota to the list only in edit mode
if (!hasQuotaInList && !getModel().getIsNew()) {
Quota quota = new Quota();
quota.setId(defaultQuota);
quota.setQuotaName(quotaName);
quotaList.add(0, quota);
vmModel.getQuota().setItems(quotaList);
vmModel.getQuota().setSelectedItem(quota);
}
}
}), cluster.getId(), defaultQuota);
}
}
Aggregations