Command for vShpere4 in ESX/ESXi:
1. Change service console ip in ESX
esxcfg-vswif -l
esxcfg-vswif -d vswif0
esxcfg-vswif -a vswif0 -p "Service Console" -i x.x.x.x -n x.x.x.x
after change, manual update /etc/sysconfig/network for gateway info.
2. Register a VM:
/usr/bin/vmware-cmd -s register /vmfs/volumes/VMStorage/vm166_01/vm166_01.vmx
3. Unregister a VM:
/usr/bin/vmware-cmd -s unregister /vmfs/volumes/VMStorage/vm166_01/vm166_01.vmx
4. Start a VM:
/usr/bin/vmware-cmd /vmfs/volumes/VMStorage/vm166_01/vm166_01.vmx start trysoft
Note: once I start it, I got “VMControl error -16: Virtual machine requires user input to continue” error, and checked log “Dec 23 14:52:00.275: vmx| If the virtual machine has been copied, you should create a new unique identifier (UUID). “, as a solution, I added “uuid.action = "create" in the vmx file.
5. Shutdown this VM:
/usr/bin/vmware-cmd /vmfs/volumes/VMStorage/vm166_01/vm166_01.vmx stop trysoft
6. List path and names of .registered VM vmx files on the present host
[root@esx167 ~]# vmware-cmd -l
/vmfs/volumes/4b6780c8-d02bd4c1-08d7-001ec9fd9947/vm166_04/vm166_04.vmx
7. createsnapshot name description quiesce memory
[root@esx167 ~]# vmware-cmd /vmfs/volumes/4b6780c8-d02bd4c1-08d7-001ec9fd9947/vm166_04/vm166_04.vmx getstate
getstate() = on
8. open ssh 333 port
esxcfg-firewall --openPort 333,tcp,out,WBXSSH ; to allow SSH out as 333
esxcfg-firewall --openPort 333,tcp,in,WBXSSH ; to allow SSH in as 333
9. clone a VM to another
C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\vm> perl vmclone.pl --username xxxxxx --password xxxxxx --vmhost x.x.x.x --vmname vm168_02 --vmname_destination vmclone2 --url --datastore VMStorage
Cloning virtual machine 'vm168_02' ...
Clone 'vmclone2' of virtual machine 'vm168_02' successfully created.
**********Issue troubleshoot**********:
C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\vm> perl vmclone.pl --username xxxxxx --password xxxxxx --vmhost x.x.x.x --vmname vm168_02 --vmname_destination vmclone2 --url --customize_vm yes --filename ../sampledata/clone_vm.xml --schema ../schema/vmclone.xsd
Cloning virtual machine 'vm168_02' ...
Fault
SOAP Fault:
-----------
Fault string: Unable to access file [wbxiso] vmclone2
Fault detail: CannotAccessFile
Solution: add --datastore
10. Convert a VM to a template
[root@sjimage vm]# perl vmtemplate.pl --username xxxxxx --password xxxxxx --vmname vmclonelinux --url --operation T
The Virtual Machine 'vmclonelinux' under host x.x.x.x is successfully marked as a template.
11. Copy a template to a new VM
[root@sjimage vm]# perl vmclone.pl --username xxxxxx --password xxxxxx --vmhost x.x.x.x --vmname vmclonelinux --vmname_destination vmclonelinux1 --url --datastore VMStorage
Command line in vMA:
12. Add NAS storage by command line remotely
#esxcfg-nas -a New-Datastore -o x.x.x.x -s /xxx/Test -h x.x.x.x --username xxxxxx --password xxxxxx --url /webService
阅读(796) | 评论(0) | 转发(0) |