use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class StorageListModel method addExistingFileStorageDomain.
public void addExistingFileStorageDomain() {
StorageDomain sdToAdd = Linq.firstOrNull(storageDomainsToAdd);
StorageDomainStatic sdsToAdd = sdToAdd.getStorageStaticData();
storageDomain = sdsToAdd;
saveBaseStorageProperties((StorageModel) getWindow());
StorageDomainManagementParameter params = new StorageDomainManagementParameter(sdsToAdd);
params.setVdsId(hostId);
Frontend.getInstance().runAction(ActionType.AddExistingFileStorageDomain, params, result -> {
Object[] array = (Object[]) result.getState();
StorageListModel storageListModel = (StorageListModel) array[0];
StorageDomain sdToAdd1 = (StorageDomain) array[1];
ActionReturnValue returnVal = result.getReturnValue();
boolean success = returnVal != null && returnVal.getSucceeded();
if (success) {
StorageModel model = (StorageModel) storageListModel.getWindow();
StoragePool dataCenter = model.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
storageListModel.attachStorageToDataCenter(sdToAdd1.getId(), dataCenter.getId(), model.getActivateDomain().getEntity());
onFinish(storageListModel.context, true, storageListModel.storageModel, null);
} else {
postImportFileStorage(storageListModel.context, true, storageListModel.storageModel, null);
}
} else {
// $NON-NLS-1$
postImportFileStorage(storageListModel.context, false, storageListModel.storageModel, "");
cleanConnection(fileConnection, hostId);
}
}, new Object[] { this, sdToAdd });
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class StorageListModel method saveLocalStorage.
private void saveLocalStorage(TaskContext context) {
this.context = context;
StorageDomain selectedItem = getSelectedItem();
StorageModel model = (StorageModel) getWindow();
VDS host = model.getHost().getSelectedItem();
boolean isNew = model.getStorage() == null;
storageModel = model.getCurrentStorageItem();
LocalStorageModel localModel = (LocalStorageModel) storageModel;
path = localModel.getPath().getEntity();
storageDomain = isNew ? new StorageDomainStatic() : (StorageDomainStatic) Cloner.clone(selectedItem.getStorageStaticData());
saveBaseStorageProperties(model);
if (isNew) {
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
handleDomainAlreadyExists(storages);
} else {
saveNewLocalStorage();
}
}), host.getStoragePoolId(), path);
} else {
StorageDomain storageDomain = getSelectedItem();
if (isPathEditable(storageDomain)) {
updatePath();
}
updateStorageDomain();
}
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class HSMGetStorageDomainInfoVDSCommand method buildStorageStaticFromStruct.
private static Pair<StorageDomainStatic, Guid> buildStorageStaticFromStruct(Map<String, Object> struct) {
Pair<StorageDomainStatic, Guid> returnValue = new Pair<>();
StorageDomainStatic sdStatic = new StorageDomainStatic();
if (struct.containsKey("name")) {
sdStatic.setStorageName(struct.get("name").toString());
}
if (struct.containsKey("type")) {
sdStatic.setStorageType(EnumUtils.valueOf(StorageType.class, struct.get("type").toString(), true));
}
if (struct.containsKey("class")) {
String domainType = struct.get("class").toString();
if ("backup".equalsIgnoreCase(domainType)) {
sdStatic.setStorageDomainType(StorageDomainType.ImportExport);
} else {
sdStatic.setStorageDomainType(EnumUtils.valueOf(StorageDomainType.class, domainType, true));
}
}
if (struct.containsKey("version")) {
sdStatic.setStorageFormat(StorageFormatType.forValue(struct.get("version").toString()));
}
if (sdStatic.getStorageType() != StorageType.UNKNOWN) {
if (sdStatic.getStorageType().isFileDomain() && struct.containsKey("remotePath")) {
String path = struct.get("remotePath").toString();
List<StorageServerConnections> connections = DbFacade.getInstance().getStorageServerConnectionDao().getAllForStorage(path);
if (connections.isEmpty()) {
sdStatic.setConnection(new StorageServerConnections());
sdStatic.getConnection().setConnection(path);
sdStatic.getConnection().setStorageType(sdStatic.getStorageType());
} else {
sdStatic.setStorage(connections.get(0).getId());
sdStatic.setConnection(connections.get(0));
}
} else if (sdStatic.getStorageType() != StorageType.NFS) {
if (struct.containsKey("vguuid")) {
sdStatic.setStorage(struct.get("vguuid").toString());
}
if (struct.containsKey("metadataDevice")) {
sdStatic.setFirstMetadataDevice(Objects.toString(struct.get("metadataDevice")));
}
if (struct.containsKey("vgMetadataDevice")) {
sdStatic.setVgMetadataDevice(Objects.toString(struct.get("vgMetadataDevice")));
}
}
}
if (struct.containsKey("state")) {
sdStatic.setSanState(EnumUtils.valueOf(SANState.class, struct.get("state").toString().toUpperCase(), false));
}
returnValue.setFirst(sdStatic);
Object[] poolUUIDs = (Object[]) struct.get("pool");
if (poolUUIDs.length != 0) {
returnValue.setSecond(Guid.createGuidFromString(poolUUIDs[0].toString()));
}
return returnValue;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class Cloner method cloneStorageDomainStatic.
private static StorageDomainStatic cloneStorageDomainStatic(StorageDomainStatic instance) {
StorageDomainStatic obj = new StorageDomainStatic();
obj.setConnection(instance.getConnection());
obj.setId(instance.getId());
obj.setStorage(instance.getStorage());
obj.setStorageDomainType(instance.getStorageDomainType());
obj.setStorageType(instance.getStorageType());
obj.setStorageName(instance.getStorageName());
obj.setFirstMetadataDevice(instance.getFirstMetadataDevice());
obj.setVgMetadataDevice(instance.getVgMetadataDevice());
obj.setDescription(instance.getDescription());
obj.setComment(instance.getComment());
obj.setStorageFormat(instance.getStorageFormat());
obj.setWipeAfterDelete(instance.getWipeAfterDelete());
obj.setDiscardAfterDelete(instance.getDiscardAfterDelete());
obj.setWarningLowSpaceIndicator(instance.getWarningLowSpaceIndicator());
obj.setCriticalSpaceActionBlocker(instance.getCriticalSpaceActionBlocker());
obj.setBackup(instance.isBackup());
return obj;
}
use of org.ovirt.engine.core.common.businessentities.StorageDomainStatic in project ovirt-engine by oVirt.
the class DataCenterGuideModel method saveSanStorage.
private void saveSanStorage(final TaskContext context) {
this.context = context;
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
storageDomain = new StorageDomainStatic();
storageDomain.setStorageType(sanModel.getType());
storageDomain.setStorageDomainType(sanModel.getRole());
storageDomain.setStorageFormat(sanModel.getContainer().getFormat().getSelectedItem());
storageDomain.setStorageName(model.getName().getEntity());
AsyncDataProvider.getInstance().getStorageDomainsByConnection(new AsyncQuery<>(storages -> {
if (storages != null && storages.size() > 0) {
String storageName = storages.get(0).getStorageName();
onFinish(context, false, storageModel, ConstantsManager.getInstance().getMessages().createOperationFailedDcGuideMsg(storageName));
} else {
saveNewSanStorage();
}
getWindow().stopProgress();
}), null, path);
}
Aggregations