Have you ever wanted to make a change to one setting on all disk configs but don't want to delete the existing config and re-apply some new default because you have a lot of minor customisations out there. Some drives have been deactivated, many thresholds have been tweaked etc.
Here is a script that can change just one setting in your deployed cdms without altering anything else. I ran it direct from the nas lua script editor. It did give a timeout in the GUI but the thread kept on running and the job got done. It could be run from the scheduler so it wrote to nas.log, or with a little work run under sdk/nsa.
Sorry about the indentation. the cut and paste lost all my leading spaces, yuck My re-format may have introduced minor errors, caveat emptor.
-- change some disk settings without re-discovering and losing existing settings
-- put the setting you wish to change in here and the desired value
-- this example sets disk usage in MB active
key = "qos_disk_usage"
value = "yes"
-- set the param pds for getting cdm configs
local getarg = pds.create()
pds.putString(getarg, "name", "cdm")
-- Find hubs
local list = nimbus.request("hub", "gethubs")
for _,hub in pairs (list.hublist) do
print ("Finding Robots on "..hub.name)
local list,rc = nimbus.request(hub.addr, "getrobots")
if rc == 0 then
for _,robot in pairs (list.robotlist) do
print (" ",robot.name)
local cdm, rc = nimbus.request(robot.addr.."/controller", "probe_config_get", getarg)
if rc == 0 then
print (" Got cdm config from ",robot.name)
for section,rec in pairs (cdm) do
local changes = 0
if rec.disk ~= nil then -- is this a disk 'root' section?
if rec.qos_disk_usage == value then
print (section, " key: ",key," already set to ",value)
else
local setargs = pds.create()
pds.putString (setargs, "name", "cdm")
pds.putString (setargs, "section", section)
pds.putString (setargs, "key", key)
pds.putString (setargs, "value", value)
_, rc = nimbus.request(robot.addr.."/controller", "probe_config_set", setargs)
if rc == 0 then
print (section," changed OK")
changes = changes + 1
else
print (section," change failed")
end
end
end
if changes ~= 0 then -- restart the probe
sleep (500) -- give it a moment to write
nimbus.request(robot.addr.."/cdm", "_restart")
end
end
else
print (" Failure getting cdm config from ",robot.name)
end
end
else
print (" No response or bad response from this hub. rc = ",rc)
end
end