How can I clear niscache and/or reset the robot_device_id of every active robot in my UIM domain?

book

Article ID: 208622

calendar_today

Updated On:

Products

DX Infrastructure Management

Issue/Introduction

Sometimes (usually due to issues caused by robot cloning) it may be necessary to reset the robot_device_id and clear niscache on every active robot in the entire domain.

Resolution

The following NAS script can be used to reset every robot's device ID by issuing the _reset_robot_device_id_and_restart callback to every robot found.  (It has also been attached as a file to the bottom of this KB.)

It skips any robot which has the hub probe installed, so if you need to do hubs you should do them manually (otherwise, this script would restart the hubs and cause the robots underneath it to fail to be reset).

Robots must be active and able to communicate with the controller probe for this script to hit them.

The script will print a list of robots as it goes.

 

How to implement/run it:

- Open NAS GUI, navigate to Auto-Operator, Scripts

- Create a new script

- paste the contents of the below script and hit the green Play button

-- SCRIPT BEGIN

hubdomain = "MyUIMDomain" -- put your UIM Domain here


-- Get hub addresses into an array called hubs
function get_hubs()
     local hubs = {}
     local gethubs = nimbus.request("hub","gethubs")
     for row,hub in pairs(gethubs.hublist) do
  if (string.match(hub.addr, hubdomain)) then
          hubs[hub.name] = hub.addr
   -- print(hub.addr .. " added to list")
  else
    --skip hubs that are not in the domain
        end
  end
     return hubs
end

-- Fetch a hub's robotlist into table "Robots" as: "robot name", "robot address"
function get_hub_robots(hub_address)
     local robots = {}
     getrobots, rc = nimbus.request(hub_address, "getrobots")
     if (rc ~= 0) then
          return "error"
     end
     
     for x, robot in pairs(getrobots.robotlist) do
          if (robot.status == 0) then
   local probes, rc2 = nimbus.request(robot.addr.."/controller", "port_list")
   if (not probes["hub"]) then
               robots[robot.name] = robot.addr
   else
     -- print("not adding hub: " ..robot.addr)
   end
  end
 end
     return robots
end


-- take a robot as input and reset its device ID
function reset_id(hub, robot, robot_address)
     print(robot .. " is the current robot")
         local probes, rc = nimbus.request(robot_address.."/controller", "_reset_device_id_and_restart")
   print("resetting " ..robot_address)

if rc == 0 then
          print("success " ..robot_address)
     else
          print ("failed to reset " ..robot_address)
     end
end

-- Main
local hubs = get_hubs()
for name, address in pairs(hubs) do
     
     local robots = get_hub_robots(address)
     if (robots == "error") then
          print("failure for hub " ..address)
     else
          for robotname, robotaddress in pairs(robots) do
               reset_id(name, robotname, robotaddress)
          end
     end
  
end

-- SCRIPT END

Additional Information

Alternate method:  How do I clean niscache on all active robots from the command line?  https://knowledge.broadcom.com/external/article/9570/how-to-clean-niscache-folder-on-all-acti.html

Attachments

1613506359938__reset_all_robot_id.lua get_app