DX Unified Infrastructure Management

 View Only
  • 1.  NAS Script to Change Origin

    Posted Jan 12, 2015 03:34 PM

    Hi All,

     

    I was wondering to change the origin of robots to extend Dashboards to different Team's based on server owners group.

    Eg. DB servers to be accessed by DBA Team, and application owners can access application specific servers.

     

    We have more than 1000 servers, and manually adding origin field in controller probe of robot is a lot of effort.

     

    I created a script from probe_config_set callback, to modify spooler config file and then restart both spooler and controller probe.

    For testing we have not made the use of 'for' loop for looping in set of robots, to change the origin field.

    But the script is not changing the origin.

     

    args = pds.create ()

    pds.putString (args,"name","spooler")

    pds.putString (args,"section","/spooler")

    pds.putString (args,"key","origin")

    pds.putString (args,"value","DBA")

    pds.putString (args,"robot","vhedtlycfe01")

    local set = pds.create ()

    pds.putString (set,"name","spooler")

    pds.putPDS (set,"as_pds",args)

    nimbus.request ("/PHEDTCASCL01dom/PHEDTCASCL01hub/vhedtlycfe01/controller","probe_config_set",set)

    nimbus.request ("/PHEDTCASCL01dom/PHEDTCASCL01hub/vhedtlycfe01/spooler","_stop")

    nimbus.request ("/PHEDTCASCL01dom/PHEDTCASCL01hub/vhedtlycfe01/controller","_stop")

      

      

     

    As I am new to Lua scripting :smileysad:.. Any suggestions or correction in the script would be highly appreciated.

     

    Regards,

    Nirmit Bali



  • 2.  Re: NAS Script to Change Origin

    Posted Jan 12, 2015 04:49 PM

    Hi,

     

    You have formed the request incorrectly. Generally, if you wish to set more than one key at a time, it's good to use the as_pds option, which takes input in this format: "full key path" : "key"

     

    like

     

    pds.putString (args,"spooler/origin","DBA")

     

    But since you're only setting one key, you don't necessarily need to go that way. You also don't need to restart Spooler separately. You could write:

     

     
    args = pds.create ()
    pds.putString (args,"name","spooler")
    pds.putString (args,"section","spooler")
    pds.putString (args,"key","origin")
    pds.putString (args,"value","DBA")
    
    data, rc = nimbus.request("/PHEDTCASCL01dom/PHEDTCASCL01hub/vhedtlycfe01/controller", "probe_config_set", args)
    print(rc)
    
    if (rc == 0) then
       data, rc  = nimbus.request("/PHEDTCASCL01dom/PHEDTCASCL01hub/vhedtlycfe01/controller", "_stop")
       print(rc)
    end
    pds.delete(args)

     -jon