Copying file from Vcentre datastore to VM
<p>I use salt-stack and  pyvmomi module to  communicate with vcenter and create the VM. On this newly created VM I want to copy files(around 1 GB) from vcenter Datastore. InitiateFileTransferToGuest can be used to upload the file to VM but how can we copy files from datastore to vm ?</p>

<p>The hackiest way I can think of is:  </p>

<ol>
<li>Save the 1GB file as .iso {either use MagicIso or inbuilt tools of
linux}. </li>
<li>Now place the file in datastore.</li>
<li>Now when creating the vm,you need to set the cdrom to point to file-data instead of empty string. </li>
<li>You can either edit the vmx file or provide the vmx options
while creating itself  </li>
</ol>

<blockquote>
<pre><code>  ide1:0.deviceType = "cdrom-image"
    ide1:0.fileName = "/vmfs/volumes/5034a864-xxxxxx/data.iso"
    ide1:0.present = "TRUE"
</code></pre>
</blockquote>

<ol start="5">
<li>After powering on the guest, depending upon the guest, you can add a batch/shell to copy to its disk.</li>
<li>If required, you can use Invoke-VMScript powercli cmdlet to do operation 5 for you.</li>
</ol>

<p>Cheers,
zXi</p>

python salt-stack vsphere vcenter pyvmomi