Ramesh N has uploaded a new change for review. Change subject: gluster: Add support for gluster brick creation ......................................................................
gluster: Add support for gluster brick creation Add Create Brick action to 'Storage Devices' sub tab in Hosts main tab. It helps to create bricks from the usable storage devices and these bricks are mounted at the given mount point and it cab directly used by the gluster volumes Change-Id: If43b6503dd8362d2a0907ac9648335a750828427 Signed-off-by: Ramesh Nachimuthu <rnach...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/HostStorageDevicesListModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/HostModule.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateBrickPopupPresenterWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostStorageDevicesView.java 12 files changed, 464 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/36031/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java index 19ebeb2..e002114 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java @@ -450,6 +450,9 @@ storage_device_list("storage_device_list", HelpTagType.UNKNOWN), //$NON-NLS-1$ + create_brick( + "create_brick", HelpTagType.WEBADMIN, "[gluster] Hosts main tab -> Storage Devices sub tab -> 'Create Brick' dialog"), //$NON-NLS-1$ //$NON-NLS-2$ + virtual_machines("virtual_machines", HelpTagType.UNKNOWN), //$NON-NLS-1$ vm_import("vm_import", HelpTagType.UNKNOWN), //$NON-NLS-1$ @@ -528,6 +531,7 @@ numa_support("numa_support", HelpTagType.WEBADMIN, "Hosts maint tab -> NUMA Support"); //$NON-NLS-1$ //$NON-NLS-2$ + public final String name; HelpTag(String name, HelpTagType type) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/HostStorageDevicesListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/HostStorageDevicesListModel.java index 0e44946..642db8d 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/HostStorageDevicesListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/HostStorageDevicesListModel.java @@ -1,15 +1,21 @@ package org.ovirt.engine.ui.uicommonweb.models.gluster; +import java.util.ArrayList; import java.util.List; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.gluster.CreateBrickParameters; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.help.HelpTag; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; @@ -26,10 +32,32 @@ super.setEntity(value); } + private UICommand createBrickCommand; + + public UICommand getCreateBrickCommand() { + return createBrickCommand; + } + + public void setCreateBrickCommand(UICommand createBrickCommand) { + this.createBrickCommand = createBrickCommand; + } + + private UICommand extendBrickCommand; + + public UICommand getExtendBrickCommand() { + return extendBrickCommand; + } + + public void setExtendBrickCommand(UICommand extendBrickCommand) { + this.extendBrickCommand = extendBrickCommand; + } + public HostStorageDevicesListModel() { setTitle(ConstantsManager.getInstance().getConstants().storageDevices()); setHelpTag(HelpTag.storage_device_list); setHashName("storage_device_list"); //$NON-NLS-1$ + setCreateBrickCommand(new UICommand("Create Brick", this)); //$NON-NLS-1$ + setExtendBrickCommand(new UICommand("Extend Brick", this)); //$NON-NLS-1$ setAvailableInModes(ApplicationMode.GlusterOnly); } @@ -77,4 +105,110 @@ protected String getListName() { return "HostDeviceListListModel"; //$NON-NLS-1$ } + + private void extendBrick() { + + } + + private void showExtendBrickDialog() { + + } + + private void showCreateBrickDialog() { + if (getWindow() != null) { + return; + } + + VDS host = getEntity(); + if (host == null || host.getStatus() != VDSStatus.Up) { + return; + } + + final LogicalVolumeModel lvModel = new LogicalVolumeModel(); + lvModel.setTitle(ConstantsManager.getInstance().getConstants().createBrick()); + lvModel.setHelpTag(HelpTag.create_brick); + lvModel.setHashName("create_brick"); //$NON-NLS-1$ + setWindow(lvModel); + + AsyncQuery asyncQuery = new AsyncQuery(); + asyncQuery.setModel(lvModel); + asyncQuery.asyncCallback = new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + LogicalVolumeModel lvModel = (LogicalVolumeModel) model; + List<EntityModel<StorageDevice>> deviceList = new ArrayList<EntityModel<StorageDevice>>(); + List<StorageDevice> devices = (List<StorageDevice>) returnValue; + + for (StorageDevice device : devices) { + if (device.getCanCreateBrick()) { + EntityModel<StorageDevice> deviceModel = new EntityModel<StorageDevice>(device); + deviceList.add(deviceModel); + } + } + lvModel.getStorageDevices().setItems(deviceList); + + } + }; + AsyncDataProvider.getInstance().getStorageDevices(asyncQuery, host.getId()); + + UICommand okCommand = new UICommand("OnCreateBrick", this); //$NON-NLS-1$ + okCommand.setTitle(ConstantsManager.getInstance().getConstants().ok()); + okCommand.setIsDefault(true); + lvModel.getCommands().add(okCommand); + + UICommand cancelCommand = new UICommand("Cancel", this); //$NON-NLS-1$ + cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + cancelCommand.setIsCancel(true); + lvModel.getCommands().add(cancelCommand); + } + + private void createBrick() { + LogicalVolumeModel lvModel = (LogicalVolumeModel) getWindow(); + if (lvModel == null) { + return; + } + if (!lvModel.validate()) { + return; + } + + VDS host = getEntity(); + if (host == null) { + return; + } + + setConfirmWindow(null); + lvModel.startProgress(null); + + List<StorageDevice> selectedDevices = new ArrayList<StorageDevice>(); + for (EntityModel<StorageDevice> device : lvModel.getStorageDevices().getSelectedItems()) { + selectedDevices.add(device.getEntity()); + } + + CreateBrickParameters parameters = + new CreateBrickParameters(host.getId(), + lvModel.getLvName().getEntity(), + lvModel.getFsTypes().getSelectedItem(), + lvModel.getSize().getEntity(), + selectedDevices); + Frontend.getInstance().runAction(VdcActionType.CreateBrick, parameters); + lvModel.stopProgress(); + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + if (command.equals(getCreateBrickCommand())) { + showCreateBrickDialog(); + } else if (command.getName().equals("OnCreateBrick")) { //$NON-NLS-1$ + createBrick(); + } else if (command.equals(getExtendBrickCommand())) { + showExtendBrickDialog(); + } else if (command.getName().equals("OnExtendBrick")) { //$NON-NLS-1$ + extendBrick(); + } else if (command.getName().equals("Cancel")) { //$NON-NLS-1$ + setWindow(null); + } + } + } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java new file mode 100644 index 0000000..2041744 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java @@ -0,0 +1,59 @@ +package org.ovirt.engine.ui.uicommonweb.models.gluster; + +import java.util.Arrays; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.Model; + +public class LogicalVolumeModel extends Model { + EntityModel<String> lvName; + EntityModel<String> size; + ListModel<String> fsTypes; + ListModel<EntityModel<StorageDevice>> storageDevices; + + public LogicalVolumeModel() { + setLvName(new EntityModel<String>()); + setStorageDevices(new ListModel<EntityModel<StorageDevice>>()); + setSize(new EntityModel<String>()); + setFsTypes(new ListModel<String>()); + getFsTypes().setItems(Arrays.asList("XFS", "ext4", "ext3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + public EntityModel<String> getLvName() { + return lvName; + } + + public EntityModel<String> getSize() { + return size; + } + + public ListModel<String> getFsTypes() { + return fsTypes; + } + + public ListModel<EntityModel<StorageDevice>> getStorageDevices() { + return storageDevices; + } + + public void setLvName(EntityModel<String> lvName) { + this.lvName = lvName; + } + + public void setSize(EntityModel<String> size) { + this.size = size; + } + + public void setFsTypes(ListModel<String> fsTypes) { + this.fsTypes = fsTypes; + } + + public void setStorageDevices(ListModel<EntityModel<StorageDevice>> storageDevices) { + this.storageDevices = storageDevices; + } + + public boolean validate() { + return true; + } +} diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index eb37239..bef9171 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -2464,4 +2464,7 @@ @DefaultStringValue("Storage Devices") String storageDevices(); + + @DefaultStringValue("Create Brick") + String createBrick(); } diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties index 4289f4b..dca507e 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties @@ -341,6 +341,7 @@ VdcActionType___AddGlusterHook=Add Gluster Hook VdcActionType___RemoveGlusterHook=Remove Gluster Hook VdcActionType___RefreshGlusterHook=Refresh Gluster Hook +VdcActionType___CreateBrick=Create Brick VdcActionType___ManageGlusterService=Manage Service VdcActionType___ActivateStorageDomain=Activate Storage Domain VdcActionType___FenceVdsManualy=Fence Host Manually diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 24ea897..43a1f62 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -3965,4 +3965,16 @@ @DefaultStringValue("Device is already in use") String deviceIsAlreadyUsed(); + + @DefaultStringValue("Logical Volume") + String logicalVolume(); + + @DefaultStringValue("LV Size") + String lvSize(); + + @DefaultStringValue("Create Brick") + String createBrick(); + + @DefaultStringValue("Extend Brick") + String extendBrick(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java index 5c46656..6cea2df 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java @@ -41,6 +41,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.AddBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.BrickAdvancedDetailsPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.CreateBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.DetachGlusterHostsPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickStatusPopupPresenterWidget; @@ -176,8 +177,8 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostHookPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostInterfacePresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostPermissionPresenter; -import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostVmPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostStorageDevicesPresenter; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostVmPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.network.NetworkSubTabPanelPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.network.SubTabNetworkClusterPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.network.SubTabNetworkExternalSubnetPresenter; @@ -279,6 +280,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.popup.event.EventPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.AddBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.BrickAdvancedDetailsPopupView; +import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.CreateBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.DetachGlusterHostsPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.RemoveBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.RemoveBrickStatusPopupView; @@ -419,8 +421,8 @@ import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostHookView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostInterfaceView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostPermissionView; -import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostVmView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostStorageDevicesView; +import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostVmView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.network.NetworkSubTabPanelView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.network.SubTabNetworkClusterView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.network.SubTabNetworkExternalSubnetView; @@ -1453,6 +1455,10 @@ AddBrickPopupPresenterWidget.ViewDef.class, AddBrickPopupView.class); + bindPresenterWidget(CreateBrickPopupPresenterWidget.class, + CreateBrickPopupPresenterWidget.ViewDef.class, + CreateBrickPopupView.class); + bindPresenterWidget(RemoveBrickPopupPresenterWidget.class, RemoveBrickPopupPresenterWidget.ViewDef.class, RemoveBrickPopupView.class); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/HostModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/HostModule.java index 8f415ed..52dbdbb 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/HostModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/HostModule.java @@ -47,6 +47,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.AssignTagsPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.DetachConfirmationPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.CreateBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.ConfigureLocalStoragePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.HostBondPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.HostInstallPopupPresenterWidget; @@ -271,6 +272,32 @@ @Provides @Singleton + public SearchableDetailModelProvider<StorageDevice, HostListModel, HostStorageDevicesListModel> getDisksListProvider(EventBus eventBus, + Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, + final Provider<CreateBrickPopupPresenterWidget> createBrickPopupProvider, + final Provider<HostListModel> mainModelProvider, + final Provider<HostStorageDevicesListModel> modelProvider) { + SearchableDetailTabModelProvider<StorageDevice, HostListModel, HostStorageDevicesListModel> result = + new SearchableDetailTabModelProvider<StorageDevice, HostListModel, HostStorageDevicesListModel>( + eventBus, defaultConfirmPopupProvider) { + @Override + public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(HostStorageDevicesListModel source, + UICommand lastExecutedCommand, + Model windowModel) { + if (lastExecutedCommand == getModel().getCreateBrickCommand()) { + return createBrickPopupProvider.get(); + } else { + return super.getModelPopup(source, lastExecutedCommand, windowModel); + } + } + }; + result.setMainModelProvider(mainModelProvider); + result.setModelProvider(modelProvider); + return result; + } + + @Provides + @Singleton public SearchableDetailModelProvider<AuditLog, HostListModel, HostEventListModel> getHostEventListProvider(EventBus eventBus, Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<EventPopupPresenterWidget> eventPopupProvider, @@ -319,9 +346,6 @@ .in(Singleton.class); bind(new TypeLiteral<SearchableDetailModelProvider<GlusterBrickEntity, HostListModel, HostBricksListModel>>(){}) .to(new TypeLiteral<SearchableDetailTabModelProvider<GlusterBrickEntity, HostListModel, HostBricksListModel>>(){}) - .in(Singleton.class); - bind(new TypeLiteral<SearchableDetailModelProvider<StorageDevice, HostListModel, HostStorageDevicesListModel>>(){}) - .to(new TypeLiteral<SearchableDetailTabModelProvider<StorageDevice, HostListModel, HostStorageDevicesListModel>>(){}) .in(Singleton.class); bind(new TypeLiteral<SearchableDetailModelProvider<GlusterServerService, HostListModel, HostGlusterSwiftListModel>>(){}) .to(new TypeLiteral<SearchableDetailTabModelProvider<GlusterServerService, HostListModel, HostGlusterSwiftListModel>>(){}) diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateBrickPopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateBrickPopupPresenterWidget.java new file mode 100644 index 0000000..d1941b7 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateBrickPopupPresenterWidget.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster; + +import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.uicommonweb.models.gluster.LogicalVolumeModel; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; + +public class CreateBrickPopupPresenterWidget extends AbstractModelBoundPopupPresenterWidget<LogicalVolumeModel, CreateBrickPopupPresenterWidget.ViewDef> { + + public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<LogicalVolumeModel> { + } + + @Inject + public CreateBrickPopupPresenterWidget(EventBus eventBus, ViewDef view) { + super(eventBus, view); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.java new file mode 100644 index 0000000..0e96367 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.java @@ -0,0 +1,143 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.utils.SizeConverter; +import org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit; +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; +import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; +import org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable; +import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor; +import org.ovirt.engine.ui.common.widget.table.column.EntityModelTextColumn; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.LogicalVolumeModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationResources; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.CreateBrickPopupPresenterWidget; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.view.client.MultiSelectionModel; +import com.google.inject.Inject; + +public class CreateBrickPopupView extends AbstractModelBoundPopupView<LogicalVolumeModel> implements CreateBrickPopupPresenterWidget.ViewDef { + + interface Driver extends SimpleBeanEditorDriver<LogicalVolumeModel, CreateBrickPopupView> { + } + + interface ViewUiBinder extends UiBinder<SimpleDialogPanel, CreateBrickPopupView> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<CreateBrickPopupView> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + + @UiField + @Path(value = "lvName.entity") + @WithElementId + StringEntityModelTextBoxEditor lvNameEditor; + + @UiField + @Ignore + @WithElementId + Label deviceHeader; + + @UiField(provided = true) + @Ignore + @WithElementId + EntityModelCellTable<ListModel> deviceTable; + + @UiField + @Path(value = "fsTypes.selectedItem") + @WithElementId + ListModelListBoxEditor<String> fileSystemTypeEditor; + + @UiField + @Path(value = "size.entity") + @WithElementId + StringEntityModelTextBoxEditor sizeEditor; + + private final Driver driver = GWT.create(Driver.class); + + private final ApplicationConstants constants; + + @Inject + public CreateBrickPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) { + super(eventBus, resources); + deviceTable = new EntityModelCellTable<ListModel>(true); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + ViewIdHandler.idHandler.generateAndSetIds(this); + localize(constants); + initTableColumns(constants); + this.constants = constants; + driver.initialize(this); + + } + + protected void initTableColumns(ApplicationConstants constants){ + // Table Entity Columns + deviceTable.addEntityModelColumn(new EntityModelTextColumn<StorageDevice>() { + @Override + public String getText(StorageDevice entity) { + return entity.getName(); + } + }, constants.deviceName()); + + deviceTable.addEntityModelColumn(new EntityModelTextColumn<StorageDevice>() { + @Override + public String getText(StorageDevice entity) { + if (entity.getSize() != null) { + Pair<SizeUnit, Double> convertedSize = SizeConverter.autoConvert(entity.getSize(), SizeUnit.MB); + return formatSize(convertedSize.getSecond()) + " " + convertedSize.getFirst().toString(); //$NON-NLS-1$ + } else { + return ""; //$NON-NLS-1$ + } + } + }, constants.size()); + } + + private void clearSelections() { + if (deviceTable.getSelectionModel() instanceof MultiSelectionModel) { + ((MultiSelectionModel) deviceTable.getSelectionModel()).clear(); + } + } + + private void localize(ApplicationConstants constants) { + lvNameEditor.setLabel(constants.logicalVolume()); + fileSystemTypeEditor.setLabel(constants.fileSystemType()); + sizeEditor.setLabel(constants.lvSize()); + deviceHeader.setText(constants.disksLabel()); + } + + @Override + public void edit(final LogicalVolumeModel object) { + driver.edit(object); + deviceTable.asEditor().edit(object.getStorageDevices()); + } + + @Override + public LogicalVolumeModel flush() { + deviceTable.flush(); + return driver.flush(); + } + + interface WidgetStyle extends CssResource { + String editorContentWidget(); + String forceEditorWidget(); + } + + public String formatSize(double size) { + return NumberFormat.getFormat("#.##").format(size);//$NON-NLS-1$ + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.ui.xml new file mode 100644 index 0000000..9a3dab1 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateBrickPopupView.ui.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> +<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" + xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" + xmlns:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic" + xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab" + xmlns:w="urn:import:org.ovirt.engine.ui.common.widget"> + + <ui:style> + .headerLabel { + font-weight: bold; + padding: 5px; + } + + .tablePanel { + height: 270px; + width: 530px; + padding-left: 15px; + border: 1px solid #CED8DF; + } + </ui:style> + + <d:SimpleDialogPanel width="550px" height="575px"> + <d:content> + <g:FlowPanel> + <ge:StringEntityModelTextBoxEditor ui:field="lvNameEditor" /> + <e:ListModelListBoxEditor ui:field="fileSystemTypeEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="sizeEditor" /> + <g:Label ui:field="deviceHeader" addStyleNames="{style.headerLabel}"/> + <g:VerticalPanel addStyleNames="{style.tablePanel}" horizontalAlignment="ALIGN_CENTER"> + <g:ScrollPanel> + <e:EntityModelCellTable ui:field="deviceTable"/> + </g:ScrollPanel> + </g:VerticalPanel> + </g:FlowPanel> + </d:content> + </d:SimpleDialogPanel> +</ui:UiBinder> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostStorageDevicesView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostStorageDevicesView.java index a4e78fa..e20d9cf 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostStorageDevicesView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabHostStorageDevicesView.java @@ -10,11 +10,13 @@ import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider; import org.ovirt.engine.ui.common.widget.table.column.TextColumnWithTooltip; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.gluster.HostStorageDevicesListModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostListModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostStorageDevicesPresenter; import org.ovirt.engine.ui.webadmin.section.main.view.AbstractSubTabTableView; +import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; import org.ovirt.engine.ui.webadmin.widget.table.column.StorageDeviceStatusColumn; import com.google.gwt.core.client.GWT; @@ -94,6 +96,19 @@ mountPointColumn.makeSortable(); getTable().addColumn(mountPointColumn, constants.mountPoint(), "170px"); //$NON-NLS-1$ + getTable().addActionButton(new WebAdminButtonDefinition<StorageDevice>(constants.createBrick()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getCreateBrickCommand(); + } + }); + + getTable().addActionButton(new WebAdminButtonDefinition<StorageDevice>(constants.extendBrick()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getExtendBrickCommand(); + } + }); } public String formatSize(double size) { -- To view, visit http://gerrit.ovirt.org/36031 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If43b6503dd8362d2a0907ac9648335a750828427 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ramesh N <rnach...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches