cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
2274
Views
0
Helpful
1
Replies

AttributeError: 'Config' object has no attribute 'logger'

vipaoqun@hotmail.com
Cisco Employee
Cisco Employee

I think there is  a bug while using Config/Filter in CRUD read/read_config .

I have a script(test_6.py) as belows:

#!/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))

If I have both OSPF and BGP configuration in my netconf server(IOS-XRv 9000), the script works well,

IOS-XRv 9000 configuration:

bgp_ospf.PNG

Run script:

1.PNG

If I just have OSPF configuration in my netconf server, no BGP configuration, the script will raise a AttributeError as belows:

IOS-XRv 9000 configuration:

ospf.PNG

Run script:

bug.PNG

 

1 Reply 1

saalvare
Cisco Employee
Cisco Employee
Please file an issue, so we can take care of it:
https://github.com/CiscoDevNet/ydk-gen/issues

Thanks!