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

One finding regarding YDK cisco_ios_xe_bundle API

Hello Yan,

Good morning!

Could you please have a look below issue ?  The issue was fixed by lower case of "g" in program. But I check API it seems upper

case of “G”.   So I am a bit confusing.  Can you give me some advice ?

 

Thanks a lot!

 

 

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_native

interface = xe_native.Native.Interface()

interface.gigabitethernet.append(gigabitethernet)    use lower case of "g" ,  program is correct but if use upper case of "G" , program is failed.   AttributeError: 'Interface' object has no attribute 'Gigabitethernet'

But from Cisco-ios-xe bundle API GigabitEthernet is upper case of "G" . So I am confused. May I know the reason we need to use

lower case of "g".

 

Thanks a lot

 

Cisco-ios-xe_bundle API

class Native.Interface.GigabitEthernet  ----- look like G is upper case.

 

 

 

from ydk.models.cisco_ios_xe import Cisco_IOS_XE_native as xe_native

interface = xe_native.Native.Interface()

gigabitethernet = interface.GigabitEthernet()
gigabitethernet.name = "2"
gigabitethernet.description = "configured by YDK"
interface.gigabitethernet.append(gigabitethernet)  ------------program successful

(ydk) jzhang@YDK64:~/Documents$ /root/virtualenv/ydk/bin/python3 /home/jzhang/Documents/configure_IP_address.py
2020-09-03 16:55:38,748 - ydk - INFO - Executing CRUD create operation on [interface]
2020-09-03 16:55:38,748 - ydk - INFO - Executing 'edit-config' RPC on [interface]
2020-09-03 16:55:38,883 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <running/>
  </target>
  <config><native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interface nc:operation="merge">
    <GigabitEthernet>
      <name>2</name>
      <description>configured by YDK</description>
    </GigabitEthernet>
  </interface>
</native>
</config>
</edit-config>
</rpc>
2020-09-03 16:55:39,445 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <ok/>
</rpc-reply>

2020-09-03 16:55:39,446 - ydk - INFO - Operation succeeded
2020-09-03 16:55:39,676 - ydk - INFO - Disconnected from device
(ydk) jzhang@YDK64:~/Documents$

 

interface.Gigabitethernet.append(gigabitethernet)  ------------program failed

 

(ydk) jzhang@YDK64:~/Documents$ /root/virtualenv/ydk/bin/python3 /home/jzhang/Documents/configure_IP_address.py
Traceback (most recent call last):
  File "/home/jzhang/Documents/configure_IP_address.py", line 36, in <module>
    config(interface)
  File "/home/jzhang/Documents/configure_IP_address.py", line 12, in config
    interface.Gigabitethernet.append(gigabitethernet)
AttributeError: 'Interface' object has no attribute 'Gigabitethernet'
2020-09-03 16:33:09,595 - ydk - INFO - Disconnected from device
(ydk) jzhang@YDK64:~/Documents$

 

 

Jacky Zhang
Global Telecom
1 Accepted Solution

Accepted Solutions

yangorelik
Spotlight
Spotlight

This is correct! The gigabitethernet is a list in the class Cisco_IOS_XE_native.Native.Interface. Please check API.

Yan Gorelik
YDK Solutions

View solution in original post

1 Reply 1

yangorelik
Spotlight
Spotlight

This is correct! The gigabitethernet is a list in the class Cisco_IOS_XE_native.Native.Interface. Please check API.

Yan Gorelik
YDK Solutions
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: