How Do I Programmatically Set Robots Into Maintenance Mode?

book

Article ID: 35064

calendar_today

Updated On:

Products

DX Infrastructure Management NIMSOFT PROBES

Issue/Introduction

Question: 

- How Do I Programmatically Set Robots Into Maintenance Mode?

 

Answer: 

- This procedure describes a NAS sample script to place all robots reporting to a specified hub into maintenance mode:

 

-- NAS script to set all robots reporting to specified hub into maintenance mode --


local duration = 60 --edit per hub - note this is in seconds
local hubName = "jmc-lt-dev" --edit per hub
local hubRobot = "jmc-w2k3" -- edit per hub
local nmsDomain = "JMC_LT_DEV" --edit per hub
local hubAddr = "/"..nmsDomain.."/"..hubName.."/"..hubRobot.."/"
local myBuffer ="NMS Scheduled Maintenance Script for "..hubName.."\n"
local fts = timestamp.format (timestamp.now(),"%d_%b_%Y_%H_%M_%S")
local ts = timestamp.format (timestamp.now(),"%c")

myBuffer = myBuffer..ts.."\n"
myBuffer = myBuffer.."Maintenance Period Duration:
"..tostring(duration).." seconds\n"

local val,rc = nimbus.request( hubAddr.."hub","getrobots")
print("return code:"..tostring(rc))
if val ~= nil then
   print("Val is not null and type is: "..type (val))
   for i,a in pairs(val) do
      print("a is not null and type is: "..type(a))
      if a ~= nil then
         if type(a) == "table" then
            for b,t in pairs(a) do
               if t.name == hubRobot then
                  print("Found hub robot: "..t.name)
                  myBuffer = myBuffer.."Found hub robot "..t.name.."....Skipping\n"
               else
                  local myArgs = pds.create ()
                  pds.putString (myArgs, "until", "")
                  pds.putInt (myArgs, "for", duration)
                  pds.putString(myArgs, "comment", "NMS Scheduled Maintenance Script")
                  local rc = nimbus.request(t.addr.."/controller","maint_until", myArgs)
                  pds.delete(myArgs)
                  myBuffer = myBuffer..t.name..": "..t.addr.."....In Maintenance\n"
                  print(t.name)
                  print(t.addr)
               end
            end
         end
      end
   end
end

file.create ("C:\\ITA Scheduled Maintenance_"..fts..".log",myBuffer)

 

 

Additional Information:

 

As always, please contact CA Technologies support for CA UIM if you have further questions.

Environment

Release:
Component: UIMNAS