jvm2016
Hot Shot
Hot Shot

vm_methods_powercli

Jump to solution
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You can only get the number of parameters and the type of each parameter that way.
The actual explanation of what the method does and the description and content of the parameters is only available in the API Reference afaik.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
13 Replies
LucD
Leadership
Leadership

You can only get the number of parameters and the type of each parameter that way.
The actual explanation of what the method does and the description and content of the parameters is only available in the API Reference afaik.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
jvm2016
Hot Shot
Hot Shot

i am trying to see description of the following method

pastedImage_0.png

if yu can suggest the right place to get this as i did not find in the api expolrer i posted earlier.

0 Kudos
LucD
Leadership
Leadership

You have to use the latest version of the API Reference.

See ApplyEVCModeVM_Task


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot

thnaks Luc ,

below is what i got .i want to use this as reference example to create other methods .

pastedImage_0.png

if i compare  these three parametrs (_this,mask,completemasks)correspond to $vm ,$featuremasks and $true.

pastedImage_1.png

0 Kudos
LucD
Leadership
Leadership

In this method the $this refers to $vm.ExtensionData, the VirtualMachine object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot

if you could help me creating a similar task for adding disk_task in this post ..

this has only one datastore and vm has only one harddisk.

below is what i intend to perform based on the attach disk_method .

however i find this task little confusing as it does not ask for the size of the harddisk .

pastedImage_0.png

0 Kudos
jvm2016
Hot Shot
Hot Shot

i think i need to use reconfigure vm task for adding new hard disk to vm .

0 Kudos
LucD
Leadership
Leadership

Not necessarily.

If your VM is at HW version vmx-13 or higher and you just want to connect 1 existing harddisk to the  VM, then you can use the AttachDisk method.

Do you want an example for AttachDisk?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot

actually i need example of adding new disk to vm using methods available in vm.extensiondata.

0 Kudos
LucD
Leadership
Leadership

This is what I think is currently the minimum settings to add a VMDK to a VM.

There is 1 known flaw in there.

While calculating the next UnitNumber, the code doesn't take into account the maximum number of devices that can be connected to a controller.

$vmName = 'MyVM'

$dsName = 'MyDS'


$vm = Get-VM -Name $vmName

$ds = Get-Datastore -Name $dsName


$spec = New-Object VMware.Vim.VirtualMachineConfigSpec


$devSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec

$devSpec.Operation = [vmware.vim.VirtualDeviceConfigSpecOperation]::add

$devSpec.FileOperation = [vmware.vim.VirtualDeviceConfigSpecFileOperation]::create


$dev = New-Object VMware.Vim.VirtualDisk

$dev.CapacityInKB = 1GB/1KB

$dev.Key = -100

$dev.ControllerKey = (Get-ScsiController -VM $vm -Name 'SCSI controller 0').ExtensionData.Key

$dev.UnitNumber = ((Get-HardDisk -VM $vm | where{$_.ExtensionData.ControllerKey -eq $dev.ControllerKey}).ExtensionData.UnitNumber |

    Measure-Object -Maximum).Maximum + 1


$devBack = New-Object VMware.vim.VirtualDiskFlatVer2BackingInfo

$devBack.DiskMode = [VMware.Vim.VirtualDiskMode]::persistent

$devBack.ThinProvisioned = $true

$devBack.Datastore = $ds.ExtensionData.MoRef

$devBack.FileName = "[$dsName]"


$dev.Backing = $devBack


$devSpec.Device = $dev


$spec.DeviceChange += $devSpec


$vm.ExtensionData.ReconfigVM($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot

Thanks  Luc,

unlike other methods this is little not self explanatory in the document .

is there any other resource other than for spec

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/790263bc-bd30-48f1-af12-ed36055d718b/e5f17bfc...

0 Kudos
LucD
Leadership
Leadership

Besides the Reference, there are also some User Guides.
They are written for specific frameworks, but you can still pick up quite a bit from those.
This for example for the .NET framework.

For the basics, there is also Steve Jin's VMware VI and vSphere DSK book.
It is written for Java and covers a rather old vSphere version, but this is a good study guide (provided you can at least read the Java examples).

And besides those, it's a matter of practising and looking at examples from others.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot

thanks

0 Kudos