You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/17 06:09:15 UTC

[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #5453: Updated the event message with proper json format for cmd info and job result

sureshanaparti commented on a change in pull request #5453:
URL: https://github.com/apache/cloudstack/pull/5453#discussion_r710777097



##########
File path: server/src/main/java/com/cloud/api/ApiServer.java
##########
@@ -347,9 +355,9 @@ public void handleAsyncJobPublishEvent(String subject, String senderAddress, Obj
         eventDescription.put("instanceType", instanceType);
         eventDescription.put("commandEventType", cmdEventType);
         eventDescription.put("jobId", job.getUuid());
-        eventDescription.put("jobResult", job.getResult());
-        eventDescription.put("cmdInfo", job.getCmdInfo());
-        eventDescription.put("status", "" + job.getStatus() );
+        eventDescription.put("jobResult", ApiSerializerHelper.fromSerializedStringToMap(job.getResult()));

Review comment:
       > @sureshanaparti could this possibly break someone's scripts?
   
   Yes, would break if they made any custom changes in their scripts to parse/extract info from _jobResult_ string. Now, as it is in proper Json format, they can simply update the script to parse the Json for extracting info.
   
   **Old way jobResult:**
   
   `"jobResult":"org.apache.cloudstack.api.response.UserVmResponse/virtualmachine/{\"id\":\"9e6243ff-6335-403a-b90c-74d8afe1d85a\",\"name\":\"vm02\",\"displayname\":\"vm02\",\"account\":\"admin\",\"userid\":\"ba81a9e1-112c-11ec-b002-1e003300048c\",\"username\":\"admin\",\"domainid\":\"a18fbc93-112c-11ec-b002-1e003300048c\",\"domain\":\"ROOT\",\"created\":\"2021-09-10T05:19:14+0000\",\"lastupdated\":\"2021-09-15T06:01:38+0000\",\"state\":\"Stopped\",\"haenable\":false,\"zoneid\":\"be8e7d3e-2f57-433d-9c93-208949e2ec1d\",\"zonename\":\"ref-trl-1773-k-M7-suresh-anaparti\",\"templateid\":\"a193173b-112c-11ec-b002-1e003300048c\",\"templatename\":\"CentOS 5.5(64-bit) no GUI (KVM)\",\"templatedisplaytext\":\"CentOS 5.5(64-bit) no GUI (KVM)\",\"passwordenabled\":false,\"serviceofferingid\":\"a2a3d572-9975-4930-87f9-ea507791b7d1\",\"serviceofferingname\":\"Small Instance\",\"cpunumber\":1,\"cpuspeed\":500,\"memory\":512,\"cpuused\":\"14.24%\",\"networkkbsread\":0,\"networkkbswrite\":0,\"diskkb
 sread\":0,\"diskkbswrite\":472,\"memorykbs\":524288,\"memoryintfreekbs\":0,\"memorytargetkbs\":524288,\"diskioread\":0,\"diskiowrite\":80,\"guestosid\":\"a1aa4d8c-112c-11ec-b002-1e003300048c\",\"rootdeviceid\":0,\"rootdevicetype\":\"ROOT\",\"securitygroup\":[],\"nic\":[{\"id\":\"c1b10d72-4ae6-41b7-a37f-cdaee72cd832\",\"networkid\":\"4ea42dd5-b867-43fb-9245-74c9bd2be4e0\",\"networkname\":\"nw01\",\"netmask\":\"255.255.255.0\",\"gateway\":\"10.1.1.1\",\"ipaddress\":\"10.1.1.177\",\"traffictype\":\"Guest\",\"type\":\"Isolated\",\"isdefault\":true,\"macaddress\":\"02:00:22:aa:00:03\",\"secondaryip\":[],\"extradhcpoption\":[],\"deviceid\":\"0\"}],\"hypervisor\":\"KVM\",\"instancename\":\"i-2-5-VM\",\"details\":{\"memoryOvercommitRatio\":\"1.0\",\"Message.ReservedCapacityFreed.Flag\":\"false\",\"cpuOvercommitRatio\":\"2.0\"},\"affinitygroup\":[],\"displayvm\":true,\"isdynamicallyscalable\":false,\"ostypeid\":\"a1aa4d8c-112c-11ec-b002-1e003300048c\",\"osdisplayname\":\"CentOS 5.5 (64-bit)\
 ",\"pooltype\":\"NetworkFilesystem\",\"receivedbytes\":0,\"sentbytes\":0,\"tags\":[],\"hasannotations\":false,\"jobid\":\"2b6c7a2f-8b72-4906-aa45-749b4bc47f0d\",\"jobstatus\":0}"`
   
   **New way jobResult:**
   
   `"jobResult":{"class":"org.apache.cloudstack.api.response.UserVmResponse","object":"virtualmachine","id":"9e6243ff-6335-403a-b90c-74d8afe1d85a","name":"vm02","displayname":"vm02","account":"admin","userid":"ba81a9e1-112c-11ec-b002-1e003300048c","username":"admin","domainid":"a18fbc93-112c-11ec-b002-1e003300048c","domain":"ROOT","created":"2021-09-10T05:19:14+0000","lastupdated":"2021-09-15T06:01:38+0000","state":"Stopped","haenable":false,"zoneid":"be8e7d3e-2f57-433d-9c93-208949e2ec1d","zonename":"ref-trl-1773-k-M7-suresh-anaparti","templateid":"a193173b-112c-11ec-b002-1e003300048c","templatename":"CentOS 5.5(64-bit) no GUI (KVM)","templatedisplaytext":"CentOS 5.5(64-bit) no GUI (KVM)","passwordenabled":false,"serviceofferingid":"a2a3d572-9975-4930-87f9-ea507791b7d1","serviceofferingname":"Small Instance","cpunumber":1,"cpuspeed":500,"memory":512,"cpuused":"14.24%","networkkbsread":0,"networkkbswrite":0,"diskkbsread":0,"diskkbswrite":472,"memorykbs":524288,"memoryintfreekbs":0,"me
 morytargetkbs":524288,"diskioread":0,"diskiowrite":80,"guestosid":"a1aa4d8c-112c-11ec-b002-1e003300048c","rootdeviceid":0,"rootdevicetype":"ROOT","securitygroup":[],"nic":[{"id":"c1b10d72-4ae6-41b7-a37f-cdaee72cd832","networkid":"4ea42dd5-b867-43fb-9245-74c9bd2be4e0","networkname":"nw01","netmask":"255.255.255.0","gateway":"10.1.1.1","ipaddress":"10.1.1.177","traffictype":"Guest","type":"Isolated","isdefault":true,"macaddress":"02:00:22:aa:00:03","secondaryip":[],"extradhcpoption":[],"deviceid":"0"}],"hypervisor":"KVM","instancename":"i-2-5-VM","details":{"memoryOvercommitRatio":"1.0","Message.ReservedCapacityFreed.Flag":"false","cpuOvercommitRatio":"2.0"},"affinitygroup":[],"displayvm":true,"isdynamicallyscalable":false,"ostypeid":"a1aa4d8c-112c-11ec-b002-1e003300048c","osdisplayname":"CentOS 5.5 (64-bit)","pooltype":"NetworkFilesystem","receivedbytes":0,"sentbytes":0,"tags":[],"hasannotations":false,"jobid":"2b6c7a2f-8b72-4906-aa45-749b4bc47f0d","jobstatus":0}`
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org