summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java2
-rw-r--r--src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java24
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java40
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/NavigationView.java8
-rw-r--r--src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java31
5 files changed, 54 insertions, 51 deletions
diff --git a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
index c47830b2..2a6f053a 100644
--- a/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
+++ b/src/com.gluster.storage.management.client/src/com/gluster/storage/management/client/GlusterDataModelManager.java
@@ -288,7 +288,7 @@ public class GlusterDataModelManager {
List<Disk> allDisks = getReadyDisksOfAllServers();
String brickInfo[] = volumeDisk.split(":");
for (Disk disk : allDisks) {
- if (disk.getServerName() == brickInfo[0] && disk.getName() == brickInfo[1]) {
+ if (disk.getServerName().equals(brickInfo[0]) && disk.getName().equals(brickInfo[1])) {
return disk;
}
}
diff --git a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java
index ac77c76f..b1ceb478 100644
--- a/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java
+++ b/src/com.gluster.storage.management.core/src/com/gluster/storage/management/core/utils/ValidationUtil.java
@@ -1,6 +1,5 @@
package com.gluster.storage.management.core.utils;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ValidationUtil {
@@ -23,7 +22,16 @@ public class ValidationUtil {
isValid = false;
}
- for (int i = 0; i < ipAddress.length && isValid; i++) {
+ int iterator=ipAddress.length-1;
+
+ if (ipAddress.length <= 4 && ipAddress[ipAddress.length - 1].equals("*")) {
+ iterator = ipAddress.length - 2;
+ } else if (ipAddress.length < 4 || ipAddress.length > 4 ){
+ isValid = false;
+ iterator = ipAddress.length - 1;
+ }
+
+ for (int i = 0; i <= iterator && isValid; i++) {
if (ipAddress[i].equals("*")) {
isValid = (i == ipAddress.length - 1) ? isValid : false;
} else {
@@ -40,7 +48,9 @@ public class ValidationUtil {
if (ip.equals("0.0.0.0") || ip.equals("255.255.255.255")) { // Invalidate the special ip's
isValid = false;
}
-
+ if (ipAddress.length < 4) {
+ isValid = false;
+ }
for (int i = 0; i < ipAddress.length && isValid; i++) {
isValid = isValidIpQuad(ipAddress[i]);
}
@@ -60,9 +70,11 @@ public class ValidationUtil {
public static void main(String[] argv) {
String ip = "0.0.0.0";
- System.out.println("Is valid ip (" + ip + ")? " + isValidIp(ip));
- String hostName = "Selvam-sd.com";
- System.out.println(isValidHostName(hostName));
+ // System.out.println("Is valid ip (" + ip + ")? " + isValidIp(ip));
+ String hostName = "myhost.q";
+ // System.out.println(isValidHostName(hostName));
+ // System.out.println(isValidHostName(hostName));
+ System.out.println(isValidAccessControl(hostName));
}
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java
index 7dd8e27d..e319dcca 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/dialogs/CreateVolumePage1.java
@@ -50,7 +50,7 @@ import com.gluster.storage.management.core.model.Volume;
import com.gluster.storage.management.core.model.Volume.NAS_PROTOCOL;
import com.gluster.storage.management.core.model.Volume.TRANSPORT_TYPE;
import com.gluster.storage.management.core.model.Volume.VOLUME_TYPE;
-import com.gluster.storage.management.core.response.VolumeListResponse;
+import com.gluster.storage.management.core.utils.ValidationUtil;
public class CreateVolumePage1 extends WizardPage {
public static final String PAGE_NAME = "create.volume.page.1";
@@ -309,21 +309,6 @@ public class CreateVolumePage1 extends WizardPage {
return true;
}
- private Boolean isValidIP(String ip) {
- // String pattern = "^.[0-9]{1,3}/..[0-9]{1,3}/..[0-9]{1,3}/..[0-9]{1,3}";
- String pattern = "^.[0-9]{1,3}/.";
- if (ip == "*") {
- return true;
- }
- String[] ipQuads = ip.split(".");
- for (String quad : ipQuads) {
- if (!quad.matches(pattern)) {
- return false;
- }
- }
- return true;
- }
-
private void validateForm() {
clearErrors();
validateVolumeName();
@@ -337,26 +322,25 @@ public class CreateVolumePage1 extends WizardPage {
if(diskCount < 1) {
setError("At least one disk must be selected!");
}
-
- String volumeType = (String)((IStructuredSelection)typeComboViewer.getSelection()).getFirstElement();
- if (volumeType.equals(VOLUME_TYPE.DISTRIBUTED_MIRROR) && (diskCount % 2 != 0)) {
+
+ VOLUME_TYPE volumeType = (VOLUME_TYPE) ((IStructuredSelection) typeComboViewer
+ .getSelection()).getFirstElement();
+ if (volumeType == VOLUME_TYPE.DISTRIBUTED_MIRROR && diskCount % 2 != 0) {
setError("Mirror type volume requires disks in multiples of two");
- } else if(volumeType.equals(VOLUME_TYPE.DISTRIBUTED_STRIPE) && (diskCount % 4 != 0)) {
+ } else if (volumeType == VOLUME_TYPE.DISTRIBUTED_STRIPE && diskCount % 4 != 0) {
setError("Stripe type volume requires disks in multiples of four");
}
}
-
+
private void validateAccessControl() {
String accessControl = txtAccessControl.getText().trim();
- if(accessControl.length() == 0) {
+ if (accessControl.length() == 0) {
setError("Please enter Access Control");
+ return;
}
- // acl validation
- String[] aclList = accessControl.split(",");
- for (String ip : aclList) {
- if (!isValidIP(ip)) {
- setError("Please enter valid access control list");
- }
+
+ if (!ValidationUtil.isValidAccessControl(accessControl)) {
+ setError("Access control list must be a comma separated list of IP addresses/Host names. Please enter a valid value!");
}
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/NavigationView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/NavigationView.java
index 4de5b61a..aede70c5 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/NavigationView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/NavigationView.java
@@ -90,13 +90,7 @@ public class NavigationView extends ViewPart implements ISelectionListener {
@Override
public void volumeChanged(Volume volume, Event event) {
super.volumeChanged(volume, event);
- selectEntity(volume); // this makes sure that the toolbar buttons get updated accoring to new status
- }
-
- @Override
- public void volumeCreated(Volume volume) {
- super.volumeCreated(volume);
- selectEntity(volume);
+ selectEntity(volume); // this makes sure that the toolbar buttons get updated according to new status
}
});
}
diff --git a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
index 497e939e..6ff61934 100644
--- a/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
+++ b/src/com.gluster.storage.management.gui/src/com/gluster/storage/management/gui/views/VolumeSummaryView.java
@@ -158,14 +158,16 @@ public class VolumeSummaryView extends ViewPart {
private GridData createDefaultLayoutData() {
GridData layoutData = new GridData();
- layoutData.minimumWidth = 150;
- layoutData.widthHint = 150;
+ layoutData.minimumWidth = 300;
+ layoutData.widthHint = 300;
return layoutData;
}
+
private void createAccessControlField(Composite section) {
toolkit.createLabel(section, "Access Control: ", SWT.NONE);
accessControlText = toolkit.createText(section, volume.getAccessControlList());
+
populateAccessControlText();
addKeyListerForAccessControl();
accessControlText.setLayoutData(createDefaultLayoutData());
@@ -175,6 +177,15 @@ public class VolumeSummaryView extends ViewPart {
// error decoration used while validating the access control text
errDecoration = guiHelper.createErrorDecoration(accessControlText);
errDecoration.hide();
+ createAccessControlInfoLabel(section); // info text
+ }
+
+ private void createAccessControlInfoLabel(Composite section) {
+ toolkit.createLabel(section, "", SWT.NONE);
+ Label accessControlInfoLabel = toolkit.createLabel(section, "(Comma separated list of IP addresses/hostnames)");
+ GridData data = new GridData(SWT.LEFT, SWT.CENTER, true, false);
+ data.horizontalSpan = 2;
+ accessControlInfoLabel.setLayoutData(data);
}
private void createChangeLinkForAccessControl(Composite section) {
@@ -211,17 +222,20 @@ public class VolumeSummaryView extends ViewPart {
guiHelper.setStatusMessage("Setting access control list to [" + newACL + "]...");
parent.update();
- if (!newACL.equals(volume.getAccessControlList()) && ValidationUtil.isValidAccessControl(newACL)) {
- BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
+ if (newACL.equals(volume.getAccessControlList())) {
+ accessControlText.setEnabled(false);
+ changeLink.setText("change");
+ } else if (ValidationUtil.isValidAccessControl(newACL)) {
+ BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
@Override
public void run() {
Status status = (new VolumesClient(GlusterDataModelManager.getInstance().getSecurityToken()))
- .setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, newACL);
-
+ .setVolumeOption(volume.getName(), Volume.OPTION_AUTH_ALLOW, newACL);
+
if (status.isSuccess()) {
accessControlText.setEnabled(false);
changeLink.setText("change");
-
+
GlusterDataModelManager.getInstance().setAccessControlList(volume, newACL);
} else {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control",
@@ -230,8 +244,7 @@ public class VolumeSummaryView extends ViewPart {
}
});
} else {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control",
- "Invalid IP / Host name ");
+ MessageDialog.openError(Display.getDefault().getActiveShell(), "Access control", "Invalid IP / Host name ");
}
guiHelper.clearStatusMessage();
parent.update();