You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seen in tests with IOS XR. When gNMISession requests a configuration, which is not present on device, the response has value of empty string. When that is value of a leaf it must be fine, but for container the expected value should be '{}' and for the list '[]'.
Expected Behavior
When configuration is not present on device the YDK should not fail with exception, but rather provide corrected JSON response.
Current Behavior
YDK fails with ValueError exception from json parser, when empty string value is returned for container or list.
Your Script
#!/usr/bin/env python
"""
Create configuration for model Cisco-IOS-XR-infra-infra-cfg.
usage: gn-create-xr-infra-infra-cfg-25-ydk.py [-h] [-v] device
positional arguments:
device gNMI device (http://user:password@host:port)
optional arguments:
-h, --help show this help message and exit
-v, --verbose print debugging messages
"""
import os
import logging
from argparse import ArgumentParser
from urllib.parse import urlparse
from ydk.path import Repository
from ydk.services import CRUDService
from ydk.gnmi.providers import gNMIServiceProvider
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_infra_infra_cfg as xr_infra_infra_cfg
if __name__ == "__main__":
"""Execute main program."""
parser = ArgumentParser()
parser.add_argument("-v", "--verbose", help="print debugging messages",
action="store_true")
parser.add_argument("device",
help="gNMI device (http://user:password@host:port)")
args = parser.parse_args()
device = urlparse(args.device)
# log debug messages if verbose argument specified
if args.verbose:
logger = logging.getLogger("ydk")
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter(("%(asctime)s - %(name)s - "
"%(levelname)s - %(message)s"))
handler.setFormatter(formatter)
logger.addHandler(handler)
# create gNMI provider
user_repo_dir = os.path.expanduser("~/.ydk/")
repository = Repository(user_repo_dir+device.hostname)
provider = gNMIServiceProvider(repo=repository,
address=device.hostname,
port=device.port,
username=device.username,
password=device.password)
# create CRUD service
crud = CRUDService()
# delete configuration on gNMI device
banner_filter = xr_infra_infra_cfg.Banners()
response = crud.delete(provider, banner_filter)
# read configuration on gNMI device
banner_filter = xr_infra_infra_cfg.Banners()
response = crud.read(provider, banner_filter)
Logs
/home/yan/.virtualenvs/ydk81/bin/python /home/yan/ydk-workspace/ydk-gen/scripts/issues/test_940.py -v ssh://admin:admin@10.30.110.84:57400
2019-07-26 14:05:06,148 - ydk - INFO - gNMIServiceProvider Connected to 10.30.110.84 via Insecure Channel
2019-07-26 14:05:06,149 - ydk - INFO - Executing CRUD delete operation on [Cisco-IOS-XR-infra-infra-cfg:banners]
2019-07-26 14:05:06,149 - ydk - INFO - Executing set gRPC operation 'delete' on entity 'Cisco-IOS-XR-infra-infra-cfg:banners'
2019-07-26 14:05:06,153 - ydk - INFO -
=============== Set Request Sent ================
delete {
origin: "Cisco-IOS-XR-infra-infra-cfg"
elem {
name: "banners"
}
}
2019-07-26 14:05:07,674 - ydk - INFO -
============= Set Response Received =============
response {
path {
origin: "Cisco-IOS-XR-infra-infra-cfg"
elem {
name: "banners"
}
}
message {
}
op: DELETE
}
message {
}
timestamp: 1564170337500323260
2019-07-26 14:05:07,674 - ydk - INFO - Set Operation Succeeded
2019-07-26 14:05:07,674 - ydk - INFO - Operation succeeded
2019-07-26 14:05:07,676 - ydk - INFO - Executing CRUD read operation on [Cisco-IOS-XR-infra-infra-cfg:banners]
2019-07-26 14:05:07,676 - ydk - INFO -
=============== Get Request Sent ================
path {
origin: "Cisco-IOS-XR-infra-infra-cfg"
elem {
name: "banners"
}
}
encoding: JSON_IETF
2019-07-26 14:05:07,760 - ydk - INFO -
============= Get Response Received =============
notification {
timestamp: 1564170337590864202
update {
path {
origin: "Cisco-IOS-XR-infra-infra-cfg"
elem {
name: "banners"
}
}
val {
json_ietf_val: ""
}
}
}
error {
}
2019-07-26 14:05:07,760 - ydk - INFO - Get Operation Succeeded
Traceback (most recent call last):
File "/home/yan/ydk-workspace/ydk-gen/scripts/issues/test_940.py", line 107, in <module>
response = crud.read(provider, banner_filter)
File "/home/yan/.virtualenvs/ydk81/lib/python3.5/site-packages/ydk/services/crud_service.py", line 69, in read
read_top_entity = self._crud.read(provider, top_filters)
ValueError: parse error - unexpected '}'
2019-07-26 14:05:07,774 - ydk - INFO - Disconnected from device
Process finished with exit code 1
System Information
YDK-0.8.3
The text was updated successfully, but these errors were encountered:
Seen in tests with IOS XR. When gNMISession requests a configuration, which is not present on device, the response has value of empty string. When that is value of a leaf it must be fine, but for container the expected value should be '{}' and for the list '[]'.
Expected Behavior
When configuration is not present on device the YDK should not fail with exception, but rather provide corrected JSON response.
Current Behavior
YDK fails with ValueError exception from json parser, when empty string value is returned for container or list.
Your Script
Logs
System Information
YDK-0.8.3
The text was updated successfully, but these errors were encountered: