freeconf / yang

Standards-based management for Golang microservices
Apache License 2.0
38 stars 14 forks source link

Derived bases of identities are not as expected when muti-level imports are done #71

Closed davidmat50 closed 1 year ago

davidmat50 commented 1 year ago

For the below files, the method Derived() for idetifyref type of 'sd-product-capability-imp-imp' was expected to give the the derived values from the the imported module, BUt it was not giving all the derived values from module_for_import.yang file

func (y *Identity) Derived() map[string]*Identity

files used are sde2e-customer-cfs-cut.yang:

module sde2e-customer-cfs-cut {
    yang-version "1.1";
    namespace "urn:params:sde2e-customer-cfs-cut";
    prefix sde2e-customer-cfs-cut;

    import module_for_import {
        prefix imp;
    }

    import module_for_import_import {
        prefix imp_imp;
    }

    identity sd-product {
        description "Software Defined Product";
    }

    identity sd-wan-main {
        base sd-product;
        description "Software Defined WAN";
    }

    identity sd-lan-main {
        base sd-product;
        description "Software Defined LAN";
    }

    identity sd-wifi-main {
        base sd-product;
        description "Software Defined WiFi";
    }

    identity sd-wifi-main-imp {
        base imp:sd-product;
        description "Software Defined WiFi";
    }

    identity sd-wifi-main-2 {
        base sd-wifi-main;
        description "Software Defined WiFi";
    }

    container customer {
        leaf-list sd-product-capability-imp {
            type identityref {
                base imp:sd-product;
            }
            default "sd-wan-imp";
            units usd;
            description "Software Products Capability for the Customer";
        }
        leaf sd-product-capability-main {
            type identityref {
                base sd-product;
            }
            default "sd-wan-main";
            units usd;
            description "Software Products Capability for the Customer";
        }
        leaf-list sd-product-capability-imp-imp {
            type identityref {
                base imp_imp:sd-wifi-imp-imp;
            }
            units usd;
            description "Software Products Capability for the Customer";
        }
        leaf product-type {
            type leafref {
                path "/customer/sd-product-capability-imp";
            }
            description "SD product type";
        }
    }
}

module_for_import.yang

module module_for_import {

    namespace "urn:netcracker:params:module_for_import";
    prefix imp;
    yang-version 1.1;

    identity sd-product {
        description
          "Software Defined Product";
    }

    identity sd-wan-imp {
        base sd-product;
        description
          "Software Defined WAN";
    }

    identity sd-lan-imp {
        base sd-product;
        description
          "Software Defined LAN";
    }

    identity sd-wifi-imp {
        base sd-product;
        description
          "Software Defined WiFi";
    }
}       

module_for_import_import.yang

module module_for_import_import {

    namespace "urn:netcracker:params:module_for_import_import";
    prefix imp_imp;
    yang-version 1.1;

    import module_for_import {
        prefix imp;
    }

    identity sd-wifi-imp-imp {
        base imp:sd-product;
        description
          "Software Defined WiFi";
    }

}
dhubler commented 1 year ago

note: i removed this function in last commit because i added FindIdentity because I thought it would be more useful and efficient. I will add it back and fix this issue at the same time.

dhubler commented 1 year ago

leaf-list

sd-wifi-imp-imp 

references identity

imp_imp:sd-wifi-imp-imp

which does not have any other identities that have that identity as their base. That is to say nothing derives from that identity so it make sense the derive list is empty.

dhubler commented 1 year ago

I do see an issue where if there were 3 modules: a, b and c and I have

a imports b and c b import c

Then the identities in "c" as seen by "a" are different then the identities of "c" been by "b" which throws off the count among other things.

dhubler commented 1 year ago

i think i fixed this.