change cdm disk setting without re-initialising and losing custom settings

Discussion created by RobPol on Jan 9, 2013
Latest reply on Mar 30, 2015 by Chris548

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 :smileysad: 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 "
   local list,rc = nimbus.request(hub.addr, "getrobots")
   if rc == 0 then
     for _,robot in pairs (list.robotlist) do
       print (" ",
       local cdm, rc = nimbus.request(robot.addr.."/controller", "probe_config_get", getarg)
       if rc == 0 then

         print (" Got cdm config from ",

         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)
                  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
                  print (section," change failed")
         if changes ~= 0 then -- restart the probe
            sleep (500) -- give it a moment to write
            nimbus.request(robot.addr.."/cdm", "_restart")
         print (" Failure getting cdm config from ",


     print (" No response or bad response from this hub. rc = ",rc)