Pages: [1]
Print
Author Topic: assigning guest ip  (Read 3078 times)
jmyerholtz
Newbie
*
Posts: 2


View Profile
« on: September 09, 2009, 01:12:45 PM »

i have over 400 guests that i need to deploy and assign static ips to.  i have been trying to use vmrun or powercli to no avail, can someone help me out?

vmrun

C:\Program Files\VMware\VMware VIX>vmrun -T esx -h https://localhost/sdk -u loca
lmgr -p Hell0W0rld -gu localmgr -gp JP1chase  runProgramInGuest "[san_vol1] serv
er1/server1.vmx" c:\windows\system32\netsh int ip set address "Local Area Connec
tion" static 192.168.15.25 255.255.255.0 192.168.15.1
Error: Cannot open VM: "[san_vol1], unknown file suffix

Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: September 09, 2009, 01:17:53 PM »

Code:
connect-viserver -server <server> -user <user> -password <pwd>
 
$vmclonespec = New-Object VMware.Vim.VirtualMachineCloneSpec
$vmclonespec.Customization = New-Object  VMware.Vim.CustomizationSpec
$vmclonespec.Customization.NicSettingMap = @(New-Object VMware.Vim.CustomizationAdapterMapping)
$vmclonespec.Customization.NicSettingMap[0].Adapter = New-Object VMware.Vim.CustomizationIPSettings
$vmclonespec.Customization.NicSettingMap[0].Adapter.ip = New-Object VMware.Vim.CustomizationFixedIp
$vmclonespec.Customization.NicSettingMap[0].Adapter.Ip.IpAddress = "<Target IP Address>"
$vmclonespec.Customization.Identity = New-Object vmware.Vim.CustomizationIdentitySettings
$vmclonespec.Customization.GlobalIPSettings = New-Object VMware.Vim.CustomizationGlobalIPSettings
 
$vmclonespec.config = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmclonespec.location = New-Object VMware.Vim.VirtualMachineRelocateSpec
 
$vmclonespec.powerOn = $false
$vmclonespec.template = $false
$name = "Test"
 
$target = Get-Folder -Name TARGETFOLDER | % {Get-View $_.ID} 
$vmmor = Get-VM VMNAME | Get-View
$vmmor.CloneVM_Task($target.MoRef ,$name, $vmclonespec )
Logged
jmyerholtz
Newbie
*
Posts: 2


View Profile
« Reply #2 on: September 09, 2009, 01:34:52 PM »

i had found that and given it a shot it came back telling me it was n"ot supported on the object."?
the script returns with a task id but the error shows in vc

i have tried it with the guest on and off.. thoughts?
Logged
pcli
Newbie
*
Posts: 8


View Profile
« Reply #3 on: July 07, 2010, 02:01:44 AM »

The script returns an error given below

Method invocation failed because [System.Object[]] doesn't contain a method named 'CloneVM_Task'.
At :line:20 char:19
+ $vmmor.CloneVM_Task <<<< ($target.MoRef ,$name, $vmclonespec )

would be nice if this can work

Thanks in advance
Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #4 on: July 07, 2010, 07:08:38 AM »

works fine for me, Jason do you have any idea what his error is?
Logged
ewannema
Administrator
Newbie
*****
Posts: 33


View Profile WWW
« Reply #5 on: July 07, 2010, 10:01:33 AM »

The System.Object[] part of the error message means that $vmmor is an array of objects and not the view of a single VM. My guess is that the Get-VM line is being called with no VM criteria or some wildcard for the name.

To validate the type of object that is pointed to by $vmmor do $vmmor.getType(). If it shows up as Object[] then you got multiple results for the Get-VM line and you should only be getting one per the code. Try running just the Get-VM portion to see what you get back.
Logged
pcli
Newbie
*
Posts: 8


View Profile
« Reply #6 on: July 08, 2010, 12:57:46 AM »

Now the error is kind a different the VC is now throwing up error . Trying it on a Red Hat VM which is already deployed with DHCP settings.


Clone virtual machine
My VM
A specified parameter
was not correct.  
spec.identity
View details...
MY\login
7/8/2010 12:57:49 PM
7/8/2010 12:57:49 PM
7/8/2010 12:57:49 PM

Can some one tell me what are the parameters that need to be changes for the script to work ( like FOLDER NAME )
« Last Edit: July 08, 2010, 02:53:10 AM by pcli » Logged
Pages: [1]
Print
Jump to: