You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/10/27 19:27:35 UTC

[1/7] git commit: updated refs/heads/master to 535ab51

Repository: cloudstack
Updated Branches:
  refs/heads/master fb4e6ed6b -> 535ab51b9


CLOUDSTACK-8816: some of the events do not have resource uuids

the key for an entity is sometimes an object a String with value
object.toString() due to serialization and deserialization of them.
Addressed this in the getter of CallContext to check for key.toString
if an object is not found with key.


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

Branch: refs/heads/master
Commit: 863931a992434a3bd736383882f9cc65a376d63e
Parents: 7d73e9b
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Fri Sep 18 14:53:11 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:31 2015 +0530

----------------------------------------------------------------------
 .../apache/cloudstack/context/CallContext.java  | 13 ++-
 .../cloudstack/context/CallContextTest.java     | 83 ++++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/863931a9/api/src/org/apache/cloudstack/context/CallContext.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java
index 2619f4a..fb83f86 100644
--- a/api/src/org/apache/cloudstack/context/CallContext.java
+++ b/api/src/org/apache/cloudstack/context/CallContext.java
@@ -89,8 +89,19 @@ public class CallContext {
         context.put(key, value);
     }
 
+    /**
+     * @param key any not null key object
+     * @return the value of the key from context map
+     * @throws NullPointerException if the specified key is nul
+     */
     public Object getContextParameter(Object key) {
-        return context.get(key);
+        Object value = context.get(key);
+        //check if the value is present in the toString value of the key
+        //due to a bug in the way we update the key by serializing and deserializing, it sometimes gets toString value of the key. @see com.cloud.api.ApiAsyncJobDispatcher#runJob
+        if(value == null ) {
+            value = context.get(key.toString());
+        }
+        return value;
     }
 
     public long getCallingUserId() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/863931a9/api/test/org/apache/cloudstack/context/CallContextTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/context/CallContextTest.java b/api/test/org/apache/cloudstack/context/CallContextTest.java
new file mode 100644
index 0000000..2b953a0
--- /dev/null
+++ b/api/test/org/apache/cloudstack/context/CallContextTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cloudstack.context;
+
+import java.util.UUID;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.cloud.user.Account;
+import com.cloud.user.User;
+import com.cloud.utils.db.EntityManager;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CallContextTest {
+
+    @Mock
+    EntityManager entityMgr;
+
+    @Before
+    public void setUp() {
+        CallContext.init(entityMgr);
+        CallContext.register(Mockito.mock(User.class), Mockito.mock(Account.class));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        CallContext.unregisterAll();
+    }
+
+    @Test
+    public void testGetContextParameter() {
+        CallContext currentContext = CallContext.current();
+
+        Assert.assertEquals("There is nothing in the context. It should return null", null, currentContext.getContextParameter("key"));
+        Assert.assertTrue("There is nothing in the context. The map should be empty", currentContext.getContextParameters().isEmpty());
+
+        UUID objectUUID = UUID.randomUUID();
+        UUID stringUUID = UUID.randomUUID();
+
+        //Case1: when an entry with the object class is present
+        currentContext.putContextParameter(User.class, objectUUID);
+        Assert.assertEquals("it should return objectUUID: " + objectUUID, objectUUID, currentContext.getContextParameter(User.class));
+        Assert.assertEquals("current context map should have exactly one entry", 1, currentContext.getContextParameters().size());
+
+        //Case2: when an entry with the object class name as String is present
+        currentContext.putContextParameter(Account.class.toString(), stringUUID);
+        //object is put with key as Account.class.toString but get with key as Account.class
+        Assert.assertEquals("it should return stringUUID: " + stringUUID, stringUUID, currentContext.getContextParameter(Account.class));
+        Assert.assertEquals("current context map should have exactly two entries", 2, currentContext.getContextParameters().size());
+
+        //Case3: when an entry with both object class and object class name as String is present
+        //put an entry of account class object in the context
+        currentContext.putContextParameter(Account.class, objectUUID);
+        //since both object and string a present in the current context, it should return object value
+        Assert.assertEquals("it should return objectUUID: " + objectUUID, objectUUID, currentContext.getContextParameter(Account.class));
+        Assert.assertEquals("current context map should have exactly three entries", 3, currentContext.getContextParameters().size());
+    }
+
+}
\ No newline at end of file


