Uploaded image for project: 'ONOS'
  1. ONOS
  2. ONOS-2090

Remove need to parse strings in REST JSON output

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 1.0.0, 1.1.0, 1.2.0
    • Fix Version/s: 1.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Not sure if this is a bug or a feature

      When accessing the intent info using the REST API, I get a JSON stream that looks like this.

      http://10.128.103.1:8181/onos/v1/intents/29/14

      {
      "type": "OpticalConnectivityIntent",
      "id": "0xe",
      "appId": "DefaultApplicationId

      {id=29, name=org.onosproject.net.intent}",
      "details": "OpticalConnectivityIntent{id=0xe, key=0xe, appId=DefaultApplicationId{id=29, name=org.onosproject.net.intent}

      , priority=100, resources=[], src=ConnectPoint

      {elementId=fjdwdmtl1:onos9500-1, portNumber=1-3-E1_LPORT}

      , dst=ConnectPoint

      {elementId=fjdwdmtl1:onos9500-2, portNumber=1-3-E1_LPORT}

      , signalType=ODU4, isBidirectional=false}",
      "resources": [],
      "state": "INSTALLED"
      }

      For instance, the value for the appId key, is:
      "appId": "DefaultApplicationId

      {id=29, name=org.onosproject.net.intent}

      "

      To get the actual id, I need to do string pattern matching / parsing.

      Python example:
      p = re.search('id=(\d+),', str(intent))
      app_id = int(p.group(1))

      IMO, this sucks and goes against why we're using JSON.

      The right way to return the appId is:
      "appId" :

      { "type": "DefaultApplicationId", "id": 29, "name": "org.onosproject.net.intent" }

        Attachments

          Activity

            People

            Assignee:
            ray Ray Milkey
            Reporter:
            marc Marc De Leenheer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: