Creating group from file?



  • I’m looking to add 170 hosts that are already registered in fog to a group for snap-in deployment, but really don’t want to click through hundreds of entries to select the ones I need. Is there a way to import from a csv or the like? I asked in the IRC and searched here in the forums and don’t seem to see anything.


  • Moderator

    I would probably put together a simple php script to do the changes you want. In my opinion, php is far more friendly with SQL than BASH is.



  • Thanks for responding. It turned out we actually already had such a script, and I was able to add the hosts to the group. I’m sure others might find your script useful if you still want to post it, though!

    @Sebastian-Roth said in Creating group from file?:

    There is a command line interface to the MySQL DB. Using this you should be able to add those hosts to a group. Start with creating that group in the web gui and noting down the ID (which you see in the URL bar of your browser when editing that group).

    Knowing this set me in the right direction, I was able to add these hosts with a short perl script, thanks.


  • Developer

    @aname Ok, so we need a bit more info. Which version of FOG do you have on that server (see in the blue cloud on the web gui)? Do you have SSH or direct access to that machine so you can run commands on the shell?

    There is a command line interface to the MySQL DB. Using this you should be able to add those hosts to a group. Start with creating that group in the web gui and noting down the ID (which you see in the URL bar of your browser when editing that group).



  • I say CSV, it’s more like return-separated - a hostname per line, like so:

    host1
    host2
    host3
    host4
    host5

    I’m not sure I have access to the SQL side of things, but I can ask one of the more senior admins. This isn’t being ‘generated’ by anything - I walked around desk by desk to find all the PCs in a certain physical location that doesn’t correspond to an existing logical group.


  • Developer

    @aname While I totally understand your need for something to automate this task I don’t think we are going to add a group settings CSV import. I think in your case it’s better to come up with a simple but effective MySQL script to do just that. How would you generate that CSV file? Please tell us and we should be able to come up with some kind of converter to make it a MySQL script doing the job for you.


Log in to reply
 

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.