NetXMS Support Forum

English Support => Feature Requests => Topic started by: jhuliagraziella on May 06, 2015, 05:00:06 PM

Title: Suggestion - Apply template to containers
Post by: jhuliagraziella on May 06, 2015, 05:00:06 PM
I'm starting to use NetXMS and when I populated the network I decided to put each node in containers corresponding to its physical location's neighborhood. The problem was: when I tried to apply templates to the nodes I couldn't just select the containers which had the nodes, I had to open every container and select each node manually.
This sure isn't a big deal, but this kind of work can be time-consuming, monotonous and tiring when dealing with large networks. I mean, imagine selecting 2000 nodes manualy without being able to just select first, hold Shift and select last?
So my suggestion would be to add the possibility to apply a template to all the nodes that are children of a container by selecting the container itself.
For example, if I have the following directory subtree:

Infrastructure Services
|
|_Container A
|  |
|  |_Container B
|  |  |
|  |  |_node 1
|  |  |_node 2
|  |  |_node 3
|  |
|  |_Container C
|     |
|     |_node 4
|     |_node 5
|
Templates
|
|_Template T

And tried to apply template T to directory A, T would be applied to all nodes from node1 to node5.
What do you think?

Thank you,

Jhúlia Graziella
Title: Re: Suggestion - Apply template to containers
Post by: bikeprata on May 06, 2015, 08:58:34 PM
That would be great, Jhuliagraziella! I support your idea and would love to see some feature like that!

May the force be with you!
Title: Re: Suggestion - Apply template to containers
Post by: tomaskir on May 07, 2015, 08:18:07 PM
This is already entirely possible.

Simply use auto-bind scripts...
Here is an example:

parents = GetNodeParents($node);

foreach(p : parents) {
  // if the node has a parent with this name
  if (p->name == "Something") {
    // auto-bind node
    return true;
  }
}

// otherwise do not auto-bind the node
return false;
Title: Re: Suggestion - Apply template to containers
Post by: jhuliagraziella on May 07, 2015, 09:06:47 PM
Quote from: tomaskir on May 07, 2015, 08:18:07 PM
This is already entirely possible.

Simply use auto-bind scripts...
Here is an example:

parents = GetNodeParents($node);

foreach(p : parents)
{
  // if the node has a parent with this name
  if (p->name == "Something")
  {
// auto-bind node
return true;
}

// otherwise do not auto-bind the node
return false;



Feeling like a newbie here, but how exactly do I configure to execute this type of script everytime I delete something? (I'm talking about deletion by clicking with mouse's right button and then selecting delete, because that's how the operators will probably do it).
If this is possible almost ALL my problems can be resolved by configuring this!  ;D
Title: Re: Suggestion - Apply template to containers
Post by: Victor Kirhenshtein on May 08, 2015, 01:19:31 PM
Hi,

how delete is involved here? I thought that original question was about applying template. Do you need to apply template to all nodes in the system or only some of them?

Best regards,
Victor
Title: Re: Suggestion - Apply template to containers
Post by: jhuliagraziella on May 08, 2015, 09:17:44 PM
Sorry, sorry, sorry. I mixed my posts and am embarassed now.  :-[

Quote from: jhuliagraziella on May 07, 2015, 09:06:47 PM
Feeling like a newbie here, but how exactly do I configure to execute this type of script everytime I delete something? (I'm talking about deletion by clicking with mouse's right button and then selecting delete, because that's how the operators will probably do it).
If this is possible almost ALL my problems can be resolved by configuring this!  ;D

Correction:
Feeling like a newbie here, but how exactly do I configure to execute this type of script everytime I try to apply a template? (I'm talking about applying a template by clicking with mouse's right button and then selecting apply and selecting the nodes I want to apply, because that's how the operators will probably do it).
If this is possible almost ALL my problems can be resolved by configuring this!  ;D

I organized my node in containers to make it easier to see, but when applying templates this way of organizing really slows my job, because I have to open every container and select just the nodes I want and that way mistakes happen easily: I gotta be careful not to select nodes that shouldn't have the template applied and if I accidentaly select something that isn't a node (like a container) I get the following error:

Cannot apply data collection template: Invalid object ID
Invalid object ID

What I wanted was: if i tried to apply a template to a container, all container's children nodes that are "aplliable" would be.
Title: Re: Suggestion - Apply template to containers
Post by: tomaskir on May 09, 2015, 11:13:04 AM
As I said before, use auto-bind script on the template.

What you want is already possible, just use the script that I gave you a few posts ago.

It will bind the nodes under the folder to the template during a configuration poll.
Title: Re: Suggestion - Apply template to containers
Post by: jhuliagraziella on May 11, 2015, 02:26:05 PM
Quote from: tomaskir on May 09, 2015, 11:13:04 AM
As I said before, use auto-bind script on the template.

What you want is already possible, just use the script that I gave you a few posts ago.

It will bind the nodes under the folder to the template during a configuration poll.

I didn't want to use scripts because then an operator would have troubles when trying to change something... And I imagine the changes needed to turn possible what I asked for are not very complicated, but no problem! :)
Thank you very much for your help!
Title: Re: Suggestion - Apply template to containers
Post by: alike767 on July 28, 2016, 05:57:48 PM
Quote from: tomaskir on May 07, 2015, 08:18:07 PM
This is already entirely possible.

Simply use auto-bind scripts...
Here is an example:

parents = GetNodeParents($node);

foreach(p : parents)
{
  // if the node has a parent with this name
  if (p->name == "Something")
  {
// auto-bind node
return true;
}

// otherwise do not auto-bind the node
return false;



I am having a problem with this script.  I have copied and pasted it into a template on the Automatic Apply Rules section.  I changed "Something" to the name of one of my containers, and when I ran a poll Configuration (full) on one of my nodes that is in that container, the node did not get added to the template.

I noticed that there is an uneven number of "}" and put them in various places with no luck.  My guess is I am having a simple syntax issue.  Should this script work exactly as posted?

Thanks
Title: Re: Suggestion - Apply template to containers
Post by: tomaskir on July 28, 2016, 07:04:15 PM
Oops, there was indeed a syntax error.

Fixed the script in the original post, please try it.
Title: Re: Suggestion - Apply template to containers
Post by: alike767 on July 28, 2016, 08:18:40 PM
That didn't fix it for me.  I must be doing something else wrong. 

Please find attached screen shot. 
Title: Re: Suggestion - Apply template to containers
Post by: tomaskir on July 28, 2016, 08:41:29 PM
Try setting "CheckTrustedNodes" to 0 in Server Configuration and restarting the server.

Here is a Wiki article on the topic:
https://wiki.netxms.org/wiki/SG:Security_Issues
Title: Re: Suggestion - Apply template to containers
Post by: alike767 on July 28, 2016, 10:26:57 PM
Great.  That works.  I had tried that, but I guess never with the right syntax.