use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class ClusterGuideModel method onAddDataCenter.
public void onAddDataCenter() {
@SuppressWarnings("unchecked") ListModel<EntityModel<StoragePool>> dataCentersModel = (ListModel<EntityModel<StoragePool>>) getWindow();
EntityModel<StoragePool> dataCenter = dataCentersModel.getSelectedItem();
if (dataCenter != null) {
Cluster cluster = getEntity();
cluster.setStoragePoolId(dataCenter.getEntity().getId());
dataCentersModel.startProgress();
Frontend.getInstance().runAction(ActionType.UpdateCluster, new ManagementNetworkOnClusterOperationParameters(cluster), result -> {
if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
// Succeeded, close this window.
ClusterGuideModel guideModel = (ClusterGuideModel) result.getState();
guideModel.postAction();
}
// Close popup window.
setWindow(null);
}, this);
} else {
setWindow(null);
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class ClusterModel method storagePool_SelectedItemChanged.
private void storagePool_SelectedItemChanged() {
// possible versions for new cluster (when editing cluster, this event won't occur)
// are actually the possible versions for the data-center that the cluster is going
// to be attached to.
final StoragePool selectedDataCenter = getDataCenter().getSelectedItem();
if (selectedDataCenter == null) {
getManagementNetwork().setItems(Collections.emptyList());
return;
}
if (selectedDataCenter.isLocal()) {
setMigrationTabAvailable(false);
} else {
setMigrationTabAvailable(true);
}
AsyncDataProvider.getInstance().getDataCenterVersions(new AsyncQuery<>(new AsyncCallback<List<Version>>() {
@Override
public void onSuccess(List<Version> versions) {
Version versionToSelect = calculateNewVersionWhichShouldBeSelected(versions);
getVersion().setItems(versions, versionToSelect);
}
private Version calculateNewVersionWhichShouldBeSelected(List<Version> versions) {
ListModel<Version> version = getVersion();
Version selectedVersion = version.getSelectedItem();
if (!getIsEdit() && (selectedVersion == null || !versions.contains(selectedVersion) || selectedVersion.compareTo(selectedDataCenter.getCompatibilityVersion()) > 0)) {
if (ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly)) {
return versions.stream().max(Comparator.naturalOrder()).orElse(null);
} else {
return selectedDataCenter.getCompatibilityVersion();
}
} else if (getIsEdit()) {
return Linq.firstOrNull(versions, x -> x.equals(getEntity().getCompatibilityVersion()));
} else {
return selectedVersion;
}
}
}), ApplicationModeHelper.getUiMode().equals(ApplicationMode.GlusterOnly) ? null : selectedDataCenter.getId());
if (getManagementNetwork().getIsChangable()) {
loadDcNetworks(selectedDataCenter.getId());
}
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class ProviderModel method updateDatacentersForExternalProvider.
protected void updateDatacentersForExternalProvider() {
AsyncDataProvider.getInstance().getDataCenterList(new AsyncQuery<>(new AsyncCallback<List<StoragePool>>() {
@Override
public void onSuccess(List<StoragePool> dataCenters) {
StoragePool prevDataCenter = getPreviousDataCenter(dataCenters);
Collections.sort(dataCenters, new NameableComparator());
// any data center
dataCenters.add(0, null);
getDataCenter().setItems(dataCenters);
getDataCenter().setSelectedItem(prevDataCenter);
if (getDataCenter().getSelectedItem() == null) {
getProxyHostPropertiesModel().disableProxyHost();
}
}
private StoragePool getPreviousDataCenter(List<StoragePool> dataCenters) {
Guid previousDataCenterId = getProxyHostPropertiesModel().getLastStoragePoolId();
for (StoragePool dataCenter : dataCenters) {
if (dataCenter.getId().equals(previousDataCenterId)) {
return dataCenter;
}
}
return null;
}
}));
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method postInitStorageDomains.
protected void postInitStorageDomains() {
if (getModel().getDisks() == null) {
return;
}
ActionGroup actionGroup = getModel().isCreateInstanceOnly() ? ActionGroup.CREATE_INSTANCE : ActionGroup.CREATE_VM;
StoragePool dataCenter = getModel().getSelectedDataCenter();
AsyncDataProvider.getInstance().getPermittedStorageDomainsByStoragePoolId(new AsyncQuery<>(storageDomains -> {
ArrayList<StorageDomain> activeStorageDomains = filterStorageDomains(storageDomains);
boolean provisioning = getModel().getProvisioning().getEntity();
ArrayList<DiskModel> disks = (ArrayList<DiskModel>) getModel().getDisks();
activeStorageDomains.sort(new NameableComparator());
List<DiskModel> diskImages = Linq.filterDisksByType(disks, DiskStorageType.IMAGE);
for (DiskModel diskModel : diskImages) {
List<StorageDomain> availableDiskStorageDomains;
diskModel.getQuota().setItems(getModel().getQuota().getItems());
List<Guid> storageIds = ((DiskImage) diskModel.getDisk()).getStorageIds();
// Active storage domains that the disk resides on
List<StorageDomain> activeDiskStorageDomains = Linq.getStorageDomainsByIds(storageIds, activeStorageDomains);
// Set target storage domains
availableDiskStorageDomains = provisioning ? activeStorageDomains : activeDiskStorageDomains;
availableDiskStorageDomains.sort(new NameableComparator());
diskModel.getStorageDomain().setItems(availableDiskStorageDomains);
diskModel.getStorageDomain().setChangeProhibitionReason(constants.noActiveTargetStorageDomainAvailableMsg());
diskModel.getStorageDomain().setIsChangeable(!availableDiskStorageDomains.isEmpty());
}
List<DiskModel> cinderDisks = Linq.filterDisksByType(disks, DiskStorageType.CINDER);
Collection<StorageDomain> cinderStorageDomains = Linq.filterStorageDomainsByStorageType(storageDomains, StorageType.CINDER);
initStorageDomainsForCinderDisks(cinderDisks, cinderStorageDomains);
}), dataCenter.getId(), actionGroup);
}
use of org.ovirt.engine.core.common.businessentities.StoragePool in project ovirt-engine by oVirt.
the class VmModelBehaviorBase method updateCdImage.
protected void updateCdImage(boolean forceRefresh) {
StoragePool dataCenter = getModel().getSelectedDataCenter();
if (dataCenter == null) {
return;
}
ImagesDataProvider.getISOImagesList(asyncQuery(images -> setImagesToModel(getModel(), images)), dataCenter.getId(), forceRefresh);
}
Aggregations