def read_interface(crud_service, provider): interfaces_filter = Interfaces.Interface() interfaces_filter.name = "eth1/1" try: interface = crud_service.read(provider, interfaces_filter) print_interface(interface) except YPYError: print('An error occurred reading interfaces.')
def create_interfaces_config(crud_service, provider): interface = Interfaces.Interface() interface.config.name = 'LoopbackYDK' interface.name = interface.config.name try: crud_service.create(provider, interface) except YPYError: print('An error occurred creating the interface.')
def create_loopack(self, arg_loopbacknum, arg_ip, arg_prefixlen): """ <interfaces xmlns="http://openconfig.net/yang/interfaces"> <interface> <name>Loopback0</name> <config> <name>Loopback0</name> <type xmlns:idx="urn:ietf:params:xml:ns:yang:iana-if-type">idx:softwareLoopback</type> <enabled>true</enabled> </config> <subinterfaces> <subinterface> <index>0</index> <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip"> <address> <ip>172.16.255.1</ip> <config> <ip>172.16.255.1</ip> <prefix-length>32</prefix-length> </config> </address> </ipv4> </subinterface> </subinterfaces> </interface> """ oc_interface = OpenConfig_Interfaces.Interface() oc_interface.name = "Loopback" + arg_loopbacknum oc_interface.config.name = "Loopback" + arg_loopbacknum oc_interface.config.type = SoftwareloopbackIdentity() oc_interface.config.enabled = True oc_subinterface = oc_interface.subinterfaces.Subinterface() oc_subinterface.index = 0 oc_subinterface_ipv4 = oc_subinterface.Ipv4() oc_subinterface_ipv4_address = oc_subinterface_ipv4.Address() oc_subinterface_ipv4_address.ip = arg_ip oc_subinterface_ipv4_address.config.ip = arg_ip oc_subinterface_ipv4_address.config.prefix_length = arg_prefixlen oc_subinterface_ipv4.address.append(oc_subinterface_ipv4_address) oc_subinterface.ipv4 = oc_subinterface_ipv4 oc_interface.subinterfaces.subinterface.append(oc_subinterface) self.xr.ydk_crud.create(self.xr.ydk_provider, oc_interface)
def create_loopback(self, arg_loopbacknum, arg_ip, arg_prefixlen): oc_interface = OpenConfig_Interfaces.Interface() oc_interface.name = "Loopback" + arg_loopbacknum oc_interface.config.name = "Loopback" + arg_loopbacknum oc_interface.config.type = SoftwareloopbackIdentity() oc_interface.config.enabled = True oc_subinterface = oc_interface.subinterfaces.Subinterface() oc_subinterface.index = 0 oc_subinterface_ipv4 = oc_subinterface.Ipv4() oc_subinterface_ipv4_address = oc_subinterface_ipv4.Address() oc_subinterface_ipv4_address.ip = arg_ip oc_subinterface_ipv4_address.config.ip = arg_ip oc_subinterface_ipv4_address.config.prefix_length = arg_prefixlen oc_subinterface_ipv4.address.append(oc_subinterface_ipv4_address) oc_subinterface.ipv4 = oc_subinterface_ipv4 oc_interface.subinterfaces.subinterface.append(oc_subinterface) self.xr.ydk_crud.create(self.xr.ydk_provider, oc_interface)