Updated Branches:
  refs/heads/marvin-refactor c8a0c1432 -> 799538c26

CLOUDSTACK-989: marvin.jsonHelper deserialization results in unfilled attributes

marvin:jsonHelper.py deserializes the entire object into entity.entity field
when 'entity' is present as an attribute in the response and failing to fill in
other attributes in the response class of entity.

Signed-off-by: Prasanna Santhanam <t...@apache.org>


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

Branch: refs/heads/marvin-refactor
Commit: 799538c264af9358be1f38923ece975de83db0de
Parents: c8a0c14
Author: Prasanna Santhanam <t...@apache.org>
Authored: Tue Mar 19 18:15:01 2013 +0530
Committer: Prasanna Santhanam <t...@apache.org>
Committed: Tue Mar 19 18:15:01 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/jsonHelper.py |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/799538c2/tools/marvin/marvin/jsonHelper.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/jsonHelper.py 
b/tools/marvin/marvin/jsonHelper.py
index 652cce0..1c98726 100644
--- a/tools/marvin/marvin/jsonHelper.py
+++ b/tools/marvin/marvin/jsonHelper.py
@@ -89,15 +89,9 @@ def finalizeResultObj(result, responseName, responsecls):
             pass
     
     if responseName is not None and responseName == 
"queryasyncjobresultresponse" and responsecls is not None and result.jobresult 
is not None:
-        result.jobresult = finalizeResultObj(result.jobresult, None, 
responsecls)
-        return result
+        return finalizeResultObj(result.jobresult, None, responsecls)
     elif responsecls is not None:
-        for k,v in result.__dict__.iteritems():
-            if k in responsecls.__dict__:
-                return result
-        
         attr = result.__dict__.keys()[0]
-       
         value = getattr(result, attr)
         if not isinstance(value, jsonLoader):
             return result
@@ -146,7 +140,7 @@ if __name__ == "__main__":
     result = '{ "listnetworkserviceprovidersresponse" : { "count":1 
,"networkserviceprovider" : [ 
{"name":"VirtualRouter","physicalnetworkid":"ad2948fc-1054-46c7-b1c7-61d990b86710","destinationphysicalnetworkid":"0","state":"Disabled","id":"d827cae4-4998-4037-95a2-55b92b6318b1","servicelist":["Vpn","Dhcp","Dns","Gateway","Firewall","Lb","SourceNat","StaticNat","PortForwarding","UserData"]}
 ] } }'
     nsp = getResultObj(result)
     print nsp[0].id
-    
+
     result = '{ "listzonesresponse" : { "count":1 ,"zone" : [  
{"id":1,"name":"test0","dns1":"8.8.8.8","dns2":"4.4.4.4","internaldns1":"192.168.110.254","internaldns2":"192.168.110.253","networktype":"Basic","securitygroupsenabled":true,"allocationstate":"Enabled","zonetoken":"5e818a11-6b00-3429-9a07-e27511d3169a","dhcpprovider":"DhcpServer"}
 ] } }'
     zones = getResultObj(result)
     print zones[0].id
@@ -155,42 +149,42 @@ if __name__ == "__main__":
     asynJob = getResultObj(result, res)
     print asynJob.jobid, repr(asynJob.jobresult)
     print asynJob.jobresult.ingressrule[0].account
-    
+
     result = '{ "queryasyncjobresultresponse" : {"errorcode" : 431, 
"errortext" : "Unable to execute API command queryasyncjobresultresponse due to 
missing parameter jobid"}  }'
     try:
         asynJob = getResultObj(result)
     except cloudstackException.cloudstackAPIException, e:
         print e
-    
+
     result = '{ "queryasyncjobresultresponse" : {}  }'
     asynJob = getResultObj(result)
     print asynJob
-    
+
     result = '{}'
     asynJob = getResultObj(result)
     print asynJob
-    
+
     result = '{ "createzoneresponse" :  { "zone" : 
{"id":1,"name":"test0","dns1":"8.8.8.8","dns2":"4.4.4.4","internaldns1":"192.168.110.254","internaldns2":"192.168.110.253","networktype":"Basic","securitygroupsenabled":true,"allocationstate":"Enabled","zonetoken":"3442f287-e932-3111-960b-514d1f9c4610","dhcpprovider":"DhcpServer"}
 }  }'
     res = createZone.createZoneResponse()
     zone = getResultObj(result, res)
     print zone.id
-    
+
     result = '{ "attachvolumeresponse" : {"jobid":24} }'
     res = attachVolume.attachVolumeResponse()
     res = getResultObj(result, res)
     print res
