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:

    "DE:AD:BE:EF:CA:FE","myHostName","10.0.0.1","Test Host - Does not exist","5","6"
    

    Based on the template:

    "MAC Address (ie: 00:11:22:33:44:55)*","Hostname*","IP Address","Description","Operating System ID","Image ID"
    

    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 %(#0000ff][B]${webdirdest}/fog/management/includes/management/includes/hosts.upload.include.php[/B] which could be fixed by inserting the following line [U]below line 50[/U])[]

    $host->setImage( $img );
    

    [B]Fixed Version[/B]
    Here is lines 48-51 (Line numbers shown and with 51 being the new line) of [B]${webdirdest}/fog/management/includes/management/includes/hosts.upload.include.php [/B]that would fix this problem:```
    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 );


  • Senior Developer

    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.



  • hosts.upload.include.php checks*, I think, that the ImageID is valid with this**:
    ImageManager.class.php
    ** $data[5] is the Image ID in the CSV


  • Moderator

    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 http://freeghost.svn.sourceforge.net/viewvc/freeghost/tags/0.32/packages/web/management/lib/Host.class.php?revision=877&view=markup)

    It may be a dependency to check if the imageid is valid before setting the value for the host.


  • Moderator

    I think this is fixed in 0.33 code (revision 877) by looking at http://freeghost.svn.sourceforge.net/viewvc/freeghost/trunk/packages/web/management/includes/hosts.upload.include.php?revision=877&view=markup

    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.


Log in to reply
 

417
Online

38722
Users

10550
Topics

99863
Posts

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