DX Unified Infrastructure Management

Expand all | Collapse all

Is there a way to define ~50 new nimbus users from a csv-list?

  • 1.  Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jun 15, 2010 12:37 AM

    Hi,

     

    is there a way to define ~50 new nimbus users from a given list (e.g. comma separeted)? The hub-callback 'user_new' should no longer be used - but I have tested it... It works, but there is no way to specify the acl, therefore ... useless.

     

    Any ideas?

     

    Regards,

     

    Olaf



  • 2.  Re: Is there a way to define ~50 new nimbus users from a csv-list?
    Best Answer

    Posted Jun 15, 2010 02:38 PM

    The hubsec_new command for the hub will create a user with the acl for you.  I have created a small script that will read a CSV file and creates the users in this list.  The default password is changeme

    The CSV is on the format username, fullname, description, profile, acl. All fields must be present (no default handling), comments start with either # or --

    Remember to replace XXXXX with your administrator password.

     

    Enjoy :smileyhappy:

    Carstein

     

     

    local nimpw      = "XXXXX"
    local csvfile      = "new-user.csv"
    local users      = {}

    nimbus.login("administrator",nimpw)

    -- csv format:
    --   username,fullname,descr,profile,acl
    buf = file.read (csvfile)
    ul  = split(buf,"\n")

    for i=1,#ul do
         
         if not regexp (ul[i],"#*|--*") then          -- Skip comment lines (starting with # or --)
              
              f = split(ul[i],",")
              
              users[i] = {}
              users[i].username = trim(f[1])
              users[i].fullname = trim(f[2])
              users[i].description = trim(f[3])
              users[i].password = "0FyNT/PyeMO6q0IOaodWCA=="     -- password is: changeme
              users[i].profile  = trim(f[4])
              users[i].acl       = trim(f[5])
         end
         
    end

    for i,u in pairs(users) do
         
         local args = pds.create()
         
         pds.putString (args,"_section",      "users")
         pds.putString (args,"_profile",       u.username)
         pds.putString (args,"fullname",       u.fullname)
         pds.putString (args,"description",u.description)
         pds.putString (args,"password",       u.password)
         pds.putString (args,"profile",       u.profile)
         pds.putString (args,"acl",       u.acl)
         
         out,rc = nimbus.request ("hub","hubsec_new",args)
         pds.delete (args)
                        
         printf ("Creating user '%s', status %d",u.username, rc)

    end

     

     



  • 3.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jun 16, 2010 01:18 AM

    Hi Carstein,

     

    thanks a lot for your small script. It shows how to make really great things with a litte magic (magic = use of undocumented callback parameters and unknow crypting of passoword ;-) ).

     

    I added the fields phone, mobile and email to your script and it works fine.

     

    Regards,

    Olaf

     

     



  • 4.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 07, 2013 01:18 PM
    Sorry for answering a 2010 post but...

    How yo create an ACL list from CSV? I mean, I dont need creating users, just create 50-100 ACL with same permissions (copied from another ACL maybe) to associate later to Domain users via LDAP.

    Any help will be appreciated!

    thanks!


  • 5.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 08, 2013 12:02 PM
    Hi,

    maybe I have a LUA snippet for this. I look to my archive and post if I find anything helpful.

    Olaf


  • 6.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 09, 2013 10:30 AM
    Many thanks for advance!

    Javier


  • 7.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 14, 2013 01:19 PM
    Anything??


  • 8.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 14, 2013 02:09 PM

    The hubsec section is called acls so you should be able to adapt the example above to fairly easiy. 

     

    Use CTRL-P on the hub and have a look at hubsec_list with the value of _section set to acl to see the keys you will need to use. If I have time later I will see if I can script a quick example, but thats a big if :-)

     



  • 9.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 15, 2013 02:35 PM
    Im a bit newb with scripts and these kind of things in Nms but I'll try it.

    i set acl on hubsec_list on _section and send command request and shows nothing :_D What am I doing wrong?

    If you have time it will be nice to have a mini example but if not, do not worry.

    Thanks!


  • 10.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 15, 2013 04:03 PM

    This should get you on your way. Note you must run it from nsa not from the nas as the nas does not have the permissions to do this.

     

    -- Create an ACL
    --

    -- Login as admin
    nimbus.login ("administrator", "********")

    -- set ACL details
    local acl_name = "TestAcl"
    local perms = {
       ["permission"]    = 'admin',
       ["DynamicViews"]  = 1,
       ["Alarm Details"] = 1,
       ["SLM View"]      = 1,
    }

    -- now we build the arguments for the command
    local args = pds.create()
    pds.putString (args, "_section",  "acls")
    pds.putString (args, "_profile",  acl_name)

    for k,v in pairs (perms) do
      printf (" Assigning perm %-15s = %s",k,v)
      pds.putString (args, k, v)
    end

     

    -- do it and clean up

    out,rc = nimbus.request("hub", "hubsec_new", args)

    pds.delete (args)

     

    -- Check the result

    if rc == 0 then
       printf ("Creating acl: %s completed OK", acl_name)
    else
       printf ("Failure creating acl: %s return code: %d", acl_name, rc)
    end



  • 11.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 15, 2013 06:16 PM
    I'll try to do it. With your example and the ex above from csv it will be much easier.

    Many thanks Robin!


  • 12.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 15, 2013 09:50 PM

    Hi Javier,

     

    sorry - I was busy the last few days. But Robin has a very good example (Robin: Thanks, I could not do better).

     

    Another comment: If you change the NAS Probe Permission via Security->Probe Administration from 'admin' to 'super' this scripts runs perfect within the NAS-Skripting-Engine. Do not forget to restore the NAS Probe Permission.

     

    Olaf



  • 13.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jan 17, 2013 10:17 PM

    Hi,

     

    It was easy to merge both scripts and have what I need, thanks all !!

     

    Only one question: The "permission" = admin, what does imply? I mean, ACL will only have the permissions I describe but I dont understand what this tag means and if there are more options, I want users as few permissions better.

     

    I paste the code just in case anyone need it.

     

    local nimpw      = "XXXX"
    local csvfile      = "acl_list.csv"
    local acl_list2     = {}
    
    nimbus.login("administrator",nimpw)
    
    -- csv format:
    buf = file.read (csvfile)
    ul  = split(buf,"\n")
    
    for i=1,#ul do
         f = split(ul[i],",")
         
         -- set ACL details
         acl_name = trim(f[1])
         local perms = {
            ["permission"]    = 'admin',
            ["DynamicViews"]  = 1,
            ["Alarm Details"] = 1,
            ["SLM View"]      = 1,
            ["Custom Dashboards"]     = 1,
         }
         -- now we build the arguments for the command
         local args = pds.create()
         pds.putString (args, "_section",  "acls")
         pds.putString (args, "_profile",  acl_name)
    
         for k,v in pairs (perms) do
           printf (" Assigning perm %-15s = %s",k,v)
           pds.putString (args, k, v)
         end
          
         -- do it and clean up
         out,rc = nimbus.request("hub", "hubsec_new", args)
    
         pds.delete (args)
     
         -- Check the result
         if rc == 0 then
            printf ("Creating acl: %s completed OK", acl_name)
         else
            printf ("Failure creating acl: %s return code: %d", acl_name, rc)
         end
    end

     

     



  • 14.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jul 30, 2015 04:24 PM

    Is there a way to generate the password? This only works if you want it to be "changeme".



  • 15.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jul 30, 2015 04:36 PM

    Since you're working with CSVs I imagine you're likeling working with excel or something similar. You could easily create them there so you'd have them at the source easily. You can also do it with Lua, this thread for example shows you how: Impersonating an alarm from the sending probe using raw-alarms

     

    -jon



  • 16.  Re: Is there a way to define ~50 new nimbus users from a csv-list?

    Posted Jul 30, 2015 06:16 PM

    I still don't understand how the example got "0FyNT/PyeMO6q0IOaodWCA==" to be the password for changeme. Was there a callback or something else that created that? If I have to use changeme for the password initially that's OK as long as there's another callback that can change it. I found change_password and user_change_password but I can't find any documentation on them and probe utility doesn't show any parameters.