Adding Image Definitions via terminal
This is probably way out in left field, but I figured I’d ask.
I’m working on ways to streamline our image deployment across all our fog servers (16 servers in 16 different subnets). I’ve written a script on our original fog server (where all our images get created/uploaded) that deploys the image to each of the other servers via SCP.
My question is, is there a way to also “script” the adding of the image definition under image management through some command line magic? So, then when the image gets moved, it auto adds itself to the image management section?
Any help/discussion is appreciated.
Wow, thanks afmrick! I’ll definitely be checking this out. I just discovered “webmin” today that’s going to help me to more simply manage all my fog servers and easily transfer files between systems, etc. So All knowledge today is certainly a HUGE help! Most appreciated!
afmrick last edited by
You can do whatever you’d like from the command line with mysql. This one will show you the names of all the images in the images table (without column names):
[CODE]mysql --batch -u fog -pmyFOGpassword -Dfog --skip-column-names -e “SELECT imageName FROM images;”[/CODE]
Here’s the same thing except it stores all the images names in the “image_names” variable which can be handy in a script:
image_names=$(mysql --batch -u fog -pmyFOGpassword -Dfog --skip-column-names -e “SELECT imageName FROM images;”)
echo “image_names = $image_names”[/CODE]
For general scripting help, I really like the Advanced Bash Scripting Guide at [url]http://tldp.org/LDP/abs/html/[/url]
I’m learning ubuntu scripting. I’m better in windows command prompt environments I have a script that’ll copy an image file or directory to all my fog servers with one command. I’ll play around see if I can make this SQL import happen via script as well.
You, sir, are my saving grace. Need a padawan?
The imageID field is auto-increment in the database for Fog 0.32. So you just don’t pass it a value when you do the insert.
Say that you wanted to export FogServer1: Image23 to FogServer2. The steps to follow would be:
On FogServer1, make a copy of the image folder or image file from /images.
On FogServer2, store the image file or image folder to your /images.
On FogServer1, export the data you need for the image definition. You can do this using phpmyadmin. Select the record from the images table, click the export button. Uncheck to export the structure, make sure to check to export the data. Remove the imageID field from the fields list and the value from the values list (remove the comma with the value).
On FogServer2, import the data into the Fog database, images table.
You can automate this with scripts if you are a scripting guy AND you do a lot of image copies to other fog servers. If not, it may be quicker to manually redefine the images in the webUI.
Yea, all our fog servers have different images across the board. We let each site customize their images as needed. If it is possible to export a single row, then that’s great cause that’s what I was aiming for. Export a single row from one fog server, and import it into another. Can you give some insight into adding the ID number or is this really complicated?
This will drop the images table on the other servers and replace it with the one you exported. I’m not sure if you are trying to sync the images across all servers, or if some servers have different images than others.
You may have have to export just the rows for the image definitions you want and insert them into the other servers images table, letting mySQL autogenerate the image ID, or scripting your insert to use the next available image ID number.
My FOG servers are independent of each other. If I run this command, will it MERGE the tables I exported with the current data tables, or will it completely overwrite the table that I import it to?
I know a little MYSQL but not enough to be considered competent
First off, are all your fog servers independent of each other? By this I mean, did you do a normal install on all 16 servers, or do you have 1 normal install and 15 storage node servers?
If they are all independent, then try this:
mysqldump the images table from the “main” fog server and restore it to the other fog servers.
Main Fog Server, run:
[CODE]#mysqldump -u root -p[password] fog images > images.sql[/CODE]
Other Fog Servers, run:
[CODE]#mysql -u root -p[password] fog < images.sql[/CODE]