1 Reply Latest reply on Nov 5, 2019 2:46 PM by Mark Roberts

    Looking to change  @ContextNode.OS_Description to @ContextNode."Node Group"

    lefthandedfreak

      I'm looking for a way to alter a script that a previous employee created, that build the list of commands based on what OS the device has.

       

      We have a custom field in the NCM section of the device properties called OS_Description.  However, it will make much more sense to filter based on what "Node Group" a device is in.  Is there a library of options or a better way to make change?

       

      I attached the script, since I can't seem to paste into this page.

       

        • Re: Looking to change  @ContextNode.OS_Description to @ContextNode."Node Group"
          Mark Roberts

          I would recommend you utilise core Orion Custom Properties, rather than the NCM Node Group field, which I would not be surprised was removed eventually.

           

          The following is an excerpt from another post on the use of Custom Properties within Config Templates, which should point you in the right direction.

           

          CUSTOM PROPERTIES WITHIN TEMPLATES

           

          Custom properties are tied with nodes, and therefore can be referenced via the node parameter:

           

          script BaseChangeTemplate (NCM.Nodes @ContextNode)
          {
            CLI
            {
              show @ContextNode.MyCustomProperty
            }
          }

           

          Assuming we have created and filled in the AssetTag custom property for our devices, we can make use of e.g. it in the following way to change access lists:

           

          script ChangeAccessList (NCM.Nodes @ContextNode)
          {
            string @myip = '10.10.'
            @myip = @myip + @ContextNode.AssetTag        
          here we make the asset tag part of the IP address
            @myip = @myip + '.32'                        
          finish building IP
            CLI                                          
          commands within a CLI block are sent to the device
            {
              configure terminal
              no access-list 112
              access-list 112 remark This is a test
              access-list 112 permit tcp @myip 0.0.0.31 host 123.234.123.234 eq 445      
          include the IP with asset tag info in the access list
            }
          }