ConfD User Community

Set-hook sync problem


#1

Hi,

I am having a problem using set-hooks under a certain condition. My data structure is something like that.

module my-test {
    namespace "http://my-test.example.com/test;
    prefix "my-test";

   description
        "Test description";

    revision 2018-16-05 {
        description "Initial revision.";
    }

    container test {
        list test-rec {
            key test-name;
            leaf test-name {
                type string;
                description "Test name";
            }
            
            container my-test-ref {
                list my-test-ref-rec {
                    ordered-by user;
                    key test-name;
                    leaf test-name {
                        type string;
                        description "Test name";
                    }
                }
            }
        }
    }
}

module my-test2 {
    namespace "http://my-test.example.com/test2;
    prefix "my-test2";

   description
        "Test description";

    revision 2018-16-05 {
        description "Initial revision.";
    }

    container test2 {
        list test2-rec {
            key test2-name;
            leaf test2-name {
                type string;
                description "Test2 name";
            }
        }
    }
}

When a record is created in the test2-rec of module my-test2 i want to populate this info inside the my-test-ref-rec list of container my-test-ref in module my-test. I am using set-hooks because the target list is ordered-by-user. My implementation was working fine until i tested it with a netconf message where test2
records where created first and the test records where created later. Of course i mean in the same transaction. So when my set-hook is triggered when i call maapi.create for the target list this fails because the upper container and of course the upper record (test-rec) are not yet created.

From the user guide i read that when the complete configuration is needed then the tailf:invocation-mode substatement can be used but this only applies when transaction-hooks are used. Is there a way to by-pass this problem when using set-hooks?

Thank you.


#2

I think you cannot make set-hook dependent on other configuration as it might no yet exists (in your case in Netconf).

What you can try to do is to make your hook check if configuration (my-test-ref) is present and do nothing if it is not (yet) present.
Then you can add another set-hook (for create) to test-rec and fill my-test-ref in this hook according to the records in test2-rec (if they exist).


#3

Hi,
thanks for the reply.
This is what i already have done and it works fine.