Automation

 View Only
Expand all | Collapse all

set-oscustomizationspec and IP address

  • 1.  set-oscustomizationspec and IP address

    Posted Mar 03, 2008 02:13 PM

    In the set-oscustomizationspec cmdlet there don't seem to be options to customize network related parameters (for example the IP address).

    In the "Customization Specification Manager" in the VI Client these customization parameters can be configured.

    Is this correct ? Or are we missing something ?



  • 2.  RE: set-oscustomizationspec and IP address

    Posted Mar 03, 2008 05:09 PM

    I think we need to look at this interface again - it's less than intuitive. It looks like to set the IP address, you set the customization spec's NamingPrefix to the address you want and set the NamingScheme to NamingScheme.Fixed.



  • 3.  RE: set-oscustomizationspec and IP address

    Posted Mar 03, 2008 08:39 PM

    I tested the NamingScheme and NamingContext but those don't seem to change anything related to network customization.

    These 2 parameters apparently change the Computer Name.

    I tried this:

    PS C:\>set-oscustomizationspec -spec (get-oscustomizationspec -name Test) -namingprefix 192.168.21.1 -namingscheme fixed

    When I checked via the Customization Wizard in the VI Client the Computer name fields were changed, not the IP address.



  • 4.  RE: set-oscustomizationspec and IP address

    Posted Mar 04, 2008 07:55 AM

    Seems like it's probably a bug. We'll have someone look into it.



  • 5.  RE: set-oscustomizationspec and IP address

    Posted Apr 11, 2008 09:45 PM

    Hello,

    anything new to this thread? I would like to do the same for a mass deployment of servers.

    Thanks,

    Lars



  • 6.  RE: set-oscustomizationspec and IP address

    Posted Apr 19, 2008 12:50 PM

    Hello, has there been any progress on this? I've been looking through the customization spec object and can't find anything related to IP addresses either--I would expect a NIC setting of some sort.

    Thanks,

    Steve



  • 7.  RE: set-oscustomizationspec and IP address

    Posted Apr 19, 2008 05:52 PM

    After some searching we were unable to find a method to pass the IP address via the current Set-OsCustomizationSpec cmdlet.

    We decided to revert to the SDK and use the CloneVM_Task.

    For those interested I have attached some skeleton code that shows the creation of the objects that the CloneVM_Task requires.

    Note that the script extract only shows how to set the IP settings of the first NIC.

    There are quit a lot of other settings that are omitted.



  • 8.  RE: set-oscustomizationspec and IP address

    Posted Apr 20, 2008 12:15 PM

    Hi,

    that's really nice. I will have a look at it. Seems to solve my problem, too.

    Many many thanks!

    LS



  • 9.  RE: set-oscustomizationspec and IP address

    Posted Apr 20, 2008 12:19 PM

    Hi Steve,

    I have written an email to on Friday. Perhaps we will get an information starting this week.

    But have a look at the solution of LucD - seems to solve the problem for me.

    LS



  • 10.  RE: set-oscustomizationspec and IP address

    Posted Apr 21, 2008 05:27 PM

    Hi Steve,

    I have written an email to mailto:adias@vmware.com on Friday. Perhaps we will get an information starting this week.

    But have a look at the solution of LucD - seems to solve the problem for me.

    We have a bug in the Beta toolkit that we plan to address for GA. In the meantime, using LucD's approach will work very well. When we have fixed our OSCustomizationSpec cmdlets, LucD's approach will still work, but the cmdlets should make it easier.



  • 11.  RE: set-oscustomizationspec and IP address

    Posted Apr 23, 2008 04:38 AM

    Thanks! That's a big help.

    One thing I am still having some trouble with is the resource pool for the target guest OS--I'm not using resource pools at all and would like to deploy the target VM directly on the host. How to get a resource pool object given a host name?

    Seems like a simple problem but I have been bashing my head against it for a few hours already.

    Thanks,

    Steve



  • 12.  RE: set-oscustomizationspec and IP address

    Posted Apr 23, 2008 06:32 AM

    The location parameter in the VirtualMachineCloneSpec allows you to specify where the new VM has to be created.

    Have a look at the VirtualMachineRelocateSpec entry in the SDK API Reference.

    All fields in there are optional.

    If you use the host parameter you can specify a target host for the VM clone method.



  • 13.  RE: set-oscustomizationspec and IP address

    Posted Apr 23, 2008 06:04 PM

    Thanks LucD for your reply.

    I think Location.Pool must be set if I am cloning from a template (which is my case):

    For a clone from a template to a virtual machine is argument is required.

    So I guess I will have to hunt around for the resource after all....

    Steve



  • 14.  RE: set-oscustomizationspec and IP address

    Posted Apr 23, 2008 09:45 AM

    Hello Stephen,

    I ran into the same problem.

    Ressourcepool is a property of ComputeResource object.

    I don't know how you get the parent object so you can reach COmputeResource object with the Find-EntityViews command

    With the following line you can make the link between a host and its resource pool (I only look at the first computeResource / host/ resource pool, you need to add loop to scan for your host!)

    $cr=Find-EntityViews computeResource

    $computeresource0=$cr[0] #here you get the first computeResource object

    $host0_ref=$computeresource0.Host[0] #get the first host referenced

    $vmhost_obj=get-view $host0_ref

    $vmhost_name= $vmhost_obj.name #here you get your host name, now get the ressource pool

    $respool_ref=$computeresource0.ResourcePool #here you get a reference

    $respool_obj=Get-View $respool_ref #this is the object you can use with a commandlet

    I'm just learning...



  • 15.  RE: set-oscustomizationspec and IP address

    Posted Apr 25, 2008 10:46 PM

    Thanks! That did the trick.

    The code I finally wound up using is:

    $filter = New-Object -TypeName "System.Collections.Specialized.NameValueCollection"

    $filter.Add("Name", $Hostname)

    $ComputeResource = Find-EntityViews ComputeResource -Filter $filter

    $vmclonespec = New-Object VMware.Vim.VirtualMachineCloneSpec

    $vmclonespec.location = New-Object VMware.Vim.VirtualMachineRelocateSpec

    $vmclonespec.Location.Pool = $ComputeResource.ResourcePool

    $vmclonespec.Location.Host = (Get-View (Get-vmHost $Hostname).id).moref

    $vmclonespec.Location.Datastore = (Get-View (Get-Datastore -VMHost (Get-vmHost $Hostname)).id).moref



  • 16.  RE: set-oscustomizationspec and IP address

    Posted Nov 19, 2009 05:07 PM

    I am curious if there is any update to this post. PowerCLI is no longer beta and from what I can tell there is nothing different than the beta CLI tools. I am trying to work around this issue by generating my own XML file with the IP,gateway, and computername all set according to the XML of an exported version stored on the server. I am just having an issue passing the xml to the new-oscustomizationspec cmdlet. It doesn't appear there is anyway of importing except for the gui. Is this something that was also overlooked, or am I completely off base here?

    Also in my reading I have seen that if you set -namingscheme to custom, you can have an external app supply these. I have code already written to do this. Is there any documentation on what the app needs to be written in(can it be a powershell function?), does it need to take in any args, and what/how(formatting) should it return?



  • 17.  RE: set-oscustomizationspec and IP address
    Best Answer

    Posted Nov 20, 2009 09:05 AM

    Hi,

    in the newly released PowerCLI 4.0 Update there is a gropup of commandlets managing NIC customization settings. These are

    Get-OSCustomizationNicMapping

    ,

    New-OSCustomizationNicMapping

    , and

    Set-OSCustomizationNicMapping

    . Try them out! Becasue this has been a hot topic for a lot of people I'm planning to put some demo scripts (or a demo video) on how these cmdlets are designed to work in the upcoming days!

    Enjoy it!

    \Yavor



  • 18.  RE: set-oscustomizationspec and IP address

    Posted Nov 20, 2009 09:31 AM

    Thanks Yavor, I will try them out.

    Can't wait to see to the demo(s0.



  • 19.  RE: set-oscustomizationspec and IP address

    Posted Dec 03, 2009 03:25 AM

    So I have been trying to use these new cmd-lets and I have run into even more issues. Everytime I create a new OScustomizationSpec and then create a new OScustomizationNicMapping, I end up with 2 NICs in the OScustomizationspec, so when I go to apply it to the vm, i get a

    Cannot deploy template:

    fault.NicSettingMismatch.summary

    error

    12/2/2009 7:21:37 PM

    I have tried not setting DNSsuffix and DNS servers in the OScustomizationSpec, In the GUI this looks like it solved it since when editing the spec it has "typical settings" for networking. But if you add a OScustomizationNicMapping to that spec you still end up with 2 NICs. All that changes is the settings in the second NIC to be totally blank. If I do set DNS and DNSsuffix, those are the only populated items in NIC2. But I always end up with 2 NICs.

    My workaround has been to after creating my OScustomizationSpec to do the following.

    $specmap = get-oscustomizationnicmapping -spec $spec

    remove-oscustomizationnicmapping $specmap

    Then i can add my actual OScustomizationNicMapping to the OScustomizationSpec and do a set-vm

    Any thoughts on why things work like this. It's very counter intuitive, if not a complete pain to figure out as its not documented anywhere.



  • 20.  RE: set-oscustomizationspec and IP address

    Posted Dec 03, 2009 07:37 AM

    When you create a new OSCustomizationSpec one NIC is automatically created for you. This behavior is the same as in the VI Client which also creates a default NIC. So when you use New-OSCustomizationNicMapping cmdlet it creates a new NIC and adds it to the spec, making a total of 2. There are 2 things you can do:

    1. Remove the default NIC (created when you created the spec) and then create the NIC you want using New-OSCustomizationNicMapping cmdlet - this is the approach you used

    2. Edit the existing NIC so that it is configured as you want, e.g.:

    Get-OSCustomizationNicMapping -Spec $spec | Set-OSCustomizationNicMapping ...

    I think your confusion is because of that default NIC being created when you create the spec. I hope now things are a bit more clear.



  • 21.  RE: set-oscustomizationspec and IP address

    Posted Dec 03, 2009 02:46 PM

    That does help explain things, and makes sense. I guess what threw me for a loop was that when using the -position 1 parameter and with OScustomizationNicMapping, it didn't overwrite the settings for NIC1, rather it inserted the NIC and settings at position 1.