use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onAddStorage.
public void onAddStorage() {
StorageModel model = (StorageModel) getWindow();
String storageName = model.getName().getEntity();
AsyncDataProvider.getInstance().isStorageDomainNameUnique(new AsyncQuery<>(isNameUnique -> {
StorageModel storageModel = (StorageModel) getWindow();
String name = storageModel.getName().getEntity();
String tempVar = storageModel.getOriginalName();
// $NON-NLS-1$
String originalName = (tempVar != null) ? tempVar : "";
if (!isNameUnique && name.compareToIgnoreCase(originalName) != 0) {
storageModel.getName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
storageModel.getName().setIsValid(false);
}
AsyncDataProvider.getInstance().getStorageDomainMaxNameLength(new AsyncQuery<>(nameMaxLength -> {
StorageModel storageModel1 = (StorageModel) getWindow();
RegexValidation tempVar2 = new RegexValidation();
// $NON-NLS-1$ //$NON-NLS-2$
tempVar2.setExpression("^[A-Za-z0-9_-]{1," + nameMaxLength + "}$");
tempVar2.setMessage(ConstantsManager.getInstance().getMessages().nameCanContainOnlyMsg(nameMaxLength));
storageModel1.getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar2 });
postOnAddStorage();
}));
}), storageName);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSaveSanStorage.
private void onSaveSanStorage() {
ConfirmationModel confirmationModel = (ConfirmationModel) getConfirmWindow();
if (confirmationModel != null && !confirmationModel.validate()) {
return;
}
cancelConfirm();
getWindow().startProgress();
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
boolean force = sanModel.isForce();
HashSet<String> lunIds = new HashSet<>();
for (LunModel lun : sanModel.getAddedLuns()) {
lunIds.add(lun.getLunId());
}
AddSANStorageDomainParameters params = new AddSANStorageDomainParameters(storageDomain);
params.setVdsId(host.getId());
params.setLunIds(new HashSet<>(lunIds));
params.setForce(force);
Frontend.getInstance().runAction(ActionType.AddSANStorageDomain, params, result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
ActionReturnValue returnValue = result.getReturnValue();
Guid storageId = returnValue.getActionReturnValue();
dataCenterGuideModel.attachStorageToDataCenter(storageId, dataCenter.getId());
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method forceCreationWarning.
private void forceCreationWarning(ArrayList<String> usedLunsMessages) {
StorageModel storageModel = (StorageModel) getWindow();
SanStorageModelBase sanStorageModelBase = (SanStorageModelBase) storageModel.getCurrentStorageItem();
sanStorageModelBase.setForce(true);
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().forceStorageDomainCreation());
model.setMessage(ConstantsManager.getInstance().getConstants().lunsAlreadyInUse());
model.setHelpTag(HelpTag.force_storage_domain_creation);
// $NON-NLS-1$
model.setHashName("force_storage_domain_creation");
model.setItems(usedLunsMessages);
// $NON-NLS-1$
UICommand onSaveSanStorageCommand = UICommand.createDefaultOkUiCommand("OnSaveSanStorage", this);
model.getCommands().add(onSaveSanStorageCommand);
// $NON-NLS-1$
UICommand cancelConfirmCommand = UICommand.createCancelUiCommand("CancelConfirm", this);
model.getCommands().add(cancelConfirmCommand);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method addLocalStorage.
private void addLocalStorage() {
final StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().newLocalDomainTitle());
model.setHelpTag(HelpTag.new_local_domain);
// $NON-NLS-1$
model.setHashName("new_local_domain");
LocalStorageModel localStorageModel = new LocalStorageModel();
localStorageModel.setRole(StorageDomainType.Data);
ArrayList<IStorageModel> list = new ArrayList<>();
list.add(localStorageModel);
model.setStorageModels(list);
model.setCurrentStorageItem(list.get(0));
AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(localHost -> {
model.getHost().setItems(new ArrayList<>(Arrays.asList(new VDS[] { localHost })));
model.getHost().setSelectedItem(localHost);
model.getDataCenter().setItems(Collections.singletonList(getEntity()), getEntity());
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAddStorage", DataCenterGuideModel.this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", DataCenterGuideModel.this);
model.getCommands().add(tempVar2);
}), getEntity().getName());
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.StorageModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method addStorageInternal.
private void addStorageInternal(String title, StorageDomainType type) {
StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
setWindow(model);
model.setTitle(title);
model.setHelpTag(HelpTag.new_domain);
// $NON-NLS-1$
model.setHashName("new_domain");
ArrayList<StoragePool> dataCenters = new ArrayList<>();
dataCenters.add(getEntity());
model.getDataCenter().setItems(dataCenters, getEntity());
model.getDataCenter().setIsChangeable(false);
List<IStorageModel> items = null;
if (type == StorageDomainType.Data) {
items = AsyncDataProvider.getInstance().getDataStorageModels();
} else if (type == StorageDomainType.ISO) {
items = AsyncDataProvider.getInstance().getIsoStorageModels();
}
model.setStorageModels(items);
model.initialize();
// $NON-NLS-1$
UICommand tempVar6 = UICommand.createDefaultOkUiCommand("OnAddStorage", this);
model.getCommands().add(tempVar6);
// $NON-NLS-1$
UICommand tempVar7 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar7);
}
Aggregations