cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
235
Views
2
Helpful
2
Replies
Highlighted
Cisco Employee

Invalid List Element Type

Hi,

I am new to YDK and having some problems when trying to apply an ip address to a created Loopback address.  Any pointers much appreciated.

The following error is given:-

ydk.errors.YPYModelError:

  InterfaceConfigurations.interface_configuration: (INVALID_TYPE, Invalid list element type, type = <ydk.models.cisco_ios_xr.Cisco_IOS_XR_ifmgr_cfg.InterfaceConfigurations.InterfaceConfiguration.Ipv4Network.Addresses.Primary object at 0x107521b38>)

The code I am attempting to run is:-

from ydk.services import CRUDService

from ydk.providers import NetconfServiceProvider

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ifmgr_cfg as xr_ifmgr_cfg

interface_configurations = xr_ifmgr_cfg.InterfaceConfigurations()

interface_configuration = interface_configurations.InterfaceConfiguration()

interface_configuration.active = 'act'
interface_configuration.interface_name = 'Loopback1'
interface_configuration.description = 'A Yang Loopback'

ipv4network = interface_configuration.Ipv4Network.Addresses.Primary()

ipv4network.address = '10.10.10.1'
ipv4network.netmask = '255.255.255.0'

interface_configurations.interface_configuration.append(interface_configuration)

interface_configurations.interface_configuration.append(ipv4network)

crud.create(provider, interface_configurations)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: Invalid List Element Type

Your capitalization is off.  YDK follows PEP8 conventions:

Instead of

ipv4network = interface_configuration.Ipv4Network.Addresses.Primary()

you should have

ipv4network = interface_configuration.Ipv4Network.address.Primary()

Also, you should indicate that you're creating a virtual interface. See a working example at:

https://git.io/vyNz9

That should get you going!

View solution in original post

2 REPLIES 2
Highlighted
Cisco Employee

Re: Invalid List Element Type

Your capitalization is off.  YDK follows PEP8 conventions:

Instead of

ipv4network = interface_configuration.Ipv4Network.Addresses.Primary()

you should have

ipv4network = interface_configuration.Ipv4Network.address.Primary()

Also, you should indicate that you're creating a virtual interface. See a working example at:

https://git.io/vyNz9

That should get you going!

View solution in original post

Cisco Employee

Re: Invalid List Element Type

Thanks Santiago,

Much appreciated.  Yes I see the issue now with capitlization. Also thanks for pointing out the type Empy()

Also seems that this was incorrect -

interface_configurations.interface_configuration.append(ipv4network)

Where I should have written

interface_configuration.ipv4_network.addresses.primary = ipv4network

All working now