Uploaded image for project: 'CloudStack'
  1. CloudStack
  2. CLOUDSTACK-989

marvin: jsonHelper deserialization results in unfilled attributes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0.0
    • Future
    • marvin
    • Security Level: Public (Anyone can view this level - this is the default.)
    • None

    Description

      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.

      For instance when the associateIpAddress is called to acquire ip address in a zone. the response has the following:

      result = '{ "queryasyncjobresultresponse": { "accountid": "2", "userid": "2", "cmd": "com.cloud.api.commands.AssociateIPAddrCmd", "jobstatus": 1, "jobprocstatus": 0, "jobresultcode": 0, "jobresulttype": "object", "jobresult": { "ipaddress":

      { "id": "25065307-673a-4047-9a85-10b520674fb7", "ipaddress": "10.223.137.67", "allocated": "2013-01-02T13:39:33-0800", "zoneid": "b2aeb0e8-7c32-4564-80d6-631e745dd745", "zonename": "zone1", "issourcenat": false, "account": "test-KE15DK", "domainid": "1", "domain": "ROOT", "forvirtualnetwork": true, "vlanid": "953c4b02-bbde-48e1-98c5-20c0888016d5", "vlanname": "1371", "isstaticnat": false, "issystem": false, "associatednetworkid": "1968a6e1-42c3-4d5d-ace4-f692e8d62ba8", "associatednetworkname": "test-KE15DK-network", "networkid": "8366fd1e-5c79-42b8-81fb-031ddafa589d", "state": "Allocating", "physicalnetworkid": "cea412ae-d62c-45d6-903b-81e8b2b926a0", "tags": [] }

      }, "created": "2013-01-02T13:39:33-0800", "jobid": "14f3f4e8-edbe-424f-93f8-5118f4f90939" } }'

      result = getResultObj(result, associateIpAddress.associateIpAddressResponse())
      ipaddr = result.jobresult
      print ipaddr.id
      print ipaddr.ipaddress.id
      print ipaddr.ipaddress.zonename
      print ipaddr.ipaddress.ipaddress
      print ipaddr.ipaddress.zoneid

      >> None
      >> 25065307-673a-4047-9a85-10b520674fb7
      >> zone1
      >> 10.223.137.67
      >> b2aeb0e8-7c32-4564-80d6-631e745dd745

      The response object is as follows:
      class associateIpAddressResponse (baseResponse):
      def _init_(self):
      """public IP address id"""
      self.id = None
      """the account the public IP address is associated with"""
      self.account = None
      """date the public IP address was acquired"""
      self.allocated = None
      """the ID of the Network associated with the IP address"""
      self.associatednetworkid = None
      """the name of the Network associated with the IP address"""
      self.associatednetworkname = None
      """the domain the public IP address is associated with"""
      self.domain = None
      """the domain ID the public IP address is associated with"""
      self.domainid = None
      """the virtual network for the IP address"""
      self.forvirtualnetwork = None
      """public IP address"""
      self.ipaddress = None
      """true if the IP address is a source nat address, false otherwise"""
      self.issourcenat = None
      """true if this ip is for static nat, false otherwise"""
      self.isstaticnat = None
      """true if this ip is system ip (was allocated as a part of deployVm or createLbRule)"""
      self.issystem = None
      """the ID of the Network where ip belongs to"""
      self.networkid = None
      """the physical network this belongs to"""
      self.physicalnetworkid = None
      """the project name of the address"""
      self.project = None
      <snip>

      Because the response contains an attribute by the name 'ipaddress' we fill in the result of the deserialization into that attribute and fail to fill in the rest of the response object.

      This results in confusion when inspecting the response:
      In some places we have:
      account.account.name and in others we have virtualmachine.id

      It is logical and intuitive to not have to make a second indirection from the resulting object that came back as response. The corresponding tests will also need to be corrected.

      Attachments

        Activity

          People

            tsp Prasanna
            tsp Prasanna
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: