cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
677
Views
5
Helpful
3
Replies

unable to push service policy under interface

arynair
Cisco Employee
Cisco Employee
I am able to push all other interface configs except the plocy ap under service-policy.please help resolve this
 
from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ifmgr_cfg as xr_intf
from ydk.providers import NetconfServiceProvider
from ydk.services import CRUDService
import logging
#from ydk.models import Cisco_IOS_XR_ipv4_bgp_cfg as xr_bgp
#from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_bgp_datatypes as xr_bgp_types
from ydk.types import Empty
 
#INTERFACE CONFIG BLOCK--WORKING
interface_configurations = xr_intf.InterfaceConfigurations()
interface_configuration = interface_configurations.InterfaceConfiguration()
interface_configuration.active = "act"
interface_configuration.interface_name ="GigabitEthernet0/0/0/0"
interface_configuration.description= '"NEW description"'
interface_configurations.interface_configuration.append(interface_configuration)
primary = interface_configuration.ipv4_network.addresses.Primary()
primary.address = "192.168.100.1"
primary.netmask = "255.255.255.252"
interface_configuration.ipv4_network.addresses.primary = primary
interface_configuration.vrf = "TESTING"

## qos under interface
QOS = interface_configuration.Qos()
qos1 =QOS.Input()
qos2 =QOS.Input.ServicePolicyQos()
qos2.service_policy_name = "TEST_POLICY"
qos1.service_policy_qos.append(qos2)

if __name__ == "__main__":
   

    sp_instance = NetconfServiceProvider(address='',
                                     port=830,
                                     username='',
                                     password='',
                                     protocol='ssh')

    crud_service = CRUDService()
    
    crud_service.update(sp_instance,interface_configurations)
1 Accepted Solution

Accepted Solutions

yangorelik
Spotlight
Spotlight

These lines are erroneous, because all the container and list nodes are pre-initialized in class hierarchy and must be used:

## qos under interface
QOS = interface_configuration.Qos()
qos1 =QOS.Input()
qos2 =QOS.Input.ServicePolicyQos()
qos2.service_policy_name = "TEST_POLICY"
qos1.service_policy_qos.append(qos2)
Instead you should have:
## qos under interface
qos_policy = xr_intf.InterfaceConfigurations.InterfaceConfiguration.Qos.Input.ServicePolicyQos()
qos_policy.service_policy_name = "TEST_POLICY"
interface_configuration.qos.input.service_policy_qos.append(qos_policy)
Yan Gorelik
YDK Solutions

View solution in original post

3 Replies 3

yangorelik
Spotlight
Spotlight

These lines are erroneous, because all the container and list nodes are pre-initialized in class hierarchy and must be used:

## qos under interface
QOS = interface_configuration.Qos()
qos1 =QOS.Input()
qos2 =QOS.Input.ServicePolicyQos()
qos2.service_policy_name = "TEST_POLICY"
qos1.service_policy_qos.append(qos2)
Instead you should have:
## qos under interface
qos_policy = xr_intf.InterfaceConfigurations.InterfaceConfiguration.Qos.Input.ServicePolicyQos()
qos_policy.service_policy_name = "TEST_POLICY"
interface_configuration.qos.input.service_policy_qos.append(qos_policy)
Yan Gorelik
YDK Solutions

Thank you!! it worked, but the class had to be ServicePolicy, not ServicePolicyQos .

Actually both classes to use is OK, because following documentation (and YANG model) the class Input contains 2 classes ServicePolicy and ServicePolicyQos. It is up to to your application, which one (or both of them) should be used.

Yan Gorelik
YDK Solutions