When uploading hosts with a CSV file on 0.32 the Image ID is ignored.
-
When I upload a hosts CSV file such as this one:
[CODE]“DE:AD:BE:EF:CA:FE”,“myHostName”,“10.0.0.1”,“Test Host - Does not exist”,“5”,“6”[/CODE]
Based on the template:
[CODE]“MAC Address (ie: 00:11:22:33:44:55)","Hostname”,“IP Address”,“Description”,“Operating System ID”,“Image ID”[/CODE]
The [B]Image ID[/B], “6”, is ignored. Everything else loads up correctly but the [B]Host Image[/B] is blank.It looks like this is a bug in [COLOR=#0000ff][B][FONT=Consolas]${webdirdest}/fog/management/includes/management/includes/hosts.upload.include.php[/FONT][/B][COLOR=#000000] which could be fixed by inserting the following line [U]below line 50[/U]:[/COLOR][/COLOR]
[CODE]$host->setImage( $img );[/CODE][B]Fixed Version[/B]
Here is lines 48-51 (Line numbers shown and with 51 being the new line) of [B][FONT=Consolas][COLOR=#0000ff]${webdirdest}/fog/management/includes/management/includes/hosts.upload.include.php [/COLOR][/FONT][/B]that would fix this problem:[CODE]48 $img = $core->getImageManager()->getImageById( $data[5] );
49 $mac = new MACAddress($data[0]);
50 $host = new Host(-1, $data[1], $data[3] . " “._(“Uploaded by batch import on”).” " . date(“F j, Y, g:i a”), $data[2], null, $mac, $data[4]);
51 $host->setImage( $img );[/CODE] -
I think this is fixed in 0.33 code (revision 877) by looking at [url]http://freeghost.svn.sourceforge.net/viewvc/freeghost/trunk/packages/web/management/includes/hosts.upload.include.php?revision=877&view=markup[/url]
I’m not sure what the process is for patching current and former versions of Fog for bug fixes. At some point we need to roll up a bunch of patches to each version and release a new revision or “service pack”, like Fog 0.32 SP1, but I have no experience in those kinds of things.
Maybe some of us familiar enough to do bug fixes can get write access to the svn repository and work on patches while Fog developers work on the next version.
-
Just looked through the 0.32 code and I can’t figure out why the imageid is not accepted as an arg to the __construct (see [url]http://freeghost.svn.sourceforge.net/viewvc/freeghost/tags/0.32/packages/web/management/lib/Host.class.php?revision=877&view=markup[/url])
It may be a dependency to check if the imageid is valid before setting the value for the host.
-
[QUOTE]I think this is fixed in 0.33 code (revision 877) by looking at [URL=‘http://freeghost.svn.sourceforge.net/viewvc/freeghost/trunk/packages/web/management/includes/hosts.upload.include.php?revision=877&view=markup’][COLOR=#555555]http://freeghost.svn.sourceforge.ne…s.upload.include.php?revision=877&view=markup[/COLOR][/URL][/QUOTE]
Awesome! Thank you very much!I’m not sure exactly what you mean on your second post but, line 48 in the 0.32 [URL=‘http://freeghost.svn.sourceforge.net/viewvc/freeghost/tags/0.32/packages/web/management/includes/hosts.upload.include.php?revision=877&view=markup’]hosts.upload.include.php[/URL] checks*, I think, that the ImageID is valid with this**:
[CODE]$img = $core->getImageManager()->getImageById( $data[5] );[/CODE] …but, it then does nothing with the [SIZE=4][FONT=sans-serif][COLOR=#19177c]$img[/COLOR][/FONT][/SIZE] variable e.g. it never assigns it to the host with out the line I added …or the far prettier method in 0.33.- Also see [URL=‘http://freeghost.svn.sourceforge.net/viewvc/freeghost/tags/0.32/packages/web/lib/fog/ImageManager.class.php?revision=796&view=markup’]ImageManager.class.php[/URL]
** [SIZE=4][FONT=sans-serif][COLOR=#000000][COLOR=#19177c]$data[/COLOR][/COLOR][/FONT][/SIZE][SIZE=4][FONT=sans-serif][COLOR=#000000][[/COLOR][/FONT][/SIZE][SIZE=4][FONT=sans-serif][COLOR=#000000][COLOR=#666666]5[/COLOR][/COLOR][/FONT][/SIZE][SIZE=4][FONT=sans-serif][COLOR=#000000]][/COLOR][/FONT][/SIZE] is the Image ID in the CSV
- Also see [URL=‘http://freeghost.svn.sourceforge.net/viewvc/freeghost/tags/0.32/packages/web/lib/fog/ImageManager.class.php?revision=796&view=markup’]ImageManager.class.php[/URL]
-
I’m guessing this is still fixed. Just wanted to add, however, the img ID may not be accurate in an import of this method as it’s basing the ID is matching exactly that on the new server, which may not always be the case.