-    
+
     result = '{ "listtemplatesresponse" : { } }'
     print getResultObj(result, listTemplates.listTemplatesResponse())
-    
+
     result = '{ "queryasyncjobresultresponse" : 
{"jobid":34,"jobstatus":2,"jobprocstatus":0,"jobresultcode":530,"jobresulttype":"object","jobresult":{"errorcode":431,"errortext":"Please
 provide either a volume id, or a tuple(device id, instance id)"}} }'
     print getResultObj(result, listTemplates.listTemplatesResponse())
     result = '{ "queryasyncjobresultresponse" : 
{"jobid":41,"jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"virtualmachine":{"id":37,"name":"i-2-37-TEST","displayname":"i-2-37-TEST","account":"admin","domainid":1,"domain":"ROOT","created":"2011-08-25T11:13:42-0700","state":"Running","haenable":false,"zoneid":1,"zonename":"test0","hostid":5,"hostname":"SimulatedAgent.1e629060-f547-40dd-b792-57cdc4b7d611","templateid":10,"templatename":"CentOS
 5.3(64-bit) no GUI (Simulator)","templatedisplaytext":"CentOS 5.3(64-bit) no 
GUI 
(Simulator)","passwordenabled":false,"serviceofferingid":7,"serviceofferingname":"Small
 
Instance","cpunumber":1,"cpuspeed":500,"memory":512,"guestosid":11,"rootdeviceid":0,"rootdevicetype":"NetworkFilesystem","securitygroup":[{"id":1,"name":"default","description":"Default
 Security 
Group"}],"nic":[{"id":43,"networkid":204,"netmask":"255.255.255.0","gateway":"192.168.1.1","ipaddress":"192.168.1.27","isolationuri":"ec2://untagg
 
ed","broadcasturi":"vlan://untagged","traffictype":"Guest","type":"Direct","isdefault":true,"macaddress":"06:56:b8:00:00:53"}],"hypervisor":"Simulator"}}}
 }'
-    
+
     result='{ "queryasyncjobresultresponse" : 
{"accountid":"30910093-22e4-4d3c-a464-8b36b60c8001","userid":"cb0aeca3-42ee-47c4-838a-2cd9053441f2","cmd":"com.cloud.api.commands.DeployVMCmd","jobstatus":1,"jobprocstatus":0,"jobresultcode":0,"jobresulttype":"object","jobresult":{"virtualmachine":{"id":"d2e4d724-e089-4e59-be8e-647674059016","name":"i-2-14-TEST","displayname":"i-2-14-TEST","account":"admin","domainid":"8cfafe79-81eb-445e-8608-c5b7c31fc3a5","domain":"ROOT","created":"2012-01-15T18:30:11+0530","state":"Running","haenable":false,"zoneid":"30a397e2-1c85-40c0-8463-70278952b046","zonename":"Sandbox-simulator","hostid":"cc0105aa-a2a9-427a-8ad7-4d835483b8a9","hostname":"SimulatedAgent.9fee20cc-95ca-48b1-8268-5513d6e83a1b","templateid":"d92570fa-bf40-44db-9dff-45cc7042604d","templatename":"CentOS
 5.3(64-bit) no GUI (Simulator)","templatedisplaytext":"CentOS 5.3(64-bit) no 
GUI 
(Simulator)","passwordenabled":false,"serviceofferingid":"3734d632-797b-4f1d-ac62-33f9cf70d005","serviceo
 fferingname":"Sample 
SO","cpunumber":1,"cpuspeed":100,"memory":128,"guestosid":"1e36f523-23e5-4e90-869b-a1b5e9ba674d","rootdeviceid":0,"rootdevicetype":"NetworkFilesystem","nic":[{"id":"4d3ab903-f511-4dab-8a6d-c2a3b51de7e0","networkid":"faeb7f24-a4b9-447d-bec6-c4956c4ab0f6","netmask":"255.255.240.0","gateway":"10.6.240.1","ipaddress":"10.6.253.89","isolationuri":"vlan://211","broadcasturi":"vlan://211","traffictype":"Guest","type":"Isolated","isdefault":true,"macaddress":"02:00:04:74:00:09"}],"hypervisor":"Simulator"}},"created":"2012-01-15T18:30:11+0530","jobid":"f4a13f28-fcd6-4d7f-b9cd-ba7eb5a5701f"}
 }'
     vm = getResultObj(result, 
deployVirtualMachine.deployVirtualMachineResponse())
     print vm.jobresult.id
-    
+
     cmd = deployVirtualMachine.deployVirtualMachineCmd()
     responsename = cmd.__class__.__name__.replace("Cmd", "Response")
     response = getclassFromName(cmd, responsename)

Reply via email to