cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1177
Views
0
Helpful
5
Replies

Debugging copy_tree() and shared_copy_tree() usage

yfherzog
Cisco Employee
Cisco Employee

I'm trying to copy a set of nodes defined by a grouping from one point in the data model to another (both defined by the same grouping, which for now is just a bunch of dummy leafs).

I've been trying to do it from both within service create method with shared_copy_tree() and from the python console with copy_tree(). In both cases, I don't see any errors, but the data is not being copied.

Trying to copy the individual nodes seems to work with no problems.

 

Any thoughts of how can I debug this process so I'm able to tell why this is not working for me?

 

Thanks!

5 Replies 5

yfherzog
Cisco Employee
Cisco Employee

I was able to get one clue.

 

The structure I have is as follows:

 

The source node is a service instance with an empty container.

On another module, I define another service which takes some nodes defined in grouping as inputs.

The same module also augments the source node with the same grouping.

 

The idea is that the different destination modules can define their extensions to the source service model and then that the mapping logic of that generic (source) service will copy those inputs to relevant list entries defined on the destination modules.

 

The part of copying the data from source to dest doesn't work for me at this point.

The source data exists, but it's just not being copied to the destination.

 

Now, what I noticed, is when I define the data in the source model directly from the source module (instead of augmenting it from the destination module), then the copy works!

 

Anyone can think of a reason for that behavior. May be the change on prefix from the container to the content is what makes the copy method disregard it?

Answering my own questions - Yes. It seems as the change of prefix is responsible for the mess.

If I provide the top level source node to have the same prefix as the nodes under it, then the copy works.

 

The question now is whether it's possible to have the copy command disregard the prefix in some way?

Could you give an example of your yang hierarchy?

My original idea was something like this:

 

Module foo:

list foo {

  ...
  container service-data {
  }
}

 

Module bar:

augment /foo:foo/foo:service-data {
  uses bar-grouping;
}

list bar {
 uses bar-grouping;
}

grouping bar-grouping {
  ...
}

The idea is to have multiple implementations similar the second module, so that multiple modules can augment the functionality of the first module.

 

 

And then have a generic piece of code in the first module that copies the data from instances of the list in the first module to instances of modules that augment it.

 

This turned out not to work with copy_tree (shared or not) - no error message, but nothing is copied.

Eventually, I suspected that maybe the change of namespace between the service-data container to whatever is inside it has caused this behavior.

To confirm, I moved the service-data container into the augmenting module and then copy was successful.

 

This is not ideal, as it requires a slightly less generic implementation.

For now, it seems as I can live with it, but been trying to think of alternatives at the same time.

Hi yfherzog,

 

I'm facing the same problem, I would like to copy configuration from one point in device1 to the same point in device2

Can you please take a look to my post and help me if you have ani idea.

here is the link :

https://community.cisco.com/t5/nso-developer-hub-discussions/pushing-the-hole-configuration-of-an-element-in-python-action/m-p/3891141

 

Thanks in advance

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: