Uploaded image for project: 'Common Controller SDK'
  1. Common Controller SDK
  2. CCSDK-2144

Fix parameter convertion for JSON array or object in LCM API payload

XMLWordPrintable

      When the field in payload of LCM API is not a simple string, but an array or object, such as the following swToBeDownloaded field:

      "payload": "{\"ipaddress-v4-oam\": \"192.168.35.90\", \"swToBeDownloaded\": [{\"swLocation\": \"http://192.168.35.96:10080/ran_du_pkg1-v2.zip\"}]}"

       When this payload is transmited to Ansible server, the swToBeDownloaded field will be dumped to:

      [{'swLocation': 'http://192.168.35.96:10080/ran_du_pkg1-v2.zip'}]

       There are some problems:
      1. The backslash and double quotes are missing, so the payload processor can not load it to a JSON array or object;
      2. When it is transmitted to the shell command of Ansible Playbook, it needs single quotes for the spaces, so it needs to backslash and single quotes.

      That means, the correct format should be:

      \'[{\"swLocation\": \"http://192.168.35.96:10080/ran_du_pkg1-v2.zip\"}]\'

      Then:
      1. The backslash and double quotes make the payload processor can load it to a JSON array or object;
      2. The backslash and single quotes at begin and end make the spaces can be transmitted to shell command.

      Before solving this issue, it needs so many backslashes, such as:

      "payload": "{\"ipaddress-v4-oam\": \"192.168.35.90\", \"swToBeDownloaded\": \"\\\\'[{\\\\\\\"swLocation\\\\\\\": \\\\\\\"http://192.168.35.96:10080/ran_du_pkg1-v2.zip\\\\\\\"}]\\\\'\"}"

       After solving this issue, the payload can be:

      "payload": "{\"ipaddress-v4-oam\": \"192.168.35.90\", \"swToBeDownloaded\": [{\"swLocation\": \"http://192.168.35.96:10080/ran_du_pkg1-v2.zip\"}]}"

       

            wangeb wangeb
            wangeb wangeb
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: