How can I clear niscache and reset the robot_device_id of all active robots in my UIM domain
search cancel

How can I clear niscache and reset the robot_device_id of all active robots in my UIM domain

book

Article ID: 208622

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) CA Unified Infrastructure Management On-Premise (Nimsoft / UIM) CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

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

The need to implement this cleanup/change may also be due to other environmental reasons.

Environment

  • UIM, version 9.x or higher

Cause

- leftover/erroneous hub/robot systems artifacts

Resolution

Please note: On February 24th 2023 the two scripts in this article have been updated to resolve some issues that customers have reported with the original scripts, especially in newer NAS versions (9.36 and higher).

The original scripts have been attached to this article as well as the new versions just in case they are needed for reference, but you should not use the scripts marked "old_version" unless there is a specific reason to do so (usually at the direction of Support.)

There are two scripts included below.  The first one will clear niscache on all robots (except hub robots) in the entire domain.  The second does a single hub at a time.

In large environments, the first script may time out or fail, in which case you should use the single-hub method.

The scripts will also print some error-checking information as part of the results, in case of any failure.

In the event that either script doesn't work for you, you may wish to pursue one of the alternate methods (linked at the bottom of this article). Support cannot help with this script, it is provided as-is and there may be unexpected error conditions that were not discovered in our internal testing. 

We strongly recommend running this in a test/dev environment first!

The scripts will skip any robot which has the hub probe installed, in order to avoid unexpected interruptions to the script itself.

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. In an environment with a large number of offline robots this script may time out or fail.

The script will print a list of results at the end.

How to implement/run it:

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

- Create a new script

- Paste the contents of the below script

- Edit the first line of the script to reflect the domain or hub address as indicated

- hit the green Play button

-- SCRIPT BEGIN - full domain version


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

local gethubs = nimbus.request("hub","gethubs")
for row,hub in pairs(gethubs.hublist) do
 if (hub.domain == hubdomain) then
   print("correct domain for hub " ..hub.addr)
   getrobots, rc = nimbus.request(hub.addr, "getrobots")
   print("return code for getrobots is " ..rc)
   for x,y in pairs(getrobots.robotlist) do
    if (y.status == 0) then
      print("working on robot " ..y.addr)
      local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
      if (not probes["hub"]) then
        print("Not a hub robot, resetting " ..y.addr)
        local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
        if (rc3 == 0) then
          print("success " ..y.addr)
        else
          print("failure " ..y.addr)
        end
      else
      print("Skipping hub robot "..y.addr )
      end
    else
     print("robot status for " ..y.addr..  " is not OK - skipping")
    end
   end
 else
 print("Wrong domain for hub " .. hub.addr)
 end
end
--SCRIPT END

 

 

-----The following script does one hub at a time and may be more effective, especially if you receive errors like 'attempt to index local 'probes' (a nil value)' when running the first script.

-- SCRIPT BEGIN - single hub version


hub_to_clear = "/MyDomain/HubName/hubrobotname/hub" 
 -- use the full address including /hub at the end


   getrobots, rc = nimbus.request(hub_to_clear, "getrobots")
   print("return code for getrobots is " ..rc)
   for x,y in pairs(getrobots.robotlist) do
    if (y.status == 0) then
      print("working on robot " ..y.addr)
      local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
      if (not probes["hub"]) then
        print("Not a hub robot, resetting " ..y.addr)
        local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
        if (rc3 == 0) then
          print("success " ..y.addr)
        else
          print("failure " ..y.addr)
        end
      else
      print("Skipping hub robot "..y.addr )
      end
    else
     print("robot status for " ..y.addr..  " is not OK - skipping")
    end
   end
-- SCRIPT END

 

 

 

Additional Information

NOTE: This script intentionally does not clear niscache on the hubs themselves; those should be done manually if necessary.  Most of the time it is not needed since hubs are not generally hosting monitoring probes.


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

1677280744765__clear_single_hub_new_version.lua get_app
1677280733424__clear_domain_new_version.lua get_app
1677280607794__clear_domain_old_version.lua get_app
1677280597471__clear_single_hub_old_version.lua get_app