MAC address as host name - auto populate, etc.



  • Hello,
    I have a small issue where I was playing around with the FOG quick registration settings, and now something is wrong and/or I cannot get it back to its default behavior where it uses the MAC address (with no colons) as the hostname.

    Before today, I have never really used the FOG_QUICKREG_AUTOPOP but I have great reason to do so now, so any help with this would be greatly appreciated.

    On a fresh FOG server install I had these settings:
    FOG_QUICKREG_AUTOPOP 1
    FOG_QUICKREG_IMG_ID 1
    FOG_QUICKREG_OS_ID 1
    FOG_QUICKREG_SYS_NAME *
    FOG_QUICKREG_SYS_NUMBER 1

    With these settings, I thought that it would auto-populate and auto-name with the machine’s MAC address as its hostname and the FOG_QUICKREG_SYS_NUMBER would advance, but I cannot get that to happen again. I know that the key is in the FOG_QUICKREG_SYS_NAME, but how do I make that the MAC address again?

    Now, the system names the machine 1, 2, 3, 4, according to the FOG_QUICKREG_SYS_NUMBER, or it actually names it *.

    I have tried 0 (off), 1 (on) and * and all possible combinations in both FOG_QUICKREG_SYS_NAME and FOG_QUICKREG_SYS_NUMBER and I just cannot get it to use the MAC address as the name anymore (without colons) like it did upon a fresh install (default behavior). I guess that I do not have to touch FOG_QUICKREG_SYS_NUMBER, which is now up to the “next number in the sequence” - since I have only 9 total machines registered in this database, FOG_QUICKREG_SYS_NUMBER is now 10, and advancing correctly.

    Any help with this would be greatly appreciated, because I really wanted to use the MAC address as the hostname (minus the colons) - I should have left it alone but I would rather not re-install, if possible.

    Thank you for any help,
    D.L.


  • Senior Developer

    If you need help, Convo me (not everybody all at once), but I can try to assist and direct where you may need it.



  • I just wanted to add that I do understand that basic scripting is not the same as developing, and is generally part of the job, but I’m sure that I will have some trouble getting this to work.

    I will try it and report back, thanks again for all of the assistance and the great work on FOG,
    D.L.



  • Thanks for the replies,
    These are both good directions to point, and thank you for the suggestions. If/when I have time to try these, I will…

    However, it would still be better if it was integrated as part of the FOG Service, or the main FOG installation, IMHO. Of course this will sound lazy, but having the work already done and having it mechanized, automated, and in the background is always better.

    That it probably the single greatest thing about FOG and the FOG Service, it WORKS - yes, there are ways to do everything that FOG and the FOG Service do independently, on your own, but I would never be able to get them working. The deployhappiness.com link illustrates this perfectly as the comment section is full of folks having trouble with it, trying to get it to work, etc. and undoubtedly that would be me as well and I would probably just give up before I got it working…

    That’s why you guys are developers and I’m just a user, haha!

    Thanks again for all of your work and help,
    D.L.


  • Developer



  • We implemented this last year so some of the information may have been changed with out being documented, but this is the script we used. Keep in mind this only updates the description in AD not on the computer itself.

    You also have to change ad permissions.

    Open ADUC
    Right click on domain select properties -> security -> advanced -> add
    Type Authenticated Users -> OK -> properties
    Change [U]Apply to:[/U] to [U]Descendant Computer Objects[/U] and allow Write Description

    DIM objSysInfo, objWMI, objComputer
    SET objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
     
    'Get OU
    SET objSysInfo=createobject("adsysteminfo")
     
    'Set computer description; will not update field if description is current or if it starts with an "!"
    FOR EACH objSMBIOS IN objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
        serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
        manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
    NEXT
    FOR EACH objComputer IN objWMI.ExecQuery("Select * from Win32_ComputerSystem")
        model = trim(replace(objComputer.Model, ",", "."))
    NEXT
    SET objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
    newDescription = "(" & serviceTag & " / " & model & ")"
    IF NOT objComputer.Description = newDescription AND NOT left(objComputer.Description,1) = "!"  THEN
        objComputer.Description = newDescription
        objComputer.SetInfo
    END IF
    


  • Thanks for the reply,
    It seems like putting the serial in “Computer Description” might be better than trying to put it in the hostname, so I guess that would be my goal, yes. In simpler terms, getting the serial into Active Directory in some form is the MAIN goal, and “Computer Description” would seem to be the best and more appropriate place/way for this, rather than the hostname.

    The problem with doing it via VBScript snapin is that is another thing to write/manage/push/worry about, and I would rather just have it be mechanized as part of the FOG Service. However, I will certainly try it that way as time allows.

    Would a VBScript pull the serial from the SQL database, or from the local machine? Off the top of my head, I cannot remember if Windows stores the motherboard serial somewhere, but you would think so…

    Also, cloning machines with/without sysprep might cause a VBScript to pull an incorrect serial if it’s pulling it from the local machine.

    Thanks,
    D.L.


  • Developer

    if your goal is to retrieve the serial number and set that to the description, you could just do that with a vbscript based snapin



  • I realize that it would be necessary to modify the FOG Service to do the “Computer Description” idea, but in theory the code/connections are already somewhat setup for something like that, correct?

    Can the FOG Service pull the serial from the SQL database? My guess would be yes, and then it would be a (not simple) matter of passing that into “Computer Description” - after that, the serial would appear inside Active Directory in quite an elegant way.

    Thanks,
    D.L.



  • Another thought, although probably even more complicated, would be to pass the system serial into “Computer Description” inside Windows which allows up to 1024 characters, I believe. I now have a better understanding of the pitfalls and cumbersome nature of having the serial as the hostname, so perhaps this would be an alternative to make the serial view-able and searchable inside Active Directory.

    The goal of this is to be able to cross-reference the systems that FOG has touched inside Active Directory (by more than just a hostname), and passing the system serial to “Computer Description” might be a more elegant or alternative way of doing this. Originally I went down the MAC path because that accomplishes this to a certain level, but that has its downside too.

    Your time, work, and thoughts are greatly appreciated,
    Thanks again,
    D.L.



  • Thank you for your time thinking this through!

    I had not thought about the issues that you mention, you are definitely right that it is more complicated than it seems at first.

    I guess even Dells would only allow 8 characters in the “prefix” to stay within the 15 character hostname limit :

    SSS-RRR-*

    And you make a good point that since it is not standardized, it would fail on many systems - ACER, and ASUS come to mind as their serials are 30 or so characters with the first 22 or so being the same, by model. The HP’s that I use have 10 characters in the serial, which would still work, but then that limits the prefix as it could no longer be 8 characters. However, I know that many folks just use SSS-* (where SSS is the site, and * would be the serial) and in this case something like this would support all Dells, and I believe all HPs.

    Since it is not standardized, and would probably require truncation then perhaps it would be more trouble than it is worth, but I just wanted to ask about this.

    Although it would be confusing, since FOG allows duplicate hostnames (and only really cares about the MAC) having truncated serials that result in duplicate hostnames would not be the end of the world, until you wanted to join / integrate Active Directory, just a thought.

    Maybe this isn’t something that would be part of the main release but could be a modification, plug-in, etc. because it is complicated, and some folks might actually hate this…

    Thanks again Tom, you’re the man!
    D.L.


  • Senior Developer

    @rhythmtone, post: 29653, member: 57 said:

    Tom,
    I’m sure that you are super busy but I would kind of like to revisit this. Would it be possible to make a similar modification so I can have “System Serial” as a variable in the quick registration process?

    HP’s are a bear, but for Dell’s this would be so sweet as the “System Serial” is only 7 characters. So the end result would be:

    SITE-ROOM-*

    Where * is the “System Serial” variable that the FOG registration collects.

    Thanks for any advice or input (MAYBE I could try to do it myself), you’re the best,
    D.L.

    PS - This is probably asking a lot, but maybe it could be truncated to 7 characters. Then it would work perfectly with Dell’s, and might work okay with other manufacturers…

    The only problem I foresee with adding this is that it’d be either all or none. Meaning, I could add an identifier for SERIAL in the naming convention that get’s automatically changed to the SERIAL of the host being added. I could even add a modifier that replaces any instance of the word SERIAL with the Host’s serial number. That being said, we’ve got truncation added to the init that truncates the hostname to 15 characters which is the limit windows can handle. Where the problem comes in is if somebody wants the naming convention to be SERIAL-14, SERIAL-16.

    This isn’t “that” difficult of a thing to add, but it’s also no simple manner. With the MAC naming system it was easy because the MAC was already being sent to perform the registration. The serial number, on the other hand, isn’t received or stored until after the host is registered, which means the name is already set. That being said, the beauty that is iPXE already has support to receive the systems serial, so I could actually pass the system’s serial number with the kernel arguments and be on our way to having this support. Where it becomes a problem is that serials aren’t standardized to a specific limit. While it would work beautifully on Dell systems, it will fail miserably on other systems.

    I’ll try to take a look into this when I get home though as I’m sure others may want this functionality as well.



  • Tom,
    I’m sure that you are super busy but I would kind of like to revisit this. Would it be possible to make a similar modification so I can have “System Serial” as a variable in the quick registration process?

    HP’s are a bear, but for Dell’s this would be so sweet as the “System Serial” is only 7 characters. So the end result would be:

    SITE-ROOM-*

    Where * is the “System Serial” variable that the FOG registration collects.

    Thanks for any advice or input (MAYBE I could try to do it myself), you’re the best,
    D.L.

    PS - This is probably asking a lot, but maybe it could be truncated to 7 characters. Then it would work perfectly with Dell’s, and might work okay with other manufacturers…



  • This worked like a charm, I really appreciate your help on this one!!

    What might also be cool is possibly to introduce other optional variables to the auto-population scheme. I am really starting to use the auto-population a lot these days, and the “System Serial” I think would be quite a useful option. For some manufacturers this is an absurdly long string (why?) but in the case of Dell’s, HP’s, etc. it would be great! I honestly wish that they would all use a short, easily readable serial/tag like Dell, but for some reason they don’t…

    In my case we often name machines STE-ROM-*******
    where ******* would be the Dell, HP serial/tag.

    Thank you again,
    D.L.


  • Senior Developer

    r974 released with this modification.

    NOTE TO ALL: If you use AUTOPOP with the SYS_NAME set as MAC, it will force the system to autoregister with the MAC address of the system and not set the hostname as: MAC

    I doubt anybody’s doing this but you never really know!



  • Thank you so much for this, I cannot wait to try it out! I have to do some other less fun stuff this afternoon, but if there is not time to get to it, then I will do so tomorrow.

    [I]“looking to have the hostname’s autopopulate as their MAC address right? Is the reason you’re wanting this particular functionality simply so that the hosts obtain a specific OS and Image ID? That’s really the only reason I could think of for this particular request.”[/I]

    [I]- [/I]This is absolutely correct, but also it auto-starts the imaging process for newly “quick registered” hosts which makes it even simpler, faster, (and you don’t have to touch the web UI) especially if I am showing this process to another person. If I have already done the setup, all they have to do is set the boot order, wait for the PXE boot menu and select “Quick Host Registration and Inventory”, nothing more, which is dead simple and fast. This gets “new in box” machines out really quickly without an admin having to set OS ID, Image ID, and press Deploy, etc. - I would like to have a better naming scheme in the future (and it seems that the code is already in place for that!) but for now I am just going to go with the MAC address as the hostname.

    Thank you again Tom, I really appreciate it. And as a big FOG fan, for me, this is a really great and useful mod. I will let you know how it goes soon,

    D.L.


  • Senior Developer

    Here is the same file for 0.32 edited in much the same way!

    For both versions, the file goes in:

    {fogwebdir}/service/auto.register.php

    Hope this helps you out!

    auto.register.php


  • Senior Developer

    Okay,

    I think I have a fix, at least for 0.33b

    In the sysname field you just need to put in any variation of the word MAC, no stars or extra characters, just the word MAC and it will autopopulate with image id and os id based on your parameters with the hostname being set as the mac address. Is this what you wanted?

    auto.register.php


  • Senior Developer

    Forgive me for my confusion, but you’re, for now, looking to have the hostname’s autopopulate as their MAC address right? Is the reason you’re wanting this particular functionality simply so that the hosts obtain a specific OS and Image ID? That’s really the only reason I could think of for this particular request. I will look at the code and from a development stand point, this should be relatively easy to accomplish. I’ll try to post an update tonight.



  • Actually, I did not try this because I really want to use autopop, but turning it off did restore the MAC address naming scheme! Thank you for the suggestion!

    So, is it not possible to autopop with the MAC address and auto-image, etc? I would much rather use the MAC address than another naming convention (right now), but it seems like this is not possible if you want it to auto-image, which currently is more important. With autopop on, of course, I can set the all the variables and get it imaging as quickly as possible, but is there no wildcard, variable, etc. that you can put in the FOG_QUICKREG_SYS_NAME to get it to still use the MAC address during this process?

    Thank you for your help, it is much appreciated!


Log in to reply
 

411
Online

38920
Users

10688
Topics

101408
Posts

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