VMware vSphere

 View Only
  • 1.  Create a VM via CLI.

    Posted Aug 04, 2019 11:29 AM

    Hello,

    How can I create a VM by CLI?

    Thanks.



  • 2.  RE: Create a VM via CLI.

    Posted Aug 04, 2019 11:41 AM


  • 3.  RE: Create a VM via CLI.

    Posted Aug 04, 2019 12:14 PM

    All you need is to echo a few lines into a vmx-file,

    create a vmdk with vmkfstools.

    register the VM with vom-cmd.

    Here is a very simple example ....

    mkdir /vmfs/volumes/datastore/test-vm

    cd /vmfs/volumes/datastore/test-vm

    echo  '.encoding = "UTF-8"'     > test-vm.vmx

    echo  'config.version = "8"'     >> test-vm.vmx

    echo  'virtualHW.version = "13"'     >> test-vm.vmx

    echo  'memSize = "512"'     >> test-vm.vmx

    echo  'scsi0.virtualDev = "lsilogic"'     >> test-vm.vmx

    echo  'scsi0.present = "TRUE"'     >> test-vm.vmx

    echo  'sata0.present = "TRUE"'     >> test-vm.vmx

    echo  'usb.present = "TRUE"'     >> test-vm.vmx

    echo  'ehci.present = "TRUE"'     >> test-vm.vmx

    echo  'scsi0:0.deviceType = "scsi-hardDisk"'     >> test-vm.vmx

    echo  'scsi0:0.fileName = "test-vm.vmdk"'     >> test-vm.vmx

    echo  'scsi0:0.present = "TRUE"'     >> test-vm.vmx

    echo  'ethernet0.virtualDev = "e1000e"'     >> test-vm.vmx

    echo  'ethernet0.networkName = "VM Network"'     >> test-vm.vmx

    echo  'ethernet0.addressType = "generated"'     >> test-vm.vmx

    echo  'ethernet0.present = "TRUE"'     >> test-vm.vmx

    echo  'sata0:0.deviceType = "atapi-cdrom"'     >> test-vm.vmx

    echo  'sata0:0.fileName = "/vmfs/devices/cdrom/mpx.vmhba64:C0:T0:L0"'     >> test-vm.vmx

    echo  'sata0:0.present = "TRUE"'     >> test-vm.vmx

    echo  'displayName = "test-vm"'     >> test-vm.vmx

    echo  'guestOS = "other-64"'     >> test-vm.vmx

    vmkfstools -c 2048m test-vm.vmdk

    vim-cmd solo/registervm /vmfs/volumes/datastore/test-vm/test-vm.vmx