Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Interface expected state in template

Interface expected state in template

Scheduled Pinned Locked Moved Support
4 Posts 2 Posters 11.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D
    D
    DesertRat
    wrote on last edited by
    #1

    Where can I script the expected state of interfaces when a template is applied to node? The purpose is to ignore all interfaces except for the one I'm interested in.

    Thanks in advance

    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      Changing of interface expected state is possible from NXSL script. We currently do not have option to keep NSXL scripts in templates, so you have to use some sort of global script for this.
      Hook::ConfigurationPoll is a good place - it's a standard hook script that is executed on each configuration poll.

      A simple example is this:

      interfaces = GetNodeInterfaces($node);
      foreach(i : interfaces)
      {
      	SetInterfaceExpectedState(i, "IGNORE");
      }
      

      but you need a bit more advanced script. You can check, if node is assigned to particular template (in this case node becomes a child object of the template, so you can use e.g. $node->isDirectParent(template_object) method to check this).

      You can use mapping tables to keep list of interfaces that should be in "UP" or "DOWN" state if you need to.

      Please inform, if you need more information or examples.

      1 Reply Last reply
      0
      • D
        D
        DesertRat
        wrote on last edited by
        #3

        Thank you very much for this. I must be missing something very basic. It looks as though the $node variable is not defined in the hook. I am getting the error: "Error 14 in line 12: Function or operation argument is not an object" just trying to execute this script within Hook::ConfigurationPoll

        /* Available global variables:
         *  $object - current object, one of 'NetObj' subclasses
         *  $node - current object if it is 'Node' class
         *
         * Expected return value:
         *  none - returned value is ignored
         */
        
        sub main()
        {
          trace(1,"hook executed for ".$node->ipAddr);
        }
        
        1 Reply Last reply
        0
        • F
          F
          Filipp Sudanov
          wrote on last edited by
          #4

          There are some objects besides nodes that also have configuration poll, e.g. Clusters, which may not have the attributes that node objects have. You can check if the object is node in the beginning of your script, e.g.

          if (classof(p) == "Node") {
            ...
          }
          
          1 Reply Last reply
          0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          Powered by NodeBB Contributors
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups