View Only
  • 1.  Linux hostname issue

    Posted Jan 07, 2010 11:54 PM

    I am using a script to deploy a VM with OS Customizations. It all works splendidly except for one thing: the VM name doesn't match the assigned hostname in the OS. The VM name could be "Test" and the hostname will be "Test-0". It always seems to append a "-0" (dash zero) on the end of the name of the VM for the hostname in Linux (haven't tried Windows to know if I have the same results).

    Here is the line I use for the customization:

    $VMspec = New-OSCustomizationSpec -OSType "Linux" -Type Persistent -Name "$VMName-spec" -DnsServer "$VMDNS" -DnsSuffix "$VMSuffix" -NamingScheme Vm -Domain "$VMDomain"

    If I read this correctly, the "-NamingScheme Vm" should set the hostname to the same as the VM. It should use the VM name, and append a number only if there is another VM of the same name, but there isn't -- it doesn't matter what the VM name is (I've tried some pretty bizarre ones), they always add the -0 to the hostname in the guest Linux OS.

    Has anyone seen this before? Any ideas what I'm missing?


  • 2.  RE: Linux hostname issue

    Posted Jan 11, 2010 07:19 PM

    Found an answer - one I'm not thrilled with, but one that does work.

    It appears that the "-NamingScheme Vm" always appends a dash ( - ) followed by a digit (0, or whatever) to the hostname in the VM. I haven't gone through the wizard to see if that makes a difference, but I suspect it will work the same way. I worked around this by substituting "-NamingScheme "Fixed" -NamingPrefix "$VMName" " where $VMName was what I was using to name the VM anyway. There probably isn't a drawback to doing this in this way, except that I think the intent is less clear.

  • 3.  RE: Linux hostname issue

    Posted Jan 11, 2010 08:08 PM

    Might be a bug. Did you ever try it via UI? Did you get the same results?


    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|]

  • 4.  RE: Linux hostname issue

    Posted Jan 11, 2010 08:33 PM

    I just tried it. Went through the Wizard - same template, selected VM, and it worked as expected (no -0 on the hostname). Not sure why the script adds that.