[2/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
CLOUDSTACK-8816: fixed missing resource uuid in destroy vm event

*event before*
| management-server.AsyncJobEvent.complete.VirtualMachine.*
| cloudstack-events | 2             |
{"cmdInfo":"{\"response\":\"json\",\"id\":\"ba45d114-9844-4123-8dc6-7ae46d10581a\",\"ctxDetails\":\"{\\\"interface
com.cloud.vm.VirtualMachine\\\":\\\"ba45d114-9844-4123-8dc6-7ae46d10581a\\\"}\",\"cmdEventType\":\"VM.DESTROY\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444812001047\",\"uuid\":\"ba45d114-9844-4123-8dc6-7ae46d10581a\",\"ctxAccountId\":\"2\",\"expunge\":\"true\",\"ctxStartEventId\":\"1395\"}","instanceType":"VirtualMachine","jobId":"b46faa05-7b3a-4dbf-a78d-fbc7c66c3ce3","status":"SUCCEEDED","processStatus":"0","commandEventType":"VM.DESTROY","resultCode":"0","command":"org.apache.cloudstack.api.command.admin.vm.DestroyVMCmdByAdmin","jobResult":"org.apache.cloudstack.api.response.UserVmResponse/null/{\"securitygroup\":[],\"nic\":[],\"tags\":[],\"affinitygroup\":[]}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 894           | string           | True        |

*event after*
|
management-server.AsyncJobEvent.complete.VirtualMachine.22e3bf71-91c8-4b18-a57e-af02d79dbb58
| cloudstack-events | 0             |
{"cmdInfo":"{\"response\":\"json\",\"id\":\"22e3bf71-91c8-4b18-a57e-af02d79dbb58\",\"ctxDetails\":\"{\\\"interface
com.cloud.vm.VirtualMachine\\\":\\\"22e3bf71-91c8-4b18-a57e-af02d79dbb58\\\"}\",\"cmdEventType\":\"VM.DESTROY\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444813240169\",\"uuid\":\"22e3bf71-91c8-4b18-a57e-af02d79dbb58\",\"ctxAccountId\":\"2\",\"expunge\":\"true\",\"ctxStartEventId\":\"1418\"}","instanceType":"VirtualMachine","instanceUuid":"22e3bf71-91c8-4b18-a57e-af02d79dbb58","jobId":"256ca2e7-de05-4b33-b32a-aa8567f05160","status":"SUCCEEDED","processStatus":"0","commandEventType":"VM.DESTROY","resultCode":"0","command":"org.apache.cloudstack.api.command.admin.vm.DestroyVMCmdByAdmin","jobResult":"org.apache.cloudstack.api.response.UserVmResponse/null/{\"securitygroup\":[],\"nic\":[],\"tags\":[],\"affinitygroup\":[]}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 948           | string           | False       |


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

Branch: refs/heads/master
Commit: ec03473c2399bde73b0407916b417c9fb46113c6
Parents: 04554dd
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Wed Oct 14 14:31:05 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:32 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiDBUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec03473c/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 130fa88..c589781 100644
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -778,7 +778,7 @@ public class ApiDBUtils {
     // ///////////////////////////////////////////////////////////
 
     public static VMInstanceVO findVMInstanceById(long vmId) {
-        return s_vmDao.findById(vmId);
+        return s_vmDao.findByIdIncludingRemoved(vmId);
     }
 
     public static long getStorageCapacitybyPool(Long poolId, short capacityType) {


[5/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
CLOUDSTACK-8816: fixed missing resource uuid in delete network cmd

*events before*
| management-server.AsyncJobEvent.submit.None.*
| cloudstack-events | 7             |
{"cmdInfo":"{\"id\":\"edf0a16b-54cd-442e-b644-4af933f34229\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.network.Network\\\":\\\"edf0a16b-54cd-442e-b644-4af933f34229\\\"}\",\"cmdEventType\":\"NETWORK.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444805881664\",\"uuid\":\"edf0a16b-54cd-442e-b644-4af933f34229\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1378\"}","instanceType":"None","jobId":"f7cbf481-49d0-423b-8661-5d3d678f4b96","status":"IN_PROGRESS","processStatus":"0","commandEventType":"NETWORK.DELETE","resultCode":"0","command":"org.apache.cloudstack.api.command.user.network.DeleteNetworkCmd","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 736           | string           | True        | |
management-server.AsyncJobEvent.complete.None.* | cloudstack-events | 6
|
{"cmdInfo":"{\"id\":\"edf0a16b-54cd-442e-b644-4af933f34229\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.network.Network\\\":\\\"edf0a16b-54cd-442e-b644-4af933f34229\\\"}\",\"cmdEventType\":\"NETWORK.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444805881664\",\"uuid\":\"edf0a16b-54cd-442e-b644-4af933f34229\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1378\"}","instanceType":"None","jobId":"f7cbf481-49d0-423b-8661-5d3d678f4b96","status":"FAILED","processStatus":"0","commandEventType":"NETWORK.DELETE","resultCode":"530","command":"org.apache.cloudstack.api.command.user.network.DeleteNetworkCmd","jobResult":"org.apache.cloudstack.api.response.ExceptionResponse/null/{\"uuidList\":[],\"errorcode\":530,\"errortext\":\"Failed
to delete
network\"}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 884           | string           | True        |

*events after*
|
management-server.AsyncJobEvent.submit.Network.5eccaece-a789-4b93-99c2-8b731ab6e328
| cloudstack-events | 1             |
{"cmdInfo":"{\"id\":\"5eccaece-a789-4b93-99c2-8b731ab6e328\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.network.Network\\\":\\\"5eccaece-a789-4b93-99c2-8b731ab6e328\\\"}\",\"cmdEventType\":\"NETWORK.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444814151636\",\"uuid\":\"5eccaece-a789-4b93-99c2-8b731ab6e328\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1424\"}","instanceType":"Network","instanceUuid":"5eccaece-a789-4b93-99c2-8b731ab6e328","jobId":"d2cd4b27-acbd-4e56-867f-fe67ebde8261","status":"IN_PROGRESS","processStatus":"0","commandEventType":"NETWORK.DELETE","resultCode":"0","command":"org.apache.cloudstack.api.command.user.network.DeleteNetworkCmd","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 793           | string           | False       |
|
management-server.AsyncJobEvent.complete.Network.5eccaece-a789-4b93-99c2-8b731ab6e328
| cloudstack-events | 0             |
{"cmdInfo":"{\"id\":\"5eccaece-a789-4b93-99c2-8b731ab6e328\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.network.Network\\\":\\\"5eccaece-a789-4b93-99c2-8b731ab6e328\\\"}\",\"cmdEventType\":\"NETWORK.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444814151636\",\"uuid\":\"5eccaece-a789-4b93-99c2-8b731ab6e328\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1424\"}","instanceType":"Network","instanceUuid":"5eccaece-a789-4b93-99c2-8b731ab6e328","jobId":"d2cd4b27-acbd-4e56-867f-fe67ebde8261","status":"SUCCEEDED","processStatus":"0","commandEventType":"NETWORK.DELETE","resultCode":"0","command":"org.apache.cloudstack.api.command.user.network.DeleteNetworkCmd","jobResult":"org.apache.cloudstack.api.response.SuccessResponse/null/{\"success\":true}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 880           | string           | False       |


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

Branch: refs/heads/master
Commit: 3ff7bf771d1850adbebb62f50cc465ce13604d3a
Parents: ec03473
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Wed Oct 14 14:35:54 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:33 2015 +0530

----------------------------------------------------------------------
 api/src/org/apache/cloudstack/api/ApiCommandJobType.java  |  3 ++-
 .../api/command/user/network/DeleteNetworkCmd.java        | 10 ++++++++++
 server/src/com/cloud/api/ApiDBUtils.java                  |  7 ++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ff7bf77/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
index 227fb30..ead6ce1 100644
--- a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
+++ b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java
@@ -53,5 +53,6 @@ public enum ApiCommandJobType {
     IAMPolicy,
     IAMGroup,
     GuestOs,
-    GuestOsMapping
+    GuestOsMapping,
+    Network
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ff7bf77/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
index 2811434..43b6633 100644
--- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.network;
 
+import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -106,6 +107,15 @@ public class DeleteNetworkCmd extends BaseAsyncCmd {
     }
 
     @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.Network;
+    }
+    @Override
     public long getEntityOwnerId() {
         Network network = _networkService.getNetwork(id);
         if (network == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3ff7bf77/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index c589781..1da62cc 100644
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1217,7 +1217,7 @@ public class ApiDBUtils {
     }
 
     public static NetworkVO findNetworkById(long id) {
-        return s_networkDao.findById(id);
+        return s_networkDao.findByIdIncludingRemoved(id);
     }
 
     public static Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId, long zoneId) {
@@ -1599,6 +1599,11 @@ public class ApiDBUtils {
             if (group != null) {
                 jobInstanceId = group.getUuid();
             }
+        } else if (jobInstanceType == ApiCommandJobType.Network) {
+            NetworkVO networkVO = ApiDBUtils.findNetworkById(job.getInstanceId());
+            if(networkVO != null) {
+                jobInstanceId = networkVO.getUuid();
+            }
         } else if (jobInstanceType != ApiCommandJobType.None) {
             // TODO : when we hit here, we need to add instanceType -> UUID
             // entity table mapping


[6/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
CLOUDSTACK-8816 added missing events

added missing events for createUser, updateUser, createAccount apis.


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

Branch: refs/heads/master
Commit: 2c0af1f86716714590a1709987f4ad0bf3c9566b
Parents: 3ff7bf7
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Wed Oct 21 10:53:33 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:33 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/user/AccountManagerImpl.java | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c0af1f8/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index edc8ad8..8f3a1b2 100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -991,6 +991,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     }
 
     @Override
+    @ActionEvents({
+        @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account"),
+        @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User")
+    })
     public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email, final String timezone,
             String accountName, final short accountType, Long domainId, final String networkDomain, final Map<String, String> details, String accountUUID, final String userUUID) {
 
@@ -1132,6 +1136,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     }
 
     @Override
+    @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User")
     public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId,
         String userUUID) {
 
@@ -1263,6 +1268,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     }
 
     @Override
+    @ActionEvent(eventType = EventTypes.EVENT_USER_UPDATE, eventDescription = "updating User")
     public UserAccount updateUser(UpdateUserCmd cmd) {
         Long id = cmd.getId();
         String apiKey = cmd.getApiKey();


[3/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
CLOUDSTACK-8816: some of the events do not have resource uuids

uuid is missing in the first event of VM create as the entity is just
created and never put in the Context.
Added the entity uuid to context on successful creation.


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

Branch: refs/heads/master
Commit: 242b87dbfbfebef08410725e6a2dd7cfa0d9ae17
Parents: 863931a
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Fri Sep 18 14:56:02 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:32 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/242b87db/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 1e5167e..32b0d3d 100644
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -3247,6 +3247,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
             _affinityGroupVMMapDao.updateMap(vm.getId(), affinityGroupIdList);
         }
 
+        CallContext.current().putContextParameter(VirtualMachine.class, vm.getUuid());
         return vm;
     }
 


[4/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
Cloudstack-8816: Fixed missing resource uuid in delete snapshot events

*event before*

| management-server.AsyncJobEvent.complete.Snapshot.*
| cloudstack-events | 26            |
{"cmdInfo":"{\"id\":\"2ebabd8f-0b34-4461-8071-0917c231ca49\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.storage.Snapshot\\\":\\\"2ebabd8f-0b34-4461-8071-0917c231ca49\\\"}\",\"cmdEventType\":\"SNAPSHOT.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444803845320\",\"uuid\":\"2ebabd8f-0b34-4461-8071-0917c231ca49\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1345\"}","instanceType":"Snapshot","jobId":"fab1feaf-3b4f-4158-b332-a78e43fee5e0","status":"SUCCEEDED","processStatus":"0","commandEventType":"SNAPSHOT.DELETE","resultCode":"0","command":"org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotCmd","jobResult":"org.apache.cloudstack.api.response.SuccessResponse/null/{\"success\":true}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}

*After*

|
management-server.AsyncJobEvent.complete.Snapshot.f25ad748-2fe3-4911-b40c-4698425c8a2f
| cloudstack-events | 0             |
{"cmdInfo":"{\"id\":\"f25ad748-2fe3-4911-b40c-4698425c8a2f\",\"response\":\"json\",\"ctxDetails\":\"{\\\"interface
com.cloud.storage.Snapshot\\\":\\\"f25ad748-2fe3-4911-b40c-4698425c8a2f\\\"}\",\"cmdEventType\":\"SNAPSHOT.DELETE\",\"ctxUserId\":\"2\",\"httpmethod\":\"GET\",\"_\":\"1444806612980\",\"uuid\":\"f25ad748-2fe3-4911-b40c-4698425c8a2f\",\"ctxAccountId\":\"2\",\"ctxStartEventId\":\"1388\"}","instanceType":"Snapshot","instanceUuid":"f25ad748-2fe3-4911-b40c-4698425c8a2f","jobId":"69849909-9082-481c-b8ee-9ddc1608fe8d","status":"SUCCEEDED","processStatus":"0","commandEventType":"SNAPSHOT.DELETE","resultCode":"0","command":"org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotCmd","jobResult":"org.apache.cloudstack.api.response.SuccessResponse/null/{\"success\":true}","account":"bd73dc2e-35c0-11e5-b094-d4ae52cb9af0","user":"bd7ea748-35c0-11e5-b094-d4ae52cb9af0"}
| 886           | string           | True        |


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

Branch: refs/heads/master
Commit: 04554ddd242c4554c8ff47e58cebe00c919f6f32
Parents: 242b87d
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Wed Oct 14 14:28:47 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 26 09:15:32 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiDBUtils.java | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/04554ddd/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 4fc9f42..130fa88 100644
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1033,12 +1033,7 @@ public class ApiDBUtils {
     }
 
     public static Snapshot findSnapshotById(long snapshotId) {
-        SnapshotVO snapshot = s_snapshotDao.findById(snapshotId);
-        if (snapshot != null && snapshot.getRemoved() == null && snapshot.getState() == Snapshot.State.BackedUp) {
-            return snapshot;
-        } else {
-            return null;
-        }
+        return s_snapshotDao.findByIdIncludingRemoved(snapshotId);
     }
 
     public static StoragePoolVO findStoragePoolById(Long storagePoolId) {


[7/7] git commit: updated refs/heads/master to 535ab51

Posted by re...@apache.org.
Merge pull request #849 from karuturi/CLOUDSTACK-8816-take2

Cloudstack-8816 some of the events do not have resource uuidsThe key objects in the context map are sometimes String and sometimes object. This causes missing uuids when an entity put in the context map with key entity.toString is queried with key entity

Testing:
manually tested by deploying a vm and checked that the created events in rabbitmq now has uuids.
events before and after the change are update at https://issues.apache.org/jira/browse/CLOUDSTACK-8816?focusedCommentId=14805239

unittests
```
$ mvn -pl :cloud-api test -Dtest=CallContextTest
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.apache.cloudstack.context.CallContextTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.152 sec - in org.apache.cloudstack.context.CallContextTest

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.445 s
[INFO] Finished at: 2015-09-18T14:58:53+05:30
[INFO] Final Memory: 55M/448M
[INFO] ------------------------------------------------------------------------
```

* pr/849:
  CLOUDSTACK-8816 added missing events
  CLOUDSTACK-8816: fixed missing resource uuid in delete network cmd
  CLOUDSTACK-8816: fixed missing resource uuid in destroy vm event
  Cloudstack-8816: Fixed missing resource uuid in delete snapshot events
  CLOUDSTACK-8816: some of the events do not have resource uuids
  CLOUDSTACK-8816: some of the events do not have resource uuids

Signed-off-by: Remi Bergsma <gi...@remi.nl>


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

Branch: refs/heads/master
Commit: 535ab51b9ad829ed1bd25973b913d4f731440ad5
Parents: fb4e6ed 2c0af1f
Author: Remi Bergsma <gi...@remi.nl>
Authored: Tue Oct 27 19:26:44 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Tue Oct 27 19:26:44 2015 +0100

----------------------------------------------------------------------
 .../cloudstack/api/ApiCommandJobType.java       |  3 +-
 .../command/user/network/DeleteNetworkCmd.java  | 10 +++
 .../apache/cloudstack/context/CallContext.java  | 13 ++-
 .../cloudstack/context/CallContextTest.java     | 83 ++++++++++++++++++++
 server/src/com/cloud/api/ApiDBUtils.java        | 16 ++--
 .../src/com/cloud/user/AccountManagerImpl.java  |  6 ++
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  1 +
 7 files changed, 122 insertions(+), 10 deletions(-)
----------------------------------------------------------------------