Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformer get for leafref(key) to uint16 fails #280

Open
anand-kumar-subramanian opened this issue Nov 15, 2019 · 2 comments
Open

Transformer get for leafref(key) to uint16 fails #280

anand-kumar-subramanian opened this issue Nov 15, 2019 · 2 comments
Assignees

Comments

@anand-kumar-subramanian
Copy link
Collaborator

Curl request:
curl -X GET "https://10.59.142.85/restconf/data/sonic-mclag:sonic-mclag/MCLAG_INTERFACE" -H "accept: application/yang-data+json"

Logs:
Nov 15 05:20:43.623481 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.619884 17 router.go:126] [REST-5] Recevied GetSonicMclagSonicMclagMclagInterface request from 10.230.26.158:63431
Nov 15 05:20:43.623481 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.622717 17 handler.go:46] [REST-5] GET /restconf/data/sonic-mclag:sonic-mclag/MCLAG_INTERFACE; content-len=0
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.623092 17 handler.go:91] [REST-5] No body
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.628063 17 handler.go:54] [REST-5] Translated path = /sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.628139 17 translib.go:465] Received Get request for path = /sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.628188 17 app_interface.go:130] getAppModule called for path =/sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.628224 17 app_interface.go:137] found the entry in the map for path =/sonic-
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.628275 17 app_interface.go:165] cast to appInterface worked&{ [] map[]}
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.629991 17 common_app.go:64] initialize:path =/sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.630949 17 db.go:335] NewDB: Init indication not requested
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.631294 17 common_app.go:111] translateGet:path =/sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.631543 17 common_app.go:183] processGet:path =/sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.631748 17 xlate.go:307] received xpath =/sonic-mclag:sonic-mclag/MCLAG_INTERFACE
Nov 15 05:20:43.634164 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.633693 17 xlate.go:96] key separator for table MCLAG_INTERFACE in Db 4 is |
Nov 15 05:20:43.639171 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.636708 17 xlate.go:122] keys for table MCLAG_INTERFACE in Db 4 are [{ Comp: [5 PortChannel50] } { Comp: [5 PortChannel60] }]
Nov 15 05:20:43.639171 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.638174 17 xlate.go:96] key separator for table MCLAG_INTERFACE in Db 4 is |
Nov 15 05:20:43.639171 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.638600 17 xlate.go:96] key separator for table MCLAG_INTERFACE in Db 4 is |
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.641379 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel50), yc(domain_id)
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.641671 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel50), yc(if_name)
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.641903 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel50), yc(if_type)
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.642143 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/if_type, yngTerminalNdDtType string and Db field value PortChannel to be converted to yang data-type.
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.642433 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_INTERFACE/if_type
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.642635 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/domain_id, yngTerminalNdDtType leafref and Db field value 5 to be converted to yang data-type.
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.642827 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_INTERFACE/domain_id
Nov 15 05:20:43.643316 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.643076 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/if_name, yngTerminalNdDtType leafref and Db field value PortChannel50 to be converted to yang data-type.
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.647527 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_INTERFACE/if_name
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.647959 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel60), yc(domain_id)
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.648203 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel60), yc(if_name)
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.648438 17 xlate_from_db.go:253] tbl(MCLAG_INTERFACE), k(5|PortChannel60), yc(if_type)
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.648727 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/if_type, yngTerminalNdDtType string and Db field value PortChannel to be converted to yang data-type.
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.648921 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_INTERFACE/if_type
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.649132 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/domain_id, yngTerminalNdDtType leafref and Db field value 5 to be converted to yang data-type.
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.649336 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_IRFACE/domain_id
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.649352 17 xlate_from_db.go:97] Received FieldXpath MCLAG_INTERFACE/if_name, yngTerminalNdDtType leafref and Dbeld value PortChannel60 to be converted to yang data-type.
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.649364 17 xlate_from_db.go:140] Yenum/Ystring/Yunion(having all members as strings) type for yangXpath MCLAG_IRFACE/if_name
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.650166 17 xlate.go:368] Payload generated:{"MCLAG_INTERFACE_LIST":[{"domain_id":"5","if_name":"PortChannel50",_type":"PortChannel"},{"domain_id":"5","if_name":"PortChannel60","if_type":"PortChannel"}]}
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server E1115 05:20:43.650748 17 common_app.go:222] ocbinds.Unmarshal() failed. error:got string type for field domain_id, expect fl64
Nov 15 05:20:43.651664 sonic INFO mgmt-framework#supervisord: rest-server E1115 05:20:43.651376 17 handler.go:58] [REST-5] Translib error *errors.errorString - got string type for field domain_id, ext float64
Nov 15 05:20:43.653842 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.652861 17 handler.go:71] [REST-5] Sending response 500, type=application/yang-data+json, data={"ietf-restconf:ors":{"error":[{"error-type":"application","error-tag":"operation-failed"}]}}
Nov 15 05:20:43.653842 sonic INFO mgmt-framework#supervisord: rest-server I1115 05:20:43.653212 17 router.go:132] [REST-5] GetSonicMclagSonicMclagMclagInterface took 30.666283ms

@anand-kumar-subramanian
Copy link
Collaborator Author

module sonic-mclag {
namespace "http://github.com/Azure/sonic-mclag";
prefix smclag;
yang-version 1.1;

import ietf-yang-types {
    prefix yang;        
}                      

    import ietf-inet-types {
            prefix inet;    
    }                      

import sonic-common {
    prefix scommon;  
}                    

import sonic-extension {
    prefix sonic-ext;  
}                      

import sonic-portchannel {
    prefix spc;          
}                        

    organization
            "SONiC";

    contact
            "SONiC";

    description
            "SONIC MCLAG";

    revision 2019-10-01 {
            description  
                    "Initial revision.";
    }                                  

    container sonic-mclag {

    container MCLAG_DOMAIN {

        list MCLAG_DOMAIN_LIST {
            key "domain_id";    
            max-elements 1;      

            leaf domain_id {
                type uint16 {
                    range "1..4095" {
                        error-message "MCLAG Domain ID out of range";
                    }                                                
                }                                                    
            }                                                        

            leaf source_ip {
                type inet:ipv4-address;
            }                          
            leaf peer_ip {            
                type inet:ipv4-address;
            }                          
            leaf peer_link {          
                type string;          
            }                          
            leaf keepalive_interval {  
                type uint16 {          
                    range "1..60" {    
                        error-message "MCLAG Domain keepalive interval out of range";
                        error-app-tag keepalive_interval-invalid;                    
                    }                                                                
                }                                                                    
                default 1;                                                          
                                                                                     
            }                                                                        
            leaf session_timeout {                                                  
                type uint16 {                                                        
                    range "1..3600" {                                                
                        error-message "MCLAG Domain session timeout out of range";  
                        error-app-tag session_timeout-invalid;                      
                    }                                                                
                }                                                                    
                default 15;                                                          
            }                                                                        
            must "(keeaplive_interval * 3) <= session_timeout" {                    
                    error-message "(keepalive interval * 3) <= session_timeout value";
                    error-app-tag keepalive_interval-invalid;                        
            }                                                                        
            must "session_timeout >= (3 *keepalive_interval)" {                      
                    error-message "(keepalive interval * 3) <= session_timeout value";
                    error-app-tag session_timeout-invalid;                            
            }                                                                        
        }                                                                            
    }                                                                                

    container MCLAG_INTERFACE {

        list MCLAG_INTERFACE_LIST {
            key "domain_id if_name";

            leaf domain_id {
                type leafref {
                    path "../../../MCLAG_DOMAIN/MCLAG_DOMAIN_LIST/domain_id";
                }                                                            
            }                                                                

            leaf if_name {
                type leafref {
                    path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name";
                }                                                                              
            }                                                                                  
            leaf if_type {                                                                      
                type string;                                                                    
            }                                                                                  

           
        }  
    }      

    //stateDB MCLAG Table
    container MCLAG_TABLE {
        sonic-ext:db-name "STATE_DB";
        sonic-ext:key-delim ":";      

        config false;
        description "state db mclag domain table";

        list MCLAG_TABLE_LIST {
            key "domain_id";    

            leaf domain_id {
                type leafref {
                    path "../../../MCLAG_DOMAIN/MCLAG_DOMAIN_LIST/domain_id";
                }                                                            
            }                                                                

            leaf oper_status {
                type scommon:oper-status;
            }

            leaf role {
                type enumeration {
                                            enum active;
                                            enum standby;
                                    }
            }

            leaf system_mac {
                type yang:mac-address;
                description
                 "System MAC Address used for ICCPD";
            }
        }
    }

    //state MCLAG Remote interface Table
    container MCLAG_REMOTE_INTF_TABLE {

        sonic-ext:db-name "STATE_DB";
        sonic-ext:key-delim ":";

        config false;
        description "state db remote interface table";

        list MCLAG_REMOTE_INTF_TABLE_LIST {
            key "domain_id if_name";

            leaf domain_id {
                type leafref {
                    path "../../../MCLAG_DOMAIN/MCLAG_DOMAIN_LIST/domain_id";
                }
            }

            leaf if_name {
                type leafref {
                    path "/spc:sonic-portchannel/spc:PORTCHANNEL/spc:PORTCHANNEL_LIST/spc:name";
                }
            }

            leaf oper_status {
                type scommon:oper-status;
            }
        }
    }

}

}

@anand-kumar-subramanian
Copy link
Collaborator Author

Note that domain_id get on the mclag_domain table works fine. Which was the earlier defect. After taking in the transformer changes this issue is not there. Now the issue is when we have a leafref as in the table mclag_interface table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants