You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2014/09/26 10:51:23 UTC

[1/3] git commit: updated refs/heads/master to 4eeae5a

Repository: cloudstack
Updated Branches:
  refs/heads/master d19a78ddf -> 4eeae5ad5


CLOUDSTACK-7495. Volume resize is only supported on kvm, vmware and xenserver. If
the operation is tried on other hypervisors it fails but logs a stack trace. We
should just log a message that the operation isn't supported.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ec1123ac
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ec1123ac
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ec1123ac

Branch: refs/heads/master
Commit: ec1123aca18009ac91e571e150fcf4c98df5e482
Parents: d19a78d
Author: Devdeep Singh <de...@gmail.com>
Authored: Fri Sep 26 13:13:24 2014 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Sep 26 13:15:31 2014 +0530

----------------------------------------------------------------------
 .../command/admin/volume/ResizeVolumeCmdByAdmin.java    | 12 ++++++++++--
 .../api/command/user/volume/ResizeVolumeCmd.java        | 11 +++++++++--
 server/src/com/cloud/storage/VolumeApiServiceImpl.java  |  2 +-
 3 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
index d1d253c..542fff5 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
@@ -24,6 +24,7 @@ import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.storage.Volume;
 
@@ -33,8 +34,15 @@ public class ResizeVolumeCmdByAdmin extends ResizeVolumeCmd {
 
     @Override
     public void execute() throws ResourceAllocationException{
-        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
-        Volume volume = _volumeService.resizeVolume(this);
+        Volume volume = null;
+        try {
+            CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
+            volume = _volumeService.resizeVolume(this);
+        } catch (InvalidParameterValueException ex) {
+            s_logger.info(ex.getMessage());
+            throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
+        }
+
         if (volume != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
             //FIXME - have to be moved to ApiResponseHelper

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
index 49fd6ca..4ec9449 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
@@ -160,8 +160,15 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
 
     @Override
     public void execute() throws ResourceAllocationException {
-        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
-        Volume volume = _volumeService.resizeVolume(this);
+        Volume volume = null;
+        try {
+            CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
+            volume = _volumeService.resizeVolume(this);
+        } catch (InvalidParameterValueException ex) {
+            s_logger.info(ex.getMessage());
+            throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
+        }
+
         if (volume != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
             //FIXME - have to be moved to ApiResponseHelper

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec1123ac/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 8ccede7..d89ea4f 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -720,7 +720,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer &&
                 hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.None) {
-            throw new InvalidParameterValueException("CloudStack currently only supports volumes marked as the KVM, VMware, or XenServer hypervisor type for resize.");
+            throw new InvalidParameterValueException("CloudStack currently supports volume resize only on KVM, VMware, or XenServer.");
         }
 
         if (volume.getState() != Volume.State.Ready && volume.getState() != Volume.State.Allocated) {


[2/3] git commit: updated refs/heads/master to 4eeae5a

Posted by de...@apache.org.
CLOUDSTACK-7575: improved performance of cleanString method in StringUtils


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7972f53c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7972f53c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7972f53c

Branch: refs/heads/master
Commit: 7972f53c8d35b78bd27cbd2c8bb1beb763b69c00
Parents: ec1123a
Author: Anshul Gangwar <an...@citrix.com>
Authored: Thu Sep 18 15:23:47 2014 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Sep 26 14:02:41 2014 +0530

----------------------------------------------------------------------
 utils/src/com/cloud/utils/StringUtils.java | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7972f53c/utils/src/com/cloud/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/StringUtils.java b/utils/src/com/cloud/utils/StringUtils.java
index 7014e5c..74dbd4d 100644
--- a/utils/src/com/cloud/utils/StringUtils.java
+++ b/utils/src/com/cloud/utils/StringUtils.java
@@ -159,9 +159,7 @@ public class StringUtils {
     }
 
     // removes a password request param and it's value, also considering password is in query parameter value which has been url encoded
-    private static final Pattern REGEX_PASSWORD_QUERYSTRING = Pattern.compile("(&|%26)?[^(&|%26)]*((p|P)assword|accesskey|secretkey)(=|%3D).*?(?=(%26|[&'\"]))");
-
-    private static final Pattern REGEX_END_PASSWORD_QUERYSTRING = Pattern.compile("(&|%26)[^(&|%26)]*((p|P)assword|accesskey|secretkey)(=|%3D).*");
+    private static final Pattern REGEX_PASSWORD_QUERYSTRING = Pattern.compile("(&|%26)?[^(&|%26)]*((p|P)assword|accesskey|secretkey)(=|%3D).*?(?=(%26|[&'\"]|$))");
 
     // removes a password/accesskey/ property from a response json object
     private static final Pattern REGEX_PASSWORD_JSON = Pattern.compile("\"((p|P)assword|accesskey|secretkey)\":\\s?\".*?\",?");
@@ -177,7 +175,6 @@ public class StringUtils {
         String cleanResult = "";
         if (stringToClean != null) {
             cleanResult = REGEX_PASSWORD_QUERYSTRING.matcher(stringToClean).replaceAll("");
-            cleanResult = REGEX_END_PASSWORD_QUERYSTRING.matcher(cleanResult).replaceAll("");
             cleanResult = REGEX_PASSWORD_JSON.matcher(cleanResult).replaceAll("");
             Matcher detailsMatcher = REGEX_PASSWORD_DETAILS.matcher(cleanResult);
             while (detailsMatcher.find()) {


[3/3] git commit: updated refs/heads/master to 4eeae5a

Posted by de...@apache.org.
CLOUDSTACK-7610,CLOUDSTACK-7611,CLOUDSTACK-7612: Fixed following bugs in AlertsSyslogAppender 1. Added sync alert. 2. Changed unrecognised alerts are send as unknown instead of null. 3. Added unit tests to cover some more scenarios.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4eeae5ad
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4eeae5ad
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4eeae5ad

Branch: refs/heads/master
Commit: 4eeae5ad51ce8d35701509cde9b99cee4ecaccc7
Parents: 7972f53
Author: Anshul Gangwar <an...@citrix.com>
Authored: Tue Sep 23 14:50:59 2014 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Sep 26 14:02:50 2014 +0530

----------------------------------------------------------------------
 .../cloudstack/syslog/AlertsSyslogAppender.java | 10 ++++---
 .../syslog/AlertsSyslogAppenderTest.java        | 30 ++++++++++++++++++--
 2 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4eeae5ad/plugins/alert-handlers/syslog-alerts/src/org/apache/cloudstack/syslog/AlertsSyslogAppender.java
----------------------------------------------------------------------
diff --git a/plugins/alert-handlers/syslog-alerts/src/org/apache/cloudstack/syslog/AlertsSyslogAppender.java b/plugins/alert-handlers/syslog-alerts/src/org/apache/cloudstack/syslog/AlertsSyslogAppender.java
index 5f6e8ec..7324c20 100644
--- a/plugins/alert-handlers/syslog-alerts/src/org/apache/cloudstack/syslog/AlertsSyslogAppender.java
+++ b/plugins/alert-handlers/syslog-alerts/src/org/apache/cloudstack/syslog/AlertsSyslogAppender.java
@@ -49,7 +49,7 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
     public static final int LENGTH_OF_STRING_MESSAGE = 8;
     public static final String MESSAGE_DELIMITER_STRING = "   ";
     //add the alertType in this array it its level needs to be set to critical
-    private static final int[] criticalAlerts = {7, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20};
+    private static final int[] criticalAlerts = {7, 8, 9, 10, 11, 12, 13, 15, 16, 19, 20, 27};
     private static final Map<Integer, String> alertsMap;
 
     static {
@@ -81,6 +81,7 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
         aMap.put(24, "unallocatedDirectAttachedPublicIp");
         aMap.put(25, "unallocatedLocalStorage");
         aMap.put(26, "resourceLimitExceeded");
+        aMap.put(27, "sync");
 
         alertsMap = Collections.unmodifiableMap(aMap);
     }
@@ -230,7 +231,8 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
         }
 
         if (alertType >= 0) {
-            message.append("alertType").append(_keyValueDelimiter).append(" ").append(alertsMap.get(alertType)).append(MESSAGE_DELIMITER_STRING);
+            message.append("alertType").append(_keyValueDelimiter).append(" ").append(alertsMap.containsKey(alertType) ? alertsMap.get(alertType) : "unknown")
+                    .append(MESSAGE_DELIMITER_STRING);
             if (dataCenterId != 0) {
                 message.append("dataCenterId").append(_keyValueDelimiter).append(" ").append(dataCenterId).append(MESSAGE_DELIMITER_STRING);
             }
@@ -246,10 +248,10 @@ public class AlertsSyslogAppender extends AppenderSkeleton {
             if (sysMessage != null) {
                 message.append("message").append(_keyValueDelimiter).append(" ").append(sysMessage);
             } else {
-                errorHandler.error(" What is the use of alert without message ");
+                errorHandler.error("What is the use of alert without message ");
             }
         } else {
-            errorHandler.error(" Invalid alert Type ");
+            errorHandler.error("Invalid alert Type ");
         }
 
         return message.toString();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4eeae5ad/plugins/alert-handlers/syslog-alerts/test/org/apache/cloudstack/syslog/AlertsSyslogAppenderTest.java
----------------------------------------------------------------------
diff --git a/plugins/alert-handlers/syslog-alerts/test/org/apache/cloudstack/syslog/AlertsSyslogAppenderTest.java b/plugins/alert-handlers/syslog-alerts/test/org/apache/cloudstack/syslog/AlertsSyslogAppenderTest.java
index 5799348..7b7dbe0 100644
--- a/plugins/alert-handlers/syslog-alerts/test/org/apache/cloudstack/syslog/AlertsSyslogAppenderTest.java
+++ b/plugins/alert-handlers/syslog-alerts/test/org/apache/cloudstack/syslog/AlertsSyslogAppenderTest.java
@@ -17,8 +17,8 @@
 
 package org.apache.cloudstack.syslog;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import javax.naming.ConfigurationException;
 
@@ -42,6 +42,12 @@ public class AlertsSyslogAppenderTest {
     }
 
     @Test
+    public void setSyslogAppendersWithPortTest() {
+        _appender.setSyslogHosts("10.1.1.1:897,10.1.1.2");
+        assertEquals(" error Syslog Appenders list size not as expected ", 2, _appender._syslogAppenders.size());
+    }
+
+    @Test
     public void setSyslogAppendersNegativeTest() {
         //setting invalid IP for Syslog Hosts
         _appender.setSyslogHosts("10.1.1.");
@@ -57,4 +63,24 @@ public class AlertsSyslogAppenderTest {
             createdMessage.contains("alertType:: managementNode" + AlertsSyslogAppender.MESSAGE_DELIMITER_STRING + "message:: Management server node 127.0.0.1 is up"));
         assertTrue("severity level not as expected ", createdMessage.contains("WARN"));
     }
+
+    @Test
+    public void appendUnknownTest() {
+        String message = "alertType:: 40 // dataCenterId:: 0 // podId:: 0 // clusterId:: null // message:: Management" + " server node 127.0.0.1 is up";
+        _appender.parseMessage(message);
+        String createdMessage = _appender.createSyslogMessage();
+        assertTrue(" message is not as expected ",
+                createdMessage.contains("alertType:: unknown" + AlertsSyslogAppender.MESSAGE_DELIMITER_STRING + "message:: Management server node 127.0.0.1 is up"));
+        assertTrue("severity level not as expected ", createdMessage.contains("WARN"));
+    }
+
+    @Test
+    public void appendFirstAlertTest() {
+        String message = "alertType:: 0 // dataCenterId:: 0 // podId:: 0 // clusterId:: null // message:: Management" + " server node 127.0.0.1 is up";
+        _appender.parseMessage(message);
+        String createdMessage = _appender.createSyslogMessage();
+        assertTrue(" message is not as expected ",
+                createdMessage.contains("alertType:: availableMemory" + AlertsSyslogAppender.MESSAGE_DELIMITER_STRING + "message:: Management server node 127.0.0.1 is up"));
+        assertTrue("severity level not as expected ", createdMessage.contains("WARN"));
+    }
 }
\ No newline at end of file