Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gNMI Provider does not preserve original strings #940

Closed
dasomeom opened this issue Jul 18, 2019 · 1 comment
Closed

gNMI Provider does not preserve original strings #940

dasomeom opened this issue Jul 18, 2019 · 1 comment

Comments

@dasomeom
Copy link

Expected Behavior

All characters in a string leaf should encode properly in (including new lines.)

    banner.banner_text = ";\n" \
                         "----------------------\n" \
                         " EXEC process created\n" \
                         "----------------------\n" \
                         ";\n"

should result in

banner exec ;
----------------------
 EXEC process created
----------------------
;

Current Behavior

new lines are not encoded correctly

val {
    json_ietf_val: "{\"banner\":[{\"banner-name\":\"motd\",\"banner-text\":\";\\u0001--------------------\\u0016 Message of the day\\u002A--------------------\\u003F;\\u0041\"}]}"
  }
banner exec ;^A----------------------^X EXEC process created.----------------------E;G

Steps to Reproduce

Your Script

./gn-create-xr-infra-infra-cfg-20-ydk.py http://xxxx:xxxx@xxxx:xxxxx -v
2019-07-18 09:42:05,230 - ydk - INFO - gNMIServiceProvider Connected to 172.27.150.154 via Insecure Channel
2019-07-18 09:42:05,231 - ydk - INFO - Executing CRUD create operation on [Cisco-IOS-XR-infra-infra-cfg:banners]
2019-07-18 09:42:05,231 - ydk - INFO - Executing set gRPC operation 'update' on entity 'Cisco-IOS-XR-infra-infra-cfg:banners'
2019-07-18 09:42:05,234 - ydk - INFO - 
=============== Set Request Sent ================
update {
  path {
    origin: "Cisco-IOS-XR-infra-infra-cfg"
    elem {
      name: "banners"
    }
  }
  val {
    json_ietf_val: "{\"banner\":[{\"banner-name\":\"exec\",\"banner-text\":\";\\u0001----------------------\\u0018 EXEC process created\\u002E----------------------\\u0045;\\u0047\"}]}"
  }
}


2019-07-18 09:42:06,627 - ydk - INFO - 
============= Set Response Received =============
response {
  path {
    origin: "Cisco-IOS-XR-infra-infra-cfg"
    elem {
      name: "banners"
    }
  }
  message {
  }
  op: UPDATE
}
message {
}
timestamp: 1563439491166759952


2019-07-18 09:42:06,627 - ydk - INFO - Set Operation Succeeded
2019-07-18 09:42:06,628 - ydk - INFO - Operation succeeded
2019-07-18 09:42:06,628 - ydk - INFO - Disconnected from device

Logs

Enable logging and post the logs below

System Information

Python 2.7, Mac

@ygorelik
Copy link
Collaborator

After libyang code fix (printer_json.c):

ygorelik@ygorelik-ThinkStation-P520:~/scripts/issues$ ./test_940.py -v ssh://admin:[email protected]:57400
2019-08-26 05:58:37,327 - ydk - INFO - gNMIServiceProvider Connected to 10.30.110.85 via Insecure Channel
2019-08-26 05:58:37,328 - ydk - INFO - Executing CRUD create operation on [Cisco-IOS-XR-infra-infra-cfg:banners]
2019-08-26 05:58:37,328 - ydk - INFO - Executing set gRPC operation 'update' on entity 'Cisco-IOS-XR-infra-infra-cfg:banners'
2019-08-26 05:58:37,330 - ydk - INFO - 
=============== Set Request Sent ================
update {
  path {
    origin: "Cisco-IOS-XR-infra-infra-cfg"
    elem {
      name: "banners"
    }
  }
  val {
    json_ietf_val: "{\"banner\":[{\"banner-name\":\"motd\",\"banner-text\":\";\\u000A------------------------------------------\\u000A Message for login authentication timeout \\u000A------------------------------------------\\u000A;\\u000A\"}]}"
  }
}


2019-08-26 05:58:39,062 - ydk - INFO - 
============= Set Response Received =============
response {
  path {
    origin: "Cisco-IOS-XR-infra-infra-cfg"
    elem {
      name: "banners"
    }
  }
  message {
  }
  op: UPDATE
}
message {
}
timestamp: 1566848184474524245


2019-08-26 05:58:39,063 - ydk - INFO - Set Operation Succeeded
2019-08-26 05:58:39,063 - ydk - INFO - Operation succeeded
2019-08-26 05:58:39,064 - ydk - INFO - Executing CRUD read operation on [Cisco-IOS-XR-infra-infra-cfg:banners]
2019-08-26 05:58:39,064 - ydk - INFO - 
=============== Get Request Sent ================
path {
  origin: "Cisco-IOS-XR-infra-infra-cfg"
  elem {
    name: "banners"
  }
}
encoding: JSON_IETF


2019-08-26 05:58:39,104 - ydk - INFO - 
============= Get Response Received =============
notification {
  timestamp: 1566848184517650082
  update {
    path {
      origin: "Cisco-IOS-XR-infra-infra-cfg"
      elem {
        name: "banners"
      }
    }
    val {
      json_ietf_val: "{\"banner\":[{\"banner-name\":\"motd\",\"banner-text\":\";\\n------------------------------------------\\n Message for login authentication timeout \\n------------------------------------------\\n;\\n\"}]}"
    }
  }
}
error {
}


2019-08-26 05:58:39,104 - ydk - INFO - Get Operation Succeeded
(<ydk_.types.YLeaf object at 0x7fb0d9b2a0d8>, ';\n------------------------------------------\n Message for login authentication timeout \n------------------------------------------\n;\n')
2019-08-26 05:58:39,106 - ydk - INFO - Disconnected from device
ygorelik@ygorelik-ThinkStation-P520:~/scripts/issues$ ssh [email protected]

------------------------------------------
 Message for login authentication timeout 
------------------------------------------


Password: 


RP/0/RP0/CPU0:carreras#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants