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

ydk.errors.YInvalidArgumentError: Path is invalid: Cisco-IOS-XE-nativ

hamedfazelit
Level 1
Level 1

Hi

I am trying just to config a loop back interface by YDK in 9300 switch . I followed samples but got errors and don't know how to follow it and fix it . this my code :

 

 

from ydk.models.Cisco_IOS_XE_native import Cisco_IOS_XE_native as xe_native
from ydk.errors import YServiceProviderError
provider = NetconfServiceProvider(address='192.168.2.2',
                                    port=830,
                                    username='###',
                                    password='###',
                                    protocol='ssh')
crud = CRUDService()

native = xe_native.Native()  # create object
loopback = native.interface.Loopback()
loopback.name = 0
loopback.description = "PRIMARY ROUTER LOOPBACK"
loopback.ip.address.primary.address = "172.16.255.1"
loopback.ip.address.primary.mask = "255.255.255.255"
native.interface.loopback.append(loopback)

# read data from NETCONF device
native = crud.create(provider, native)
 # process object data
exit()

 

 

after running the code I get bellow error:

 

 

 line 68, in <module>
    native = crud.create(provider, native)
  File "/usr/local/lib/python3.10/dist-packages/ydk/errors/error_handler.py", line 103, in helper
    return func(self, provider, entity, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/ydk/services/crud_service.py", line 49, in create
    return _crud_update(provider, entity, self._crud.create)
  File "/usr/local/lib/python3.10/dist-packages/ydk/services/crud_service.py", line 69, in _crud_update
    with _handle_error():
  File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.10/dist-packages/ydk/errors/error_handler.py", line 73, in handle_runtime_error
    raise _exc
ydk.errors.YInvalidArgumentError:  Path is invalid: Cisco-IOS-XE-native:native

 

 

the library generated by ydk-gen.

 

 

1 Reply 1

I dont have a way to test this right now, try this

from ydk.models.Cisco_IOS_XE_native import Cisco_IOS_XE_native as xe_native
from ydk.errors import YServiceProviderError

provider = NetconfServiceProvider(address='192.168.2.2',
                                    port=830,
                                    username='###',
                                    password='###',
                                    protocol='ssh')
crud = CRUDService()

native = xe_native.Native()  # create object

# Define the path to the Loopback interface configuration
loopback_path = "/native/interface/Loopback[name='0']"  # Replace '0' with your desired loopback number

# Create the Loopback object with desired configuration
loopback = xe_native.Loopback()
loopback.name = "0"  # Replace with your desired loopback number
loopback.description = "PRIMARY ROUTER LOOPBACK"
loopback.ip.address.primary.address = "172.16.255.1"
loopback.ip.address.primary.mask = "255.255.255.255"

# Update the Loopback configuration at the specified path
crud.create(provider, path=loopback_path, data=loopback)

exit()

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io