-
Notifications
You must be signed in to change notification settings - Fork 78
AttributeError: 'Config' object has no attribute 'logger' #876
Copy link
Copy link
Closed
Description
Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.
Expected Behavior
Scripts with Config/Filter in CRUD read/read_config should works well whether configuration exists or not.
Current Behavior
There may be a bug when using Config/Filter in CRUD read/read_config .
If I have both OSPF and BGP configuration in my netconf server(IOS-XRv 9000), the script works well,
but If I just have OSPF configuration in my netconf server, no BGP configuration, the script will raise a AttributeError.
Steps to Reproduce
Please refer to : https://community.cisco.com/t5/yang-development-kit-ydk/attributeerror-config-object-has-no-attribute-logger/m-p/3788454
Your Script
#!/usr/bin/env python
from argparse import ArgumentParser
from urlparse import urlparse
from ydk.services import CRUDService
from ydk.providers import NetconfServiceProvider
from ydk.services import CodecService
from ydk.providers import CodecServiceProvider
from ydk.types import Filter, Config
import logging
import json
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="NETCONF device (ssh://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 NETCONF provider
provider = NetconfServiceProvider(address=device.hostname,
port=device.port,
username=device.username,
password=device.password,
protocol=device.scheme)
json_provider = CodecServiceProvider(type=str("json"))
# create CRUD service
crud = CRUDService()
codec = CodecService()
entity = [
{
"Cisco-IOS-XR-ipv4-ospf-cfg:ospf": {}
},
{
"Cisco-IOS-XR-ipv4-bgp-cfg:bgp": {}
}
]
entities = [codec.decode(json_provider, json.dumps(tree)) for tree in entity]
crud.read(provider, Filter(entities))
Logs
Enable logging and post the logs below
System Information
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels