cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [34/50] [abbrv] git commit: updated refs/heads/planner_reserve to 9b86516
Date Sun, 05 May 2013 07:59:59 GMT
CLOUDSTACK-2146: system vm scaleup failed ;{ "scalevirtualmachineresponse" : {"errorcode":530,"cserrorcode":9999,"errortext":"Failed
to scale vm"} }

Only response generation for system vm scale up failed so fixed by changing the response object.

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>


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

Branch: refs/heads/planner_reserve
Commit: 38b4f84f1749f86ac058b25d86995fe54bc7fde6
Parents: 64fb826
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Fri May 3 14:52:45 2013 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Fri May 3 16:49:08 2013 +0530

----------------------------------------------------------------------
 api/src/com/cloud/vm/UserVmService.java            |    2 +-
 .../cloudstack/api/command/user/vm/ScaleVMCmd.java |   10 ++--
 .../api/command/test/ScaleVMCmdTest.java           |   35 +++------------
 server/src/com/cloud/vm/UserVmManagerImpl.java     |   10 ++---
 .../test/com/cloud/vm/MockUserVmManagerImpl.java   |    4 +-
 5 files changed, 19 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index c8ccb67..fa89521 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -451,6 +451,6 @@ public interface UserVmService {
 
     UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
 
-    UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException,
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
+    boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException,
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
index 4fc65c3..4f2ac75 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
@@ -22,11 +22,12 @@ import com.cloud.user.UserContext;
 import com.cloud.uservm.UserVm;
 import org.apache.cloudstack.api.*;
 import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.log4j.Logger;
 
 
-@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new
service offering.", responseObject=UserVmResponse.class)
+@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new
service offering.", responseObject=SuccessResponse.class)
 public class ScaleVMCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());
     private static final String s_name = "scalevirtualmachineresponse";
@@ -83,7 +84,7 @@ public class ScaleVMCmd extends BaseCmd {
     @Override
     public void execute(){
         //UserContext.current().setEventDetails("Vm Id: "+getId());
-        UserVm result = null;
+        boolean result;
         try {
             result = _userVmService.upgradeVirtualMachine(this);
         } catch (ResourceUnavailableException ex) {
@@ -99,9 +100,8 @@ public class ScaleVMCmd extends BaseCmd {
             s_logger.warn("Exception: ", ex);
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
         }
-        if (result != null){
-            UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine",
result).get(0);
-            response.setResponseName(getCommandName());
+        if (result){
+            SuccessResponse response = new SuccessResponse(getCommandName());
             this.setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
index 301fa02..8a28290 100644
--- a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
+++ b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
@@ -16,31 +16,20 @@
 // under the License.
 package org.apache.cloudstack.api.command.test;
 
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
 import com.cloud.uservm.UserVm;
 import com.cloud.vm.UserVmService;
 import junit.framework.Assert;
 import junit.framework.TestCase;
 import org.apache.cloudstack.api.ResponseGenerator;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
 import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
-import org.apache.cloudstack.api.response.RegionResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.region.Region;
-import org.apache.cloudstack.region.RegionService;
+
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.Mockito;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-
 public class ScaleVMCmdTest extends TestCase{
 
     private ScaleVMCmd scaleVMCmd;
@@ -57,12 +46,11 @@ public class ScaleVMCmdTest extends TestCase{
             public Long getId() {
                 return 2L;
             }
+            @Override
+            public String getCommandName() {
+                return "scalevirtualmachineresponse";
+            }
         };
-
-       //Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
-       //UserContext.registerContext(1, account, null, true);
-
-
     }
 
 
@@ -71,11 +59,10 @@ public class ScaleVMCmdTest extends TestCase{
 
         UserVmService userVmService = Mockito.mock(UserVmService.class);
 
-        UserVm uservm = Mockito.mock(UserVm.class);
         try {
             Mockito.when(
                     userVmService.upgradeVirtualMachine(scaleVMCmd))
-                    .thenReturn(uservm);
+                    .thenReturn(true);
         }catch (Exception e){
             Assert.fail("Received exception when success expected " +e.getMessage());
         }
@@ -83,13 +70,6 @@ public class ScaleVMCmdTest extends TestCase{
         scaleVMCmd._userVmService = userVmService;
         responseGenerator = Mockito.mock(ResponseGenerator.class);
 
-        UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class);
-        List<UserVmResponse> responseList = new ArrayList<UserVmResponse>();
-        responseList.add(userVmResponse);
-
-        Mockito.when(responseGenerator.createUserVmResponse("virtualmachine",uservm))
-                .thenReturn(responseList);
-
         scaleVMCmd._responseGenerator = responseGenerator;
         scaleVMCmd.execute();
 
@@ -101,10 +81,9 @@ public class ScaleVMCmdTest extends TestCase{
         UserVmService userVmService = Mockito.mock(UserVmService.class);
 
         try {
-            UserVm uservm = Mockito.mock(UserVm.class);
             Mockito.when(
                     userVmService.upgradeVirtualMachine(scaleVMCmd))
-                    .thenReturn(null);
+                    .thenReturn(false);
         }catch (Exception e){
             Assert.fail("Received exception when success expected " +e.getMessage());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 6179948..bc25bed 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1050,7 +1050,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VM_SCALE, eventDescription = "scaling Vm")
-    public UserVm
+    public boolean
     upgradeVirtualMachine(ScaleVMCmd cmd) throws InvalidParameterValueException {
         Long vmId = cmd.getId();
         Long newServiceOfferingId = cmd.getServiceOfferingId();
@@ -1076,8 +1076,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
         }
 
         // Dynamically upgrade the running vms
+        boolean success = false;
         if(vmInstance.getState().equals(State.Running)){
-            boolean success = false;
             int retry = _scaleRetry;
             while (retry-- != 0) { // It's != so that it can match -1.
                 try{
@@ -1095,7 +1095,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                     vmInstance = _vmInstanceDao.findById(vmId);
                     vmInstance = _itMgr.reConfigureVm(vmInstance, oldServiceOffering, existingHostHasCapacity);
                     success = true;
-                    return _vmDao.findById(vmInstance.getId());
+                    return success;
                 }catch(InsufficientCapacityException e ){
                     s_logger.warn("Received exception while scaling ",e);
                 } catch (ResourceUnavailableException e) {
@@ -1112,11 +1112,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
                     }
                 }
             }
-            if (!success)
-                return null;
         }
 
-        return _vmDao.findById(vmInstance.getId());
+        return success;
 
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/server/test/com/cloud/vm/MockUserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
index 22bbbe8..8b0b1c7 100644
--- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java
+++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
@@ -407,8 +407,8 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager,
     }
 
     @Override
-    public UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException,
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException
{
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+    public boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException,
ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException
{
+        return false;  //To change body of implemented methods use File | Settings | File
Templates.
     }
 
 


Mime
View raw message