Loading src/device/service/drivers/gnmi_openconfig/handlers/Interface.py +30 −19 Original line number Diff line number Diff line Loading @@ -33,37 +33,48 @@ class InterfaceHandler(_Handler): sif_index = get_int(resource_value, 'index', None) # 0 if delete: address_ip = get_str(resource_value, 'address_ip', None) if address_ip is not None: if sif_index is None: return None, None PATH_TMPL = ( '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' '/openconfig-if-ip:ipv4/addresses/address[ip={:s}]' root_node : libyang.DContainer = yang_handler.get_data_path( '/openconfig-interfaces:interfaces' ) str_path = PATH_TMPL.format(if_name, sif_index, address_ip) return str_path, json.dumps({}) if sif_index is None: return None, None address_ip = get_str(resource_value, 'address_ip', None) if address_ip is None: PATH_TMPL = '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' str_path = PATH_TMPL.format(if_name, sif_index) str_data = json.dumps({}) root_node : libyang.DContainer = yang_handler.get_data_path( '/openconfig-interfaces:interfaces' yang_sif = root_node.find_path('/'.join([ '', # add slash at the beginning 'openconfig-interfaces:interfaces', 'interface[name="{:s}"]'.format(if_name), 'subinterfaces', 'subinterface[index="{:d}"]'.format(sif_index), ])) else: PATH_TMPL = ( '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' '/openconfig-if-ip:ipv4/addresses/address[ip={:s}]' ) str_path = PATH_TMPL.format(if_name, sif_index, address_ip) yang_sif = root_node.find_path('/'.join([ '', # add slash at the beginning 'openconfig-interfaces:interfaces', 'interface[name="{:s}"]'.format(if_name), 'subinterfaces', 'subinterface[index="{:d}"]'.format(sif_index), 'openconfig-if-ip:ipv4', 'addresses', 'address[ip="{:s}"]'.format(address_ip) ])) if yang_sif is not None: yang_sif.unlink() yang_sif.free() str_data = json.dumps({}) return str_path, str_data enabled = get_bool(resource_value, 'enabled', None) # True/False Loading Loading
src/device/service/drivers/gnmi_openconfig/handlers/Interface.py +30 −19 Original line number Diff line number Diff line Loading @@ -33,37 +33,48 @@ class InterfaceHandler(_Handler): sif_index = get_int(resource_value, 'index', None) # 0 if delete: address_ip = get_str(resource_value, 'address_ip', None) if address_ip is not None: if sif_index is None: return None, None PATH_TMPL = ( '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' '/openconfig-if-ip:ipv4/addresses/address[ip={:s}]' root_node : libyang.DContainer = yang_handler.get_data_path( '/openconfig-interfaces:interfaces' ) str_path = PATH_TMPL.format(if_name, sif_index, address_ip) return str_path, json.dumps({}) if sif_index is None: return None, None address_ip = get_str(resource_value, 'address_ip', None) if address_ip is None: PATH_TMPL = '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' str_path = PATH_TMPL.format(if_name, sif_index) str_data = json.dumps({}) root_node : libyang.DContainer = yang_handler.get_data_path( '/openconfig-interfaces:interfaces' yang_sif = root_node.find_path('/'.join([ '', # add slash at the beginning 'openconfig-interfaces:interfaces', 'interface[name="{:s}"]'.format(if_name), 'subinterfaces', 'subinterface[index="{:d}"]'.format(sif_index), ])) else: PATH_TMPL = ( '/interfaces/interface[name={:s}]/subinterfaces/subinterface[index={:d}]' '/openconfig-if-ip:ipv4/addresses/address[ip={:s}]' ) str_path = PATH_TMPL.format(if_name, sif_index, address_ip) yang_sif = root_node.find_path('/'.join([ '', # add slash at the beginning 'openconfig-interfaces:interfaces', 'interface[name="{:s}"]'.format(if_name), 'subinterfaces', 'subinterface[index="{:d}"]'.format(sif_index), 'openconfig-if-ip:ipv4', 'addresses', 'address[ip="{:s}"]'.format(address_ip) ])) if yang_sif is not None: yang_sif.unlink() yang_sif.free() str_data = json.dumps({}) return str_path, str_data enabled = get_bool(resource_value, 'enabled', None) # True/False Loading