Ramesh N has uploaded a new change for review. Change subject: <WIP>gluster: Open LMI integration for disk provisioning ......................................................................
<WIP>gluster: Open LMI integration for disk provisioning Prototype for provisioning disks using open-lmi. Change-Id: I6452b2fbffca9f372f861eb6bcb81de10c4ef6ff Signed-off-by: Ramesh Nachimuthu <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetLogicalVolumesQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetUnUsedDisksQuery.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/CreateLogicalVolumeCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateLogicalVolumeParameters.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StorageDeviceInfo.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/CreateLogicalVolumeVDSParameters.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CreateLogicalVolumeVDSCommand.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetDeviceInfoVDSCommand.java A backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/StorageDeviceInfoListReturnForXmlRpc.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/StorageDeviceListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java 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/ClientGinjectorExtension.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 M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateLogicalVolumePopupPresenterWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/host/SubTabDisksPresenter.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.ui.xml A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabDisksView.java 34 files changed, 1,401 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/32485/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetLogicalVolumesQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetLogicalVolumesQuery.java new file mode 100644 index 0000000..813cbb0e --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetLogicalVolumesQuery.java @@ -0,0 +1,48 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.bll.Backend; +import org.ovirt.engine.core.bll.QueriesCommandBase; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend; +import org.ovirt.engine.core.common.queries.VdsIdParametersBase; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; + +public class GetLogicalVolumesQuery<P extends VdsIdParametersBase> extends QueriesCommandBase<P> { + + private static final String DEVICE_TYPE_LVM_LV = "LVM_LV"; + + public GetLogicalVolumesQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + VDS vds = getDbFacade().getVdsDao().get(getParameters().getVdsId()); + // Get Device List + VDSBrokerFrontend vdsBrokerFrontend = getVdsBroker(); + VdsIdVDSCommandParametersBase parameters = new VdsIdVDSCommandParametersBase( + getParameters().getVdsId()); + List<StorageDeviceInfo> storageDevices = (List<StorageDeviceInfo>) vdsBrokerFrontend.RunVdsCommand( + VDSCommandType.GetDeviceInfo, parameters).getReturnValue(); + getQueryReturnValue().setReturnValue(filterLogicalVolumes(storageDevices)); + + } + + private List<StorageDeviceInfo> filterLogicalVolumes(List<StorageDeviceInfo> allDisks) { + List<StorageDeviceInfo> lvs = new ArrayList<StorageDeviceInfo>(); + for (StorageDeviceInfo disk : allDisks) { + if (disk.getType().equals(DEVICE_TYPE_LVM_LV)) { + lvs.add(disk); + } + } + return lvs; + } + protected VDSBrokerFrontend getVdsBroker() { + return Backend.getInstance().getResourceManager(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetUnUsedDisksQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetUnUsedDisksQuery.java new file mode 100644 index 0000000..887e52a --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetUnUsedDisksQuery.java @@ -0,0 +1,52 @@ +package org.ovirt.engine.core.bll.gluster; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.ovirt.engine.core.bll.Backend; +import org.ovirt.engine.core.bll.QueriesCommandBase; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.common.interfaces.VDSBrokerFrontend; +import org.ovirt.engine.core.common.queries.VdsIdParametersBase; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; + +public class GetUnUsedDisksQuery<P extends VdsIdParametersBase> extends QueriesCommandBase<P> { + + Set<String> excludedTypes = new HashSet<String>(Arrays.asList("LVM_PV", "LVM_PV")); + public GetUnUsedDisksQuery(P parameters) { + super(parameters); + } + + @Override + protected void executeQueryCommand() { + VDS vds = getDbFacade().getVdsDao().get(getParameters().getVdsId()); + // Get Device List + VDSBrokerFrontend vdsBrokerFrontend = getVdsBroker(); + VdsIdVDSCommandParametersBase parameters = new VdsIdVDSCommandParametersBase( + getParameters().getVdsId()); + List<StorageDeviceInfo> storageDevices = (List<StorageDeviceInfo>) vdsBrokerFrontend.RunVdsCommand( + VDSCommandType.GetDeviceInfo, parameters).getReturnValue(); + getQueryReturnValue().setReturnValue(filterUnUsedDisks(storageDevices)); + + } + + private List<StorageDeviceInfo> filterUnUsedDisks(List<StorageDeviceInfo> allDisks) { + List<StorageDeviceInfo> unUsedDisks = new ArrayList<StorageDeviceInfo>(); + for (StorageDeviceInfo disk : allDisks) { + if (disk.getFileSystem().isEmpty() && disk.getPartitions().isEmpty() + && !excludedTypes.contains(disk.getType())) { + unUsedDisks.add(disk); + } + + } + return unUsedDisks; + } + protected VDSBrokerFrontend getVdsBroker() { + return Backend.getInstance().getResourceManager(); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/CreateLogicalVolumeCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/CreateLogicalVolumeCommand.java new file mode 100644 index 0000000..186da82 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/CreateLogicalVolumeCommand.java @@ -0,0 +1,34 @@ +package org.ovirt.engine.core.bll.network.host; + +import org.ovirt.engine.core.bll.VdsCommand; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.gluster.CreateLogicalVolumeParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.gluster.CreateLogicalVolumeVDSParameters; + +public class CreateLogicalVolumeCommand<T extends CreateLogicalVolumeParameters> extends VdsCommand<T> { + + public CreateLogicalVolumeCommand(T parameters) { + super(parameters); + } + + @Override + protected void executeCommand() { + + VDSReturnValue returnValue = runVdsCommand( + VDSCommandType.CreateLogicalVolume, + new CreateLogicalVolumeVDSParameters(getVdsId(), + getParameters().getLvName(), + getParameters().getFileSystem(), + getParameters().getFileSystemType(), + getParameters().getSize(), + getParameters().getDisks())); + setSucceeded(returnValue.getSucceeded()); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.CREATE_LOGICAL_VOLUME : AuditLogType.CREATE_LOGICAL_VOLUME_FAILED; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 38c7dae..185cfe5 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -279,6 +279,8 @@ USER_EXCEEDED_QUOTA_STORAGE_GRACE_LIMIT_PERMISSIVE_MODE(3016, AuditLogSeverity.WARNING), // Gluster Audit Logs + CREATE_LOGICAL_VOLUME(3990), + CREATE_LOGICAL_VOLUME_FAILED(3991), GLUSTER_VOLUME_CREATE(4000), GLUSTER_VOLUME_CREATE_FAILED(4001, AuditLogSeverity.ERROR), GLUSTER_VOLUME_OPTION_ADDED(4002), @@ -375,7 +377,9 @@ REMOVE_GLUSTER_VOLUME_BRICKS_NOT_FOUND_FROM_CLI(4092, AuditLogSeverity.WARNING), GLUSTER_VOLUME_DETAILS_REFRESH(4093), GLUSTER_VOLUME_DETAILS_REFRESH_FAILED(4094, AuditLogSeverity.ERROR), - + USER_FORCE_SELECTED_SPM_STOP_FAILED(4096, AuditLogSeverity.ERROR), + GET_STORAGE_DEVICES(4097), + GET_STORAGE_DEVICES_FAILED(4098, AuditLogSeverity.ERROR), USER_FORCE_SELECTED_SPM(159), USER_VDS_RESTART(41), USER_FAILED_VDS_RESTART(107, AuditLogSeverity.ERROR), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index a121dc8..28ad5b7 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -300,6 +300,7 @@ StopRemoveGlusterVolumeBricks(1423, ActionGroup.MANIPULATE_GLUSTER_VOLUME, false, QuotaDependency.NONE), CommitRemoveGlusterVolumeBricks(1424, ActionGroup.MANIPULATE_GLUSTER_VOLUME, false, QuotaDependency.NONE), RefreshGlusterVolumeDetails(1425, ActionGroup.MANIPULATE_GLUSTER_VOLUME, QuotaDependency.NONE), + CreateLogicalVolume(1426, ActionGroup.MANIPULATE_HOST, QuotaDependency.NONE), // Cluster Policy AddClusterPolicy(1450, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateLogicalVolumeParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateLogicalVolumeParameters.java new file mode 100644 index 0000000..657a350 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/gluster/CreateLogicalVolumeParameters.java @@ -0,0 +1,81 @@ +package org.ovirt.engine.core.common.action.gluster; + +import java.util.List; + +import org.ovirt.engine.core.common.action.VdsActionParameters; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.compat.Guid; + +public class CreateLogicalVolumeParameters extends VdsActionParameters { + + private static final long serialVersionUID = 761203751697100144L; + + private String lvName; + + private String fileSystem; + + private String fileSystemType; + + private Integer size; + + private List<StorageDeviceInfo> disks; + + public CreateLogicalVolumeParameters() { + + } + + public CreateLogicalVolumeParameters(Guid hostId, + String lvName, + String fileSystem, + String fileSystemType, + Integer size, + List<StorageDeviceInfo> disks) { + super(hostId); + this.lvName = lvName; + this.fileSystem = fileSystem; + this.fileSystemType = fileSystemType; + this.setDisks(disks); + this.size = size; + } + + public String getLvName() { + return lvName; + } + + public void setLvName(String lvName) { + this.lvName = lvName; + } + + public String getFileSystem() { + return fileSystem; + } + + public void setFileSystem(String fileSystem) { + this.fileSystem = fileSystem; + } + + public String getFileSystemType() { + return fileSystemType; + } + + public void setFileSystemType(String fileSystemType) { + this.fileSystemType = fileSystemType; + } + + public List<StorageDeviceInfo> getDisks() { + return disks; + } + + public void setDisks(List<StorageDeviceInfo> disks) { + this.disks = disks; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StorageDeviceInfo.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StorageDeviceInfo.java new file mode 100644 index 0000000..4b14085 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/gluster/StorageDeviceInfo.java @@ -0,0 +1,112 @@ +package org.ovirt.engine.core.common.businessentities.gluster; + +import java.io.Serializable; +import java.util.List; + +public class StorageDeviceInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + private String name; + private String fileSystem; + private String capacity; + private String type; + private String container; + private List<String> partitions; + + public StorageDeviceInfo() { + super(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getFileSystem() { + return fileSystem; + } + + public void setFileSystem(String fileSystem) { + this.fileSystem = fileSystem; + } + + public String getCapacity() { + return capacity; + } + + public void setCapacity(String capacity) { + this.capacity = capacity; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getContainer() { + return container; + } + + public List<String> getPartitions() { + return partitions; + } + + public void setContainer(String container) { + this.container = container; + } + + public void setPartitions(List<String> partitions) { + this.partitions = partitions; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((capacity == null) ? 0 : capacity.hashCode()); + result = prime * result + ((fileSystem == null) ? 0 : fileSystem.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + StorageDeviceInfo other = (StorageDeviceInfo) obj; + if (capacity == null) { + if (other.capacity != null) + return false; + } else if (!capacity.equals(other.capacity)) + return false; + if (fileSystem == null) { + if (other.fileSystem != null) + return false; + } else if (!fileSystem.equals(other.fileSystem)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 7ac717d..de6f895 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -330,6 +330,8 @@ GetGlusterVolumeRebalanceStatus, GetGlusterVolumeRemoveBricksStatus, GetGlusterVolumeByTaskId, + GetLogicalVolumes, + GetUnUsedDisks, GetDefaultConfigurationVersion(VdcQueryAuthType.User), OsRepository(VdcQueryAuthType.User), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java index 6a055cc..0915064 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java @@ -120,6 +120,7 @@ SetMOMPolicyParameters("org.ovirt.engine.core.vdsbroker.vdsbroker"), SetHaMaintenanceMode("org.ovirt.engine.core.vdsbroker.vdsbroker"), // Gluster VDS commands + CreateLogicalVolume("org.ovirt.engine.core.vdsbroker.gluster"), CreateGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"), SetGlusterVolumeOption("org.ovirt.engine.core.vdsbroker.gluster"), ResetGlusterVolumeOptions("org.ovirt.engine.core.vdsbroker.gluster"), @@ -156,6 +157,7 @@ GetDiskAlignment("org.ovirt.engine.core.vdsbroker.vdsbroker"), GlusterTasksList("org.ovirt.engine.core.vdsbroker.gluster"), GetGlusterVolumeRemoveBricksStatus("org.ovirt.engine.core.vdsbroker.gluster"), + GetDeviceInfo("org.ovirt.engine.core.vdsbroker.gluster"), SetNumberOfCpus("org.ovirt.engine.core.vdsbroker"), UpdateVmPolicy("org.ovirt.engine.core.vdsbroker"), List("org.ovirt.engine.core.vdsbroker.vdsbroker"), // get a list of VMs with status only diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/CreateLogicalVolumeVDSParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/CreateLogicalVolumeVDSParameters.java new file mode 100644 index 0000000..83150fa --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/gluster/CreateLogicalVolumeVDSParameters.java @@ -0,0 +1,87 @@ +/** + * + */ +package org.ovirt.engine.core.common.vdscommands.gluster; + +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.compat.Guid; + +/** + * VDS Command parameters class for the "Create logical Volume" action, with the volume object as parameter. + */ +public class CreateLogicalVolumeVDSParameters extends VdsIdVDSCommandParametersBase { + + private String lvName; + + private String fileSystem; + + private String fileSystemType; + + private Integer size; + + private List<StorageDeviceInfo> disks; + + public CreateLogicalVolumeVDSParameters() { + + } + + public CreateLogicalVolumeVDSParameters(Guid hostId, + String lvName, + String fileSystem, + String fileSystemType, + Integer size, + List<StorageDeviceInfo> disks) { + super(hostId); + this.lvName = lvName; + this.fileSystem = fileSystem; + this.fileSystemType = fileSystemType; + this.size = size; + this.setDisks(disks); + + } + + public String getLvName() { + return lvName; + } + + public void setLvName(String lvName) { + this.lvName = lvName; + } + + public String getFileSystem() { + return fileSystem; + } + + public void setFileSystem(String fileSystem) { + this.fileSystem = fileSystem; + } + + public String getFileSystemType() { + return fileSystemType; + } + + public void setFileSystemType(String fileSystemType) { + this.fileSystemType = fileSystemType; + } + + public List<StorageDeviceInfo> getDisks() { + return disks; + } + + public void setDisks(List<StorageDeviceInfo> disks) { + this.disks = disks; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CreateLogicalVolumeVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CreateLogicalVolumeVDSCommand.java new file mode 100644 index 0000000..faade89 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/CreateLogicalVolumeVDSCommand.java @@ -0,0 +1,45 @@ +package org.ovirt.engine.core.vdsbroker.gluster; + +import java.util.HashSet; +import java.util.Set; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.common.vdscommands.gluster.CreateLogicalVolumeVDSParameters; +import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc; +import org.ovirt.engine.core.vdsbroker.vdsbroker.VdsBrokerCommand; + +/** + * VDS command to create a gluster volume + */ +public class CreateLogicalVolumeVDSCommand<P extends CreateLogicalVolumeVDSParameters> extends VdsBrokerCommand<P> { + private OneUuidReturnForXmlRpc uuidReturn; + + public CreateLogicalVolumeVDSCommand(P parameters) { + super(parameters); + } + + @Override + protected StatusForXmlRpc getReturnStatus() { + return uuidReturn.mStatus; + } + + @Override + protected void executeVdsBrokerCommand() { + CreateLogicalVolumeVDSParameters parameters = getParameters(); + Set<String> diskNames = new HashSet<String>(); + + for(StorageDeviceInfo disk: parameters.getDisks()){ + diskNames.add(disk.getName()); + } + + getBroker().createLogicalVolume(diskNames.toArray(new String[0]), + parameters.getLvName(), + parameters.getSize(), + parameters.getFileSystemType()); + + // Handle errors if any + proceedProxyReturnValue(); + } + +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetDeviceInfoVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetDeviceInfoVDSCommand.java new file mode 100644 index 0000000..b53034d --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/GetDeviceInfoVDSCommand.java @@ -0,0 +1,32 @@ +package org.ovirt.engine.core.vdsbroker.gluster; + +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc; + +@SuppressWarnings({ "rawtypes", "unchecked" }) +public class GetDeviceInfoVDSCommand<P extends VdsIdVDSCommandParametersBase> extends AbstractGlusterBrokerCommand<P> { + + private StorageDeviceInfoListReturnForXmlRpc _result; + + public GetDeviceInfoVDSCommand(P parameters) { + super(parameters); + } + + @Override + protected void executeVdsBrokerCommand() { + _result = getBroker().getDeviceInfos(); + + proceedProxyReturnValue(); + setReturnValue(_result.getDeviceInfos()); + } + + @Override + protected StatusForXmlRpc getReturnStatus() { + return _result.mStatus; + } + + @Override + protected Object getReturnValueFromBroker() { + return _result; + } +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/StorageDeviceInfoListReturnForXmlRpc.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/StorageDeviceInfoListReturnForXmlRpc.java new file mode 100644 index 0000000..a7823f4 --- /dev/null +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/gluster/StorageDeviceInfoListReturnForXmlRpc.java @@ -0,0 +1,71 @@ +package org.ovirt.engine.core.vdsbroker.gluster; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.core.vdsbroker.irsbroker.StatusReturnForXmlRpc; + +public class StorageDeviceInfoListReturnForXmlRpc extends StatusReturnForXmlRpc { + + private static final String NAME = "name"; + private static final String FILE_SYSTEM = "fileSystem"; + private static final String SIZE = "size"; + private static final String TYPE = "type"; + private static final String DEVICE_INFO = "deviceInfo"; + private static final String CONTAINER = "container"; + private static final String PARTITIONS = "partitions"; + private static final String ORIGIN = "origin"; + private List<StorageDeviceInfo> deviceInfos; + + @SuppressWarnings("unchecked") + public StorageDeviceInfoListReturnForXmlRpc(Map<String, Object> innerMap) { + super(innerMap); + + if (mStatus.mCode != 0) { + return; + } + + Object[] deviceArray = (Object[]) innerMap.get(DEVICE_INFO); + deviceInfos = new ArrayList<StorageDeviceInfo>(); + + if (deviceArray != null) { + for (Object deviceInfoMap : deviceArray) { + StorageDeviceInfo deviceInfo = getDeviceInfo((Map<String, Object>) deviceInfoMap); + if (deviceInfo != null) { + deviceInfos.add(deviceInfo); + } + } + } + } + + private StorageDeviceInfo getDeviceInfo(Map<String, Object> map) { + if(map.containsKey(ORIGIN) && !map.get(ORIGIN).toString().equals("Primordial")){ + return null; + } + StorageDeviceInfo deviceInfo = new StorageDeviceInfo(); + deviceInfo.setName(map.get(NAME).toString()); + deviceInfo.setFileSystem(map.get(FILE_SYSTEM).toString()); + deviceInfo.setCapacity(map.get(SIZE).toString()); + deviceInfo.setType(map.get(TYPE).toString()); + deviceInfo.setContainer(map.get(CONTAINER).toString()); + deviceInfo.setPartitions(getPartitions((Object[]) map.get(PARTITIONS))); + return deviceInfo; + } + + private List<String> getPartitions(Object[] object) { + List<String> partitions = new ArrayList<String>(); + for (Object obj : object) { + obj.toString(); + partitions.add(obj.toString()); + } + return partitions; + } + + + public List<StorageDeviceInfo> getDeviceInfos() { + return deviceInfos; + } + +} diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java index bbba12b..755dfe1 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/jsonrpc/JsonRpcVdsServer.java @@ -21,6 +21,7 @@ import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeStatusReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeTaskReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumesListReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.gluster.StorageDeviceInfoListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfoReturnForXmlRpc; @@ -930,6 +931,19 @@ } @Override + public StatusOnlyReturnForXmlRpc createLogicalVolume(String[] disks, String lvName, int size, String fileSystemType) { + JsonRpcRequest request = + new RequestBuilder("LogicalVolume.create").withParameter("deviceNames", + new ArrayList<String>(Arrays.asList(disks))) + .withParameter("lvName", lvName) + .withParameter("size", size) + .withParameter("fs", fileSystemType) + .build(); + Map<String, Object> response = new FutureMap(this.client, request); + return new StatusOnlyReturnForXmlRpc(response); + } + + @Override public OneUuidReturnForXmlRpc glusterVolumeCreate(String volumeName, String[] brickList, int replicaCount, @@ -1420,4 +1434,13 @@ new FutureMap(this.client, request); return new StatusOnlyReturnForXmlRpc(response); } + + @Override + public StorageDeviceInfoListReturnForXmlRpc getDeviceInfos() { + JsonRpcRequest request = + new RequestBuilder("Gluster.getDeviceInfo").build(); + Map<String, Object> response = + new FutureMap(this.client, request).withIgnoreResponseKey(); + return new StorageDeviceInfoListReturnForXmlRpc(response); + } } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java index ff27a06..82c55dd 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IVdsServer.java @@ -16,6 +16,7 @@ import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeStatusReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeTaskReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumesListReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.gluster.StorageDeviceInfoListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfoReturnForXmlRpc; @@ -140,6 +141,8 @@ LUNListReturnForXmlRpc getDeviceList(int storageType); + StorageDeviceInfoListReturnForXmlRpc getDeviceInfos(); + DevicesVisibilityMapReturnForXmlRpc getDevicesVisibility(String[] devicesList); IQNListReturnForXmlRpc discoverSendTargets(Map<String, String> args); @@ -194,6 +197,12 @@ String baseVolUUID, String topVolUUID, String bandwidth, String jobUUID); // Gluster vdsm Commands + StatusOnlyReturnForXmlRpc createLogicalVolume(String[] disks, + String lvName, + int size, + String fileSystemType); + + // Gluster vdsm Commands OneUuidReturnForXmlRpc glusterVolumeCreate(String volumeName, String[] brickList, int replicaCount, diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java index c937834..20790ea 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerConnector.java @@ -294,4 +294,11 @@ public Map<String, Object> setNumberOfCpus(String vmId, String numberOfCpus); public Map<String, Object> updateVmPolicy(Map info); + + public Map<String, Object> glusterGetDeviceInfo(); + + public Map<String, Object> createLogicalVolume(String[] disks, + String fileSystem, + int size, + String fileSystemType); } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java index 82e28e0..530d395 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsServerWrapper.java @@ -18,12 +18,13 @@ import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeStatusReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumeTaskReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.gluster.GlusterVolumesListReturnForXmlRpc; +import org.ovirt.engine.core.vdsbroker.gluster.StorageDeviceInfoListReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.FileStatsReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.OneUuidReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.irsbroker.StoragePoolInfoReturnForXmlRpc; import org.ovirt.engine.core.vdsbroker.xmlrpc.XmlRpcRunTimeException; -@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings({ "rawtypes", "unchecked" }) public class VdsServerWrapper implements IVdsServer { private final VdsServerConnector vdsServer; @@ -324,7 +325,11 @@ } @Override - public StatusOnlyReturnForXmlRpc setVmTicket(String vmId, String otp64, String sec, String connectionAction, Map<String, String> params) { + public StatusOnlyReturnForXmlRpc setVmTicket(String vmId, + String otp64, + String sec, + String connectionAction, + Map<String, String> params) { try { Map<String, Object> xmlRpcReturnValue = vdsServer.setVmTicket(vmId, otp64, sec, connectionAction, params); StatusOnlyReturnForXmlRpc wrapper = new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); @@ -400,7 +405,7 @@ @Override public FenceStatusReturnForXmlRpc fenceNode(String ip, String port, String type, String user, String password, - String action, String secured, String options, Map<String, Object> fencingPolicy) { + String action, String secured, String options, Map<String, Object> fencingPolicy) { try { Map<String, Object> xmlRpcReturnValue; if (fencingPolicy == null) { @@ -916,6 +921,19 @@ } @Override + public StatusOnlyReturnForXmlRpc createLogicalVolume(String[] disks, String lvName, int size, String fileSystemType) { + try { + return new StatusOnlyReturnForXmlRpc(vdsServer.createLogicalVolume(disks, + lvName, + size, + fileSystemType)); + } catch (UndeclaredThrowableException ute) { + throw new XmlRpcRunTimeException(ute); + } + + } + + @Override public OneUuidReturnForXmlRpc glusterVolumeCreate(String volumeName, String[] brickList, int replicaCount, @@ -1085,9 +1103,13 @@ } @Override - public GlusterTaskInfoReturnForXmlRpc glusterVolumeRebalanceStart(String volumeName, Boolean fixLayoutOnly, Boolean force) { + public GlusterTaskInfoReturnForXmlRpc glusterVolumeRebalanceStart(String volumeName, + Boolean fixLayoutOnly, + Boolean force) { try { - return new GlusterTaskInfoReturnForXmlRpc(vdsServer.glusterVolumeRebalanceStart(volumeName, fixLayoutOnly, force)); + return new GlusterTaskInfoReturnForXmlRpc(vdsServer.glusterVolumeRebalanceStart(volumeName, + fixLayoutOnly, + force)); } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } @@ -1216,7 +1238,9 @@ } @Override - public GlusterVolumeProfileInfoReturnForXmlRpc glusterVolumeProfileInfo(Guid clusterId, String volumeName, boolean nfs) { + public GlusterVolumeProfileInfoReturnForXmlRpc glusterVolumeProfileInfo(Guid clusterId, + String volumeName, + boolean nfs) { try { Map<String, Object> xmlRpcReturnValue = vdsServer.glusterVolumeProfileInfo(volumeName, nfs); GlusterVolumeProfileInfoReturnForXmlRpc wrapper = @@ -1278,7 +1302,7 @@ try { Map<String, Object> xmlRpcReturnValue = vdsServer.glusterHostUUIDGet(); OneUuidReturnForXmlRpc wrapper = new OneUuidReturnForXmlRpc(xmlRpcReturnValue); - return wrapper; + return wrapper; } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } @@ -1308,9 +1332,14 @@ } @Override - public StatusOnlyReturnForXmlRpc glusterHookUpdate(String glusterCommand, String stage, String hookName, String content, String checksum) { + public StatusOnlyReturnForXmlRpc glusterHookUpdate(String glusterCommand, + String stage, + String hookName, + String content, + String checksum) { try { - Map<String, Object> xmlRpcReturnValue = vdsServer.glusterHookUpdate(glusterCommand, stage, hookName, content, checksum); + Map<String, Object> xmlRpcReturnValue = + vdsServer.glusterHookUpdate(glusterCommand, stage, hookName, content, checksum); StatusOnlyReturnForXmlRpc wrapper = new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); return wrapper; } catch (UndeclaredThrowableException ute) { @@ -1318,16 +1347,17 @@ } } - @Override + @Override public StatusOnlyReturnForXmlRpc glusterHookAdd(String glusterCommand, String stage, String hookName, String content, String checksum, Boolean enabled) { - try { - Map<String, Object> xmlRpcReturnValue = vdsServer.glusterHookAdd(glusterCommand, stage, hookName, content, checksum, enabled); - StatusOnlyReturnForXmlRpc wrapper = new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); - return wrapper; - } catch (UndeclaredThrowableException ute) { - throw new XmlRpcRunTimeException(ute); - } + try { + Map<String, Object> xmlRpcReturnValue = + vdsServer.glusterHookAdd(glusterCommand, stage, hookName, content, checksum, enabled); + StatusOnlyReturnForXmlRpc wrapper = new StatusOnlyReturnForXmlRpc(xmlRpcReturnValue); + return wrapper; + } catch (UndeclaredThrowableException ute) { + throw new XmlRpcRunTimeException(ute); + } } @Override @@ -1342,11 +1372,11 @@ } @Override - public GlusterServicesReturnForXmlRpc glusterServicesAction(Guid serverId, String [] serviceList, String actionType) { + public GlusterServicesReturnForXmlRpc glusterServicesAction(Guid serverId, String[] serviceList, String actionType) { try { - Map<String, Object> xmlRpcReturnValue = vdsServer.glusterServicesAction(serviceList, actionType); - GlusterServicesReturnForXmlRpc wrapper = new GlusterServicesReturnForXmlRpc(serverId, xmlRpcReturnValue); - return wrapper; + Map<String, Object> xmlRpcReturnValue = vdsServer.glusterServicesAction(serviceList, actionType); + GlusterServicesReturnForXmlRpc wrapper = new GlusterServicesReturnForXmlRpc(serverId, xmlRpcReturnValue); + return wrapper; } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } @@ -1431,4 +1461,11 @@ StoragePoolInfoReturnForXmlRpc wrapper = new StoragePoolInfoReturnForXmlRpc(xmlRpcReturnValue); return wrapper; } + + @Override + public StorageDeviceInfoListReturnForXmlRpc getDeviceInfos() { + Map<String, Object> xmlRpcReturnValue = vdsServer.glusterGetDeviceInfo(); + StorageDeviceInfoListReturnForXmlRpc wrapper = new StorageDeviceInfoListReturnForXmlRpc(xmlRpcReturnValue); + return wrapper; + } } diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index eae76a2..9d061f3 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -324,6 +324,8 @@ <include name="common/businessentities/gluster/GlusterHookContentType.java"/> <include name="common/businessentities/gluster/GlusterHookConflictFlags.java"/> <include name="common/businessentities/gluster/GlusterVolumeSizeInfo.java"/> + <include name="common/businessentities/gluster/StorageDeviceInfo.java"/> + <include name="common/asynctasks/gluster/GlusterAsyncTask.java"/> <include name="common/asynctasks/gluster/GlusterTaskStatus.java"/> <include name="common/asynctasks/gluster/GlusterTaskType.java"/> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index c52657e..c8bb83c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -84,8 +84,8 @@ import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; import org.ovirt.engine.core.common.interfaces.SearchType; import org.ovirt.engine.core.common.mode.ApplicationMode; -import org.ovirt.engine.core.common.queries.ArchCapabilitiesParameters.ArchCapabilitiesVerb; import org.ovirt.engine.core.common.queries.ArchCapabilitiesParameters; +import org.ovirt.engine.core.common.queries.ArchCapabilitiesParameters.ArchCapabilitiesVerb; import org.ovirt.engine.core.common.queries.CommandVersionsInfo; import org.ovirt.engine.core.common.queries.ConfigurationValues; import org.ovirt.engine.core.common.queries.GetAgentFenceOptionsQueryParameters; @@ -115,8 +115,8 @@ import org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters; import org.ovirt.engine.core.common.queries.MultilevelAdministrationsQueriesParameters; import org.ovirt.engine.core.common.queries.NameQueryParameters; -import org.ovirt.engine.core.common.queries.OsQueryParameters.OsRepositoryVerb; import org.ovirt.engine.core.common.queries.OsQueryParameters; +import org.ovirt.engine.core.common.queries.OsQueryParameters.OsRepositoryVerb; import org.ovirt.engine.core.common.queries.ProviderQueryParameters; import org.ovirt.engine.core.common.queries.SearchParameters; import org.ovirt.engine.core.common.queries.ServerParameters; @@ -3826,4 +3826,35 @@ }; } + public void getLogicalVolumes(AsyncQuery aQuery, Guid hostId) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source; + } + }; + VdsIdParametersBase parameters = + new VdsIdParametersBase(hostId); //$NON-NLS-1$ //$NON-NLS-2$ + Frontend.getInstance().runQuery(VdcQueryType.GetLogicalVolumes, + parameters, + aQuery); + } + + public void getUnUsedDisks(AsyncQuery aQuery, Guid hostId) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source; + } + }; + VdsIdParametersBase parameters = + new VdsIdParametersBase(hostId); //$NON-NLS-1$ //$NON-NLS-2$ + Frontend.getInstance().runQuery(VdcQueryType.GetUnUsedDisks, + parameters, + aQuery); + } + } + 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 a51df14..c671658 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 @@ -516,7 +516,10 @@ edit_cpu_profile("edit_cpu_profile", HelpTagType.WEBADMIN, "Cluster Tab > Cpu Profiles sub-tab -> Edit Cpu Profile dialog"), //$NON-NLS-1$ //$NON-NLS-2$ - remove_cpu_profile("remove_cpu_profile", HelpTagType.WEBADMIN, "Clsuter Tab > Cpu Profiles sub-tab -> Remove Cpu Profile dialog"); //$NON-NLS-1$ //$NON-NLS-2$ + remove_cpu_profile( + "remove_cpu_profile", HelpTagType.WEBADMIN, "Clsuter Tab > Cpu Profiles sub-tab -> Remove Cpu Profile dialog"), //$NON-NLS-1$ //$NON-NLS-2$ + + create_lv("create_lv", HelpTagType.WEBADMIN, "Host Tab > LV Sub Tab -> Create LV dialog"); //$NON-NLS-1$ //$NON-NLS-2$ public final String name; 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..419f75f --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/LogicalVolumeModel.java @@ -0,0 +1,92 @@ +package org.ovirt.engine.ui.uicommonweb.models.gluster; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.ui.uicommonweb.UICommand; +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; + ListModel<EntityModel<StorageDeviceInfo>> disks; + EntityModel<String> fileSystem; + EntityModel<String> fileSystemType; + EntityModel<Integer> size; + + public EntityModel<Integer> getSize() { + return size; + } + + public void setSize(EntityModel<Integer> size) { + this.size = size; + } + + private UICommand addDiskCommand; + + public LogicalVolumeModel() { + setLvName(new EntityModel<String>()); + setDisks(new ListModel<EntityModel<StorageDeviceInfo>>()); + setFileSystem(new EntityModel<String>()); + setFileSystemType(new EntityModel<String>("XFS")); //$NON-NLS-1$ + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + + if (command == getAddDiskCommand()) { + addDisk(); + } + } + + private void addDisk() { + + } + + public EntityModel<String> getLvName() { + return lvName; + } + + public void setLvName(EntityModel<String> lvName) { + this.lvName = lvName; + } + + public ListModel<EntityModel<StorageDeviceInfo>> getDisks() { + return disks; + } + + public void setDisks(ListModel<EntityModel<StorageDeviceInfo>> disks) { + this.disks = disks; + } + + public EntityModel<String> getFileSystem() { + return fileSystem; + } + + public void setFileSystem(EntityModel<String> filesystem) { + this.fileSystem = filesystem; + } + + public EntityModel<String> getFileSystemType() { + return fileSystemType; + } + + public void setFileSystemType(EntityModel<String> fileSystemType) { + this.fileSystemType = fileSystemType; + } + + public UICommand getAddDiskCommand() { + return addDiskCommand; + } + + public void setAddDiskCommand(UICommand addDiskCommand) { + this.addDiskCommand = addDiskCommand; + } + + public boolean validate() { + // TODO Auto-generated method stub + return true; + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/StorageDeviceListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/StorageDeviceListModel.java new file mode 100644 index 0000000..c058333 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/StorageDeviceListModel.java @@ -0,0 +1,192 @@ +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.CreateLogicalVolumeParameters; +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +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; + +public class StorageDeviceListModel extends SearchableListModel { + + @Override + public VDS getEntity() { + return (VDS) super.getEntity(); + } + + public void setEntity(VDS value) + { + super.setEntity(value); + } + + private UICommand addLVCommand; + + public UICommand getAddLVCommand() { + return addLVCommand; + } + + public void setAddLVCommand(UICommand addLVCommand) { + this.addLVCommand = addLVCommand; + } + + public StorageDeviceListModel() { + setTitle("Testing");//$NON-NLS-1$ + setHelpTag(HelpTag.disks); + setHashName("disks"); //$NON-NLS-1$ + setAddLVCommand(new UICommand("Create Logical Volume", this)); //$NON-NLS-1$ + setAvailableInModes(ApplicationMode.GlusterOnly); + } + + @Override + protected void onEntityChanged() { + super.onEntityChanged(); + getSearchCommand().execute(); + } + + @Override + protected void entityPropertyChanged(Object sender, PropertyChangedEventArgs e) + { + super.entityPropertyChanged(sender, e); + getSearchCommand().execute(); + } + + @Override + public void search() + { + if (getEntity() != null) + { + super.search(); + } + } + + @Override + protected void syncSearch() + { + if (getEntity() == null || getEntity().getStatus() != VDSStatus.Up) { + return; + } + + AsyncDataProvider.getInstance().getLogicalVolumes(new AsyncQuery(this, new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + List<StorageDeviceInfo> disks = (List<StorageDeviceInfo>) returnValue; + setItems(disks); + } + }), getEntity().getId()); + + } + + @Override + protected String getListName() { + return "HostDeviceListListModel"; //$NON-NLS-1$ + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + if (command.equals(getAddLVCommand())) { + createLV(); + } else if (command.getName().equals("OnCreateLV")) { //$NON-NLS-1$ + onCreateLV(); + } else if (command.getName().equals("Cancel")) { //$NON-NLS-1$ + setWindow(null); + } + } + + private void onCreateLV() { + 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<StorageDeviceInfo> selectedDisks = new ArrayList<StorageDeviceInfo>(); + for (EntityModel<StorageDeviceInfo> disk : lvModel.getDisks().getSelectedItems()) { + selectedDisks.add(disk.getEntity()); + } + + CreateLogicalVolumeParameters parameters = + new CreateLogicalVolumeParameters(host.getId(), + lvModel.getLvName().getEntity(), + lvModel.getFileSystem().getEntity(), + lvModel.getFileSystemType().getEntity(), + lvModel.getSize().getEntity(), + selectedDisks); + Frontend.getInstance().runAction(VdcActionType.CreateLogicalVolume, parameters); + lvModel.stopProgress(); + } + + private void createLV() { + 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().createLogicalVolume()); + lvModel.setHelpTag(HelpTag.create_lv); + lvModel.setHashName("create_logical_volume"); //$NON-NLS-1$ + + setWindow(lvModel); + + AsyncQuery _asyncQuery = new AsyncQuery(); + _asyncQuery.setModel(lvModel); + _asyncQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object result) + { + LogicalVolumeModel lvModel = (LogicalVolumeModel) model; + List<EntityModel<StorageDeviceInfo>> disksList = new ArrayList<EntityModel<StorageDeviceInfo>>(); + List<StorageDeviceInfo> disks = (List<StorageDeviceInfo>) result; + for (StorageDeviceInfo disk : disks) { + EntityModel<StorageDeviceInfo> diskModel = new EntityModel<StorageDeviceInfo>(disk); + disksList.add(diskModel); + } + lvModel.getDisks().setItems(disksList); + } + }; + AsyncDataProvider.getInstance().getUnUsedDisks(_asyncQuery, host.getId()); + + UICommand command = new UICommand("OnCreateLV", this); //$NON-NLS-1$ + command.setTitle(ConstantsManager.getInstance().getConstants().ok()); + command.setIsDefault(true); + lvModel.getCommands().add(command); + + command = new UICommand("Cancel", this); //$NON-NLS-1$ + command.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + command.setIsCancel(true); + lvModel.getCommands().add(command); + } +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java index 33bbca0..12fe090 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java @@ -76,6 +76,7 @@ import org.ovirt.engine.ui.uicommonweb.models.events.TaskListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterFeaturesUtil; import org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.StorageDeviceListModel; import org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel; import org.ovirt.engine.ui.uicommonweb.models.tags.TagModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; @@ -313,6 +314,16 @@ private void setHostEventListModel(HostEventListModel value) { privateHostEventListModel = value; + } + + private StorageDeviceListModel disksModel; + + public StorageDeviceListModel getDisksModel() { + return disksModel; + } + + public void setDisksModel(StorageDeviceListModel disksModel) { + this.disksModel = disksModel; } private boolean isPowerManagementEnabled; @@ -1837,6 +1848,7 @@ setGlusterSwiftModel(new HostGlusterSwiftListModel()); setHostBricksListModel(new HostBricksListModel()); + setDisksModel(new StorageDeviceListModel()); setHostVmListModel(new HostVmListModel()); ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(generalModel); @@ -1848,6 +1860,7 @@ list.add(new HostHooksListModel()); list.add(getGlusterSwiftModel()); list.add(getHostBricksListModel()); + list.add(getDisksModel()); list.add(new PermissionListModel()); setDetailModels(list); } 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 7a7637e..293feb4 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 @@ -1,8 +1,9 @@ package org.ovirt.engine.ui.uicompat; -import com.google.gwt.i18n.client.Constants; import org.ovirt.engine.core.common.businessentities.VmPool; + +import com.google.gwt.i18n.client.Constants; public interface UIConstants extends com.google.gwt.i18n.client.Constants { @@ -2427,5 +2428,12 @@ @DefaultStringValue("CPU Profile") String cpuProfileTitle(); + + @DefaultStringValue("Create Logical Volume") + String createLogicalVolume(); + + @DefaultStringValue("Logical Volumes") + String logicalVolumesTitle(); + } 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 1bbe4a1..5be6aa4 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 @@ -2280,6 +2280,16 @@ @DefaultStringValue("Volume") String volumeName(); + // Disk + @DefaultStringValue("Disk") + String diskName(); + + @DefaultStringValue("File System") + String fileSystem(); + + @DefaultStringValue("Size") + String size(); + @DefaultStringValue("Brick Directory") String brickDirectory(); @@ -3906,4 +3916,16 @@ @DefaultStringValue("QoS") String cpuProfileQosLabel(); + + @DefaultStringValue("Logical Volume") + String logicalVolume(); + + @DefaultStringValue("File System Type") + String fileSystemType(); + + @DefaultStringValue("Create Logical Volume") + String createLogicalVolume(); + + @DefaultStringValue("Size") + String sizeLV(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java index fbb2bd8..063f03e 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java @@ -18,13 +18,14 @@ import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmPool; import org.ovirt.engine.core.common.businessentities.VmTemplate; -import org.ovirt.engine.core.common.businessentities.aaa.DbUser; import org.ovirt.engine.core.common.businessentities.event_subscriber; +import org.ovirt.engine.core.common.businessentities.aaa.DbUser; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterHookEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; import org.ovirt.engine.core.common.businessentities.network.ExternalSubnet; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.NetworkCluster; @@ -70,6 +71,7 @@ import org.ovirt.engine.ui.uicommonweb.models.disks.DiskVmListModel; import org.ovirt.engine.ui.uicommonweb.models.events.EventListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.StorageDeviceListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeBrickListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeEventListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeGeneralModel; @@ -315,6 +317,8 @@ SearchableDetailModelProvider<GlusterBrickEntity, HostListModel, HostBricksListModel> getSubTabHostBricksModelProvider(); + SearchableDetailModelProvider<StorageDeviceInfo, HostListModel, StorageDeviceListModel> getSubTabDisksModelProvider(); + // Pool DetailModelProvider<PoolListModel, PoolGeneralModel> getSubTabPoolGeneralModelProvider(); 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 3aadfe4..a58fb97 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.CreateLogicalVolumePopupPresenterWidget; 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; @@ -166,6 +167,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumePermissionPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.VolumeSubTabPanelPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.HostSubTabPanelPresenter; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabDisksPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostBrickPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostEventPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostGeneralPresenter; @@ -276,6 +278,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.CreateLogicalVolumePopupView; 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; @@ -406,6 +409,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumePermissionView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.VolumeSubTabPanelView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.HostSubTabPanelView; +import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabDisksView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostBrickView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostEventView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostGeneralView; @@ -810,6 +814,10 @@ SubTabHostBrickPresenter.ViewDef.class, SubTabHostBrickView.class, SubTabHostBrickPresenter.ProxyDef.class); + bindPresenter(SubTabDisksPresenter.class, + SubTabDisksPresenter.ViewDef.class, + SubTabDisksView.class, + SubTabDisksPresenter.ProxyDef.class); // VirtualMachine bindPresenter(VirtualMachineSubTabPanelPresenter.class, @@ -1433,6 +1441,10 @@ AddBrickPopupPresenterWidget.ViewDef.class, AddBrickPopupView.class); + bindPresenterWidget(CreateLogicalVolumePopupPresenterWidget.class, + CreateLogicalVolumePopupPresenterWidget.ViewDef.class, + CreateLogicalVolumePopupView.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 df8c076..d050097 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 @@ -9,6 +9,7 @@ import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; import org.ovirt.engine.ui.common.presenter.ModelBoundPresenterWidget; import org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget; @@ -26,6 +27,7 @@ import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.StorageDeviceListModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostBondInterfaceModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostBricksListModel; import org.ovirt.engine.ui.uicommonweb.models.hosts.HostEventListModel; @@ -45,6 +47,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.DetachConfirmationPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.PermissionsPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.CreateLogicalVolumePopupPresenterWidget; 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; @@ -173,6 +176,29 @@ HostListModel.class, HostBricksListModel.class); } + + @Provides + @Singleton + public SearchableDetailModelProvider<StorageDeviceInfo, HostListModel, StorageDeviceListModel> getDisksListProvider(EventBus eventBus, + Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, + final Provider<CreateLogicalVolumePopupPresenterWidget> createLVPopupProvider) { + return new SearchableDetailTabModelProvider<StorageDeviceInfo, HostListModel, StorageDeviceListModel>( + eventBus, defaultConfirmPopupProvider, + HostListModel.class, + StorageDeviceListModel.class) { + @Override + public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(StorageDeviceListModel source, + UICommand lastExecutedCommand, + Model windowModel) { + if (lastExecutedCommand == getModel().getAddLVCommand()) { + return createLVPopupProvider.get(); + } else { + return super.getModelPopup(source, lastExecutedCommand, windowModel); + } + } + }; + } + @Provides @Singleton public SearchableDetailModelProvider<HostInterfaceLineModel, HostListModel, HostInterfaceListModel> getHostInterfaceListProvider(EventBus eventBus, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java index 937f0d5..cc36187 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java @@ -211,6 +211,9 @@ public static final String hostBricksSubTabPlace = hostMainTabPlace + SUB_TAB_PREFIX + "gluster_bricks"; //$NON-NLS-1$ + public static final String hostDisksSubTabPlace = hostMainTabPlace + SUB_TAB_PREFIX + + "disks"; //$NON-NLS-1$ + public static final String hostPermissionSubTabPlace = hostMainTabPlace + SUB_TAB_PREFIX + "permissions"; //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateLogicalVolumePopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateLogicalVolumePopupPresenterWidget.java new file mode 100644 index 0000000..30010d9 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/CreateLogicalVolumePopupPresenterWidget.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 CreateLogicalVolumePopupPresenterWidget extends AbstractModelBoundPopupPresenterWidget<LogicalVolumeModel, CreateLogicalVolumePopupPresenterWidget.ViewDef> { + + public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<LogicalVolumeModel> { + } + + @Inject + public CreateLogicalVolumePopupPresenterWidget(EventBus eventBus, ViewDef view) { + super(eventBus, view); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/host/SubTabDisksPresenter.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/host/SubTabDisksPresenter.java new file mode 100644 index 0000000..2a36db0 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/host/SubTabDisksPresenter.java @@ -0,0 +1,60 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +import org.ovirt.engine.ui.common.place.PlaceRequestFactory; +import org.ovirt.engine.ui.common.presenter.AbstractSubTabPresenter; +import org.ovirt.engine.ui.common.uicommon.model.DetailModelProvider; +import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider; +import org.ovirt.engine.ui.common.widget.tab.ModelBoundTabData; +import org.ovirt.engine.ui.uicommonweb.models.gluster.StorageDeviceListModel; +import org.ovirt.engine.ui.uicommonweb.models.hosts.HostListModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.place.ApplicationPlaces; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.HostSelectionChangeEvent; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; +import com.gwtplatform.mvp.client.TabData; +import com.gwtplatform.mvp.client.annotations.NameToken; +import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit; +import com.gwtplatform.mvp.client.annotations.ProxyEvent; +import com.gwtplatform.mvp.client.annotations.TabInfo; +import com.gwtplatform.mvp.client.proxy.PlaceManager; +import com.gwtplatform.mvp.client.proxy.PlaceRequest; +import com.gwtplatform.mvp.client.proxy.TabContentProxyPlace; + +public class SubTabDisksPresenter extends AbstractSubTabPresenter<VDS, HostListModel, StorageDeviceListModel, SubTabDisksPresenter.ViewDef, SubTabDisksPresenter.ProxyDef> { + + @ProxyCodeSplit + @NameToken(ApplicationPlaces.hostDisksSubTabPlace) + public interface ProxyDef extends TabContentProxyPlace<SubTabDisksPresenter> { + } + + public interface ViewDef extends AbstractSubTabPresenter.ViewDef<VDS> { + } + + @TabInfo(container = HostSubTabPanelPresenter.class) + static TabData getTabData(ApplicationConstants applicationConstants, + DetailModelProvider<HostListModel, StorageDeviceListModel> modelProvider) { + return new ModelBoundTabData(applicationConstants.disksLabel(), 4, modelProvider); + } + + @Inject + public SubTabDisksPresenter(EventBus eventBus, ViewDef view, ProxyDef proxy, + PlaceManager placeManager, SearchableDetailModelProvider<StorageDeviceInfo, HostListModel, StorageDeviceListModel> modelProvider) { + super(eventBus, view, proxy, placeManager, modelProvider, + HostSubTabPanelPresenter.TYPE_SetTabContent); + } + + @Override + protected PlaceRequest getMainTabRequest() { + return PlaceRequestFactory.get(ApplicationPlaces.hostMainTabPlace); + } + + @ProxyEvent + public void onHostSelectionChange(HostSelectionChangeEvent event) { + updateMainTabSelection(event.getSelectedItems()); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.java new file mode 100644 index 0000000..a4a77f6 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.java @@ -0,0 +1,126 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster; + +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +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.generic.IntegerEntityModelTextBoxEditor; +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.CreateLogicalVolumePopupPresenterWidget; + +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.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 CreateLogicalVolumePopupView extends AbstractModelBoundPopupView<LogicalVolumeModel> implements CreateLogicalVolumePopupPresenterWidget.ViewDef { + + interface Driver extends SimpleBeanEditorDriver<LogicalVolumeModel, CreateLogicalVolumePopupView> { + } + + interface ViewUiBinder extends UiBinder<SimpleDialogPanel, CreateLogicalVolumePopupView> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<CreateLogicalVolumePopupView> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + @UiField + @Path(value = "lvName.entity") + @WithElementId + StringEntityModelTextBoxEditor lvNameEditor; + + @UiField + @Ignore + @WithElementId + Label disksHeader; + + @UiField(provided = true) + @Ignore + @WithElementId + EntityModelCellTable<ListModel> disksTable; + + @UiField + @Path(value = "fileSystemType.entity") + @WithElementId + StringEntityModelTextBoxEditor fileSystemTypeEditor; + + @UiField + @Path(value = "size.entity") + @WithElementId + IntegerEntityModelTextBoxEditor sizeEditor; + + private final Driver driver = GWT.create(Driver.class); + + @Inject + public CreateLogicalVolumePopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) { + super(eventBus, resources); + disksTable = new EntityModelCellTable<ListModel>(true); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + ViewIdHandler.idHandler.generateAndSetIds(this); + localize(constants); + initTableColumns(constants); + driver.initialize(this); + } + + protected void initTableColumns(ApplicationConstants constants){ + // Table Entity Columns + disksTable.addEntityModelColumn(new EntityModelTextColumn<StorageDeviceInfo>() { + @Override + public String getText(StorageDeviceInfo entity) { + return entity.getName(); + } + }, constants.diskName()); + + disksTable.addEntityModelColumn(new EntityModelTextColumn<StorageDeviceInfo>() { + @Override + public String getText(StorageDeviceInfo entity) { + return entity.getCapacity(); + } + }, constants.size()); + } + + private void clearSelections() { + if (disksTable.getSelectionModel() instanceof MultiSelectionModel) { + ((MultiSelectionModel) disksTable.getSelectionModel()).clear(); + } + } + + private void localize(ApplicationConstants constants) { + lvNameEditor.setLabel(constants.logicalVolume()); + fileSystemTypeEditor.setLabel(constants.fileSystemType()); + sizeEditor.setLabel(constants.sizeLV()); + disksHeader.setText(constants.disksLabel()); + } + + @Override + public void edit(final LogicalVolumeModel object) { + disksTable.asEditor().edit(object.getDisks()); + driver.edit(object); + } + + @Override + public LogicalVolumeModel flush() { + disksTable.flush(); + return driver.flush(); + } + + interface WidgetStyle extends CssResource { + String editorContentWidget(); + String forceEditorWidget(); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.ui.xml new file mode 100644 index 0000000..35cf3d5 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/CreateLogicalVolumePopupView.ui.xml @@ -0,0 +1,48 @@ +<?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; + } + + .editorContentWidget{ + width: 200px; + } + + .tablePanel { + height: 270px; + width: 500px; + padding: 5px; + border: 1px solid #CED8DF; + } + + .tableContainer { + padding-left: 20px + } + + </ui:style> + + <d:SimpleDialogPanel width="550px" height="480px"> + <d:content> + <g:VerticalPanel> + <ge:StringEntityModelTextBoxEditor ui:field="lvNameEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="fileSystemTypeEditor" /> + <ge:IntegerEntityModelTextBoxEditor ui:field="sizeEditor" /> + <g:Label ui:field="disksHeader" addStyleNames="{style.headerLabel}"/> + <g:VerticalPanel addStyleNames="{style.tableContainer}" > + <g:ScrollPanel> + <e:EntityModelCellTable ui:field="disksTable"/> + </g:ScrollPanel> + </g:VerticalPanel> + </g:VerticalPanel> + </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/SubTabDisksView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabDisksView.java new file mode 100644 index 0000000..5ad3f07 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/host/SubTabDisksView.java @@ -0,0 +1,66 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.tab.host; + +import javax.inject.Inject; + +import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.gluster.StorageDeviceInfo; +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.StorageDeviceListModel; +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.SubTabDisksPresenter; +import org.ovirt.engine.ui.webadmin.section.main.view.AbstractSubTabTableView; +import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; + +public class SubTabDisksView extends AbstractSubTabTableView<VDS, StorageDeviceInfo, HostListModel, StorageDeviceListModel> + implements SubTabDisksPresenter.ViewDef { + + @Inject + public SubTabDisksView(SearchableDetailModelProvider<StorageDeviceInfo, HostListModel, StorageDeviceListModel> modelProvider, + ApplicationConstants constants) { + super(modelProvider); + initTable(constants); + initWidget(getTable()); + } + + void initTable(ApplicationConstants constants) { + getTable().enableColumnResizing(); + + TextColumnWithTooltip<StorageDeviceInfo> diskNameColumn = new TextColumnWithTooltip<StorageDeviceInfo>() { + @Override + public String getValue(StorageDeviceInfo object) { + return object.getName(); + } + }; + diskNameColumn.makeSortable(); + getTable().addColumn(diskNameColumn, constants.logicalVolume()); //$NON-NLS-1$ + + TextColumnWithTooltip<StorageDeviceInfo> deviceTypeColumn = new TextColumnWithTooltip<StorageDeviceInfo>() { + @Override + public String getValue(StorageDeviceInfo object) { + return object.getFileSystem(); + } + }; + deviceTypeColumn.makeSortable(); + getTable().addColumn(deviceTypeColumn, constants.fileSystem()); //$NON-NLS-1$ + + TextColumnWithTooltip<StorageDeviceInfo> sizeColumn = new TextColumnWithTooltip<StorageDeviceInfo>() { + @Override + public String getValue(StorageDeviceInfo object) { + return object.getCapacity(); + } + }; + sizeColumn.makeSortable(); + getTable().addColumn(sizeColumn, constants.size()); //$NON-NLS-1$ + + getTable().addActionButton(new WebAdminButtonDefinition<StorageDeviceInfo>(constants.createLogicalVolume()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getAddLVCommand(); + } + }); + } + +} -- To view, visit http://gerrit.ovirt.org/32485 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6452b2fbffca9f372f861eb6bcb81de10c4ef6ff Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ramesh N <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
