use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class InstanceImageLineModel method attachDisk.
public void attachDisk() {
if (parentModel.getUnitVmModel().getSelectedCluster() == null || parentModel.getUnitVmModel().getSelectedDataCenter() == null) {
return;
}
InstanceImagesAttachDiskModel model = new InstanceImagesAttachDiskModel() {
@Override
public void onSave() {
if (validate()) {
flush();
List<EntityModel<DiskModel>> selectedDisks = getSelectedDisks();
if (selectedDisks.size() == 1) {
// only 0 or 1 is allowed
setDisk(selectedDisks.iterator().next().getEntity().getDisk());
}
getDiskModel().setEntity(this);
InstanceImageLineModel.this.setChanged(true);
setDiskModel(null);
// from now on only editing is possible
attachCommand.setIsAvailable(false);
fillData();
}
}
@Override
public void updateInterface(Version clusterVersion) {
InstanceImageLineModel.this.updateInterface(clusterVersion, this);
}
@Override
protected void updateBootableDiskAvailable() {
updateBootableFrom(parentModel.getAllCurrentDisksModels());
}
@Override
protected List<Disk> getAttachedNotSubmittedDisks() {
return parentModel.getNotYetAttachedNotAttachableDisks();
}
};
VM realOrFakeVm = vm;
Version compatibilityVersion = parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion();
if (realOrFakeVm == null) {
realOrFakeVm = new VM();
realOrFakeVm.setId(null);
realOrFakeVm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
realOrFakeVm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
realOrFakeVm.setClusterCompatibilityVersion(compatibilityVersion);
}
model.setVm(realOrFakeVm);
setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().attachVirtualDiskTitle(), HelpTag.attach_virtual_disk, // $NON-NLS-1$
"attach_virtual_disk");
setDiskModel(model);
model.initialize(parentModel.getAllCurrentDisksModels());
maybeLoadAttachableDisks(model);
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class InstanceImageLineModel method showNewDialog.
private void showNewDialog() {
final AbstractDiskModel model = new NewDiskModel() {
@Override
public void onSave() {
if (validate()) {
flush();
getDiskModel().setEntity(this);
InstanceImageLineModel.this.setChanged(true);
setDiskModel(null);
// the "new" turns into "edit" - no need for attach anymore
attachCommand.setIsAvailable(false);
fillData();
Disk disk = super.getDisk();
if (disk.getDiskStorageType() == DiskStorageType.IMAGE || disk.getDiskStorageType() == DiskStorageType.CINDER) {
((DiskImage) disk).setActive(true);
}
}
}
@Override
public void updateInterface(Version clusterVersion) {
InstanceImageLineModel.this.updateInterface(clusterVersion, this);
}
@Override
protected void updateBootableDiskAvailable() {
updateBootableFrom(parentModel.getAllCurrentDisksModels());
}
};
VM vm = new VM();
vm.setClusterId(parentModel.getUnitVmModel().getSelectedCluster().getId());
vm.setStoragePoolId(parentModel.getUnitVmModel().getSelectedDataCenter().getId());
vm.setClusterCompatibilityVersion(parentModel.getUnitVmModel().getSelectedCluster().getCompatibilityVersion());
Quota selectedQuota = parentModel.getUnitVmModel().getQuota().getSelectedItem();
vm.setQuotaId(selectedQuota == null ? null : selectedQuota.getId());
model.setVm(vm);
model.getSizeExtend().setIsAvailable(false);
setupModelAsDialog(model, ConstantsManager.getInstance().getConstants().newVirtualDiskTitle(), HelpTag.new_virtual_disk, // $NON-NLS-1$
"new_virtual_disk");
setDiskModel(model);
model.initialize(parentModel.getAllCurrentDisksModels());
if (model.getIsBootable().getIsChangable()) {
model.getIsBootable().setEntity(true);
}
if (getVm() != null) {
model.setVm(getVm());
((NewDiskModel) model).updateSuggestedDiskAliasFromServer();
} else {
String currentVmName = parentModel.getUnitVmModel().getName().getEntity();
if (StringHelper.isNotNullOrEmpty(currentVmName)) {
// if already set the VM name on the new VM dialog, suggest the name according to the name
model.getAlias().setEntity(suggestAliasForNewVm(currentVmName));
}
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class UnitVmModel method updateMigrationOptions.
private void updateMigrationOptions() {
DataCenterWithCluster dataCenterWithCluster = getDataCenterWithClustersList().getSelectedItem();
if (dataCenterWithCluster == null) {
return;
}
Cluster cluster = dataCenterWithCluster.getCluster();
Version version = getCompatibilityVersion();
// test migration support for VM/cluster level along with the cluster architecture
Boolean isMigrationSupported = AsyncDataProvider.getInstance().isMigrationSupported(cluster.getArchitecture(), version);
if (isMigrationSupported && getVmType().getSelectedItem() != VmType.HighPerformance) {
getMigrationMode().setItems(Arrays.asList(MigrationSupport.values()));
} else {
getMigrationMode().setItems(Arrays.asList(MigrationSupport.PINNED_TO_HOST));
}
autoConverge.setIsChangeable(true);
migrateCompressed.setIsChangeable(true);
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class UnitVmModel method refreshMigrationPolicies.
private void refreshMigrationPolicies() {
Version version = getCompatibilityVersion();
Guid selectedPolicyId = null;
if (getMigrationPolicies() != null && getMigrationPolicies().getSelectedItem() != null) {
selectedPolicyId = getMigrationPolicies().getSelectedItem().getId();
}
List<MigrationPolicy> policies = AsyncDataProvider.getInstance().getMigrationPolicies(version);
getMigrationPolicies().setItems(policies);
if (selectedPolicyId != null) {
for (MigrationPolicy policy : policies) {
if (Objects.equals(policy.getId(), selectedPolicyId)) {
getMigrationPolicies().setSelectedItem(policy);
break;
}
}
}
}
use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.
the class UnitVmModel method getCompatibilityVersion.
public Version getCompatibilityVersion() {
ListModel<Version> customCompatibilityVersion = getCustomCompatibilityVersion();
if (customCompatibilityVersion != null && customCompatibilityVersion.getSelectedItem() != null) {
return customCompatibilityVersion.getSelectedItem();
}
Cluster cluster = getSelectedCluster();
if (cluster != null) {
return cluster.getCompatibilityVersion();
}
return null;
}
Aggregations