Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 206069

Re: How to map a RDM to a VM via the CLI

$
0
0

So you need powercli (or perl SDK) for this. You need to  create a devicechange spec and apply the spec with "ReconfigVM_task call.  

 

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] ($numberOfdisks)

 

Then goes through a loop and add all disks:

 

        $spec.deviceChange[$i] = New-Object VMware.Vim.VirtualDeviceConfigSpec
        $spec.deviceChange[$i].operation = "add"
        $spec.deviceChange[$i].device = New-Object VMware.Vim.VirtualDisk
        $spec.deviceChange[$i].device.backing = New-Object VMware.Vim.$backing
        $spec.deviceChange[$i].device.backing.fileName = "$Diskfile"
        $spec.deviceChange[$i].device.backing.diskMode = "independent_persistent"
        $spec.deviceChange[$i].device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
        $spec.deviceChange[$i].device.connectable.startConnected = $true
        $spec.deviceChange[$i].device.connectable.allowGuestControl = $false
        $spec.deviceChange[$i].device.connectable.connected = $true
        $spec.deviceChange[$i].device.controllerKey = $ctrlKey
        $spec.deviceChange[$i].device.unitNumber = $unit

 

 

finally, make the API call:

    $vm.ReconfigVM_Task($spec)


Viewing all articles
Browse latest Browse all 206069

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>