======ESX====== =====Obsah:===== [[#link|Externi odkazy]]\\ [[#lpar|Klient - LPAR]]\\ [[#hmc|HMC]]\\ [[#vios|VIOS - Virtual I/O Server]]\\ =====Externi odkazy===== [[https://www.virtuallyghetto.com/kickstart|virtuallyGhetto]] ... vyborne stranky o automatizaci VMware infrastruktury (William Lam)\\ [[https://www.vmware.com/cz/products/vcenter-server.html|vCenter]]\\ [[https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.vcsa.doc/GUID-223C2821-BD98-4C7A-936B-7DBE96291BA4.html|vCenter Server Appliance]] - vCenter na Linuxu - dedikovany linux + PostgreSQL + vCenter SA jako Linux alternativa k vCenteru\\ [[https://www.powershellgallery.com/packages/VMware.PowerCLI/10.0.0.7895300|PowerCLI]] - Rozsireni PowerShellu pro administraci vCentera (i pro [[https://virtualizationreview.com/articles/2017/06/01/how-to-install-and-use-powershell-and-powercli-on-linux.aspx|Linux]])\\ =====Start/stop/status/info===== vim-cmd vmsvc/getallvms ... Seznam virtualnich masin (VM), jejich VMID\\ vim-cmd vmsvc/get.config 3 ... Vypis konfigurace 3. VM\\ vim-cmd solo/registervm /vmfs/volumes/534d2847-a2/POCITAC1.vmx ... registrace nove VM\\ vim-cmd vmsvc/power.on 5 ... start virtualni masiny\\ =====Status/Info/Logy===== vmware -v ... verze ESX\\ ====URL==== https://hostname:port/vsphere-client/ ... vCenter (port napr. 9443)\\ https://hostname/ ... ESX\\ ====Disky, VMKF oddilu==== ls /vmfs/devices/disks/\\ esxcfg-scsidevs -l | grep "Console Device:" ... seznam pouzitych disku\\ esxcli system boot device get ... vypise bootovaci disk\\ esxcli storage core path list ... cesty ke storage\\ vmkfstools -P "/vmfs/volumes/DatastoreName" ... informace na kterem disku je vany volume\\ partedUtil get "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" ... informace o disku\\ partedUtil getptbl "/vmfs/devices/disks/DeviceName" ... ukaze jednotlive oddily na disku\\ partedUtil resize "/vmfs/devices/disks/mpx.vmhba0:C0:T0:L0" 3 10229760 40000000 ... rozsireni\\ partedUtil fixGpt ... oprave GPT\\ vmkfstools --growfs "/vmfs/devices/disks/device:partition" "/vmfs/devices/disks/device:partition" ... rozsireni volume\\ fdisk -u /vmfs/devices/disks/mpx.vmhba0:C0:T0:L0 ... ukaze informace o partition\\ vmkfstools -V ... refresh VMKF volumes\\ =====VMDK - diskove soubory===== esxcfg-module multiextent ... nacte modul pro spojovani vicecetnych diskovych souboru\\ vmkfstools -i BigDataSolutions_Base-cl5.vmdk BigDataSolutions_Base-cl5-all.vmdk -d thin ... spoji vicesouborovy diskovy soubor\\ vmkfstools -i a.vmdk b.vmdk ... naklonuje vmdk\\ vmkfstools -c 2048m testdisk.vmdk ... vytvori novy disk device\\ vmkfstools -X 6G testdisk.vmdk ... rozsiri existujici disk device\\ mkfstools -i testdisk.vmdk testclone.vmdk -d thin ... naklonuje disk (bytvori kopii)\\ vmkfstools -U testdisk.vmdk ... smaze existujici disk\\ vmkfstools -E testclone.vmdk test.vmdk ... prejmenuje disk\\ $null ... namountuje DS\\ cd DS:/$($vm.Name)/\\ C:\\ Remove-PSDrive -Name DS -Confirm:$false ... odmountovani\\ ====VMware VI SDK API==== Specifikace objektu: [[ http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.VirtualDiskManager.html |VirtualDiskManager]] [[http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.Datacenter.html|Datacenter]], [[http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.HostSystem.html|HostSystem]], [[http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.host.HardwareInfo.html|HardwareInfo]], [[http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualMachine.html|VirtualMachine]], ...\\ \\ [[ https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/sdk40programmingguide.pdf|sdk40programmingguide.pdf]] [[http://pubs.vmware.com/vsphere-5-5/topic/com.vmware.ICbase/PDF/vsdk_prog_guide_5_5.pdf |vsdk_prog_guide_5_5.pd]] Knihovny implementujici API: [[https://gist.github.com/mintsoft/35859c8ed3ce33bfe9d4|Perl]], [[https://gist.github.com/mintsoft/35859c8ed3ce33bfe9d4|rbvmomi]], [[https://github.com/vmware/pyvmomi|pyvmomi]], [[https://gist.github.com/mintsoft/35859c8ed3ce33bfe9d4|Perlova ukazka]], [[https://github.com/seblucas/www-blog/blob/master/content/blog/esxi-control.md|esxi-control v Perlu]], [[http://pierrelx.com/19/|vSphere VI Java API]], [[http://vijava.sourceforge.net/doc/getstarted/tutorial.htm|2, [[https://github.com/chef-partners/knife-vsphere|knife implementace SDK api]]]] curl https://IP/sdk/vimServiceVersions.xml ... podporovane verze SDK API\\ Bash prototyp: cat run.sh curl -c c.cookies -b c.cookies -s -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' --header 'Connection: Keep-Alive' --keepalive-time 5 --data @t_session.xml https://${VCENTER_IP}/sdk/ POST_DATA=`cat t_login.xml | sed -e "s:#USER:$VUSER:" -e "s:#PASSWD:$VPASSWD:"` curl -c c.cookies -b c.cookies -k -s --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' --data "$POST_DATA" https://${VCENTER_IP}/sdk ROOT_FOLDER=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data @t_session.xml https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='rootFolder'])" -` POST_DATA=`cat t_folder_child.xml | sed -e "s:#FOLDER:$ROOT_FOLDER:"` DC=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='ManagedObjectReference'])" -` POST_DATA=`cat t_datacenter_name.xml | sed -e "s:#DC:$DC:"` DC_NAME=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='val'])" - ` POST_DATA=`cat t_datacenter_vmfolder.xml | sed -e "s:#DC:$DC:"` DC_VMFOLDER=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='val'])" - ` POST_DATA=`cat t_folder_child.xml | sed -e "s:#FOLDER:$DC_VMFOLDER:"` curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk > a.xml NUMBER_OF=`cat a.xml | xmllint --xpath "count(//*[name()='ManagedObjectReference'] -` for i in `seq 1 $NUMBER_OF`; do ENTRY_NAME=`cat a.xml | xmllint --xpath "string(//*[name()='ManagedObjectReference'][$i])" -` ENTRY_TYPE=`cat a.xml | xmllint --xpath "string(//*[name()='ManagedObjectReference'][$i]/@type)" -` echo $ENTRY_NAME $ENTRY_TYPE if test "$ENTRY_TYPE" = "VirtualMachine"; then POST_DATA=`cat t_vm_name.xml | sed -e "s:#VM:$VM:"` VM_NAME=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='val'])" - ` POST_DATA=`cat t_vm_datastore.xml | sed -e "s:#VM:$VM:"` VM_DATASTORE=`curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk | xmllint --xpath "string(//*[name()='ManagedObjectReference'])" - ` POST_DATA=`cat t_datastore_summary.xml | sed -e "s:#DS:$VM_DATASTORE:"` curl -c c.cookies -b c.cookies -k --header 'Content-Type: text/xml; charset="utf-8"' --header 'SOAPAction: "urn:internalvim25/5.5"' -s --data "$POST_DATA" https://${VCENTER_IP}/sdk > c.xml DS_NAME=`cat c.xml | xmllint --xpath "string(//*[name()='name'])" -` DS_URL=`cat c.xml | xmllint --xpath "string(//*[name()='url'])" -` DS_CAPACITY=`cat c.xml | xmllint --xpath "string(//*[name()='capacity'])" -` DS_FREESPACE=`cat c.xml | xmllint --xpath "string(//*[name()='freeSpace'])" -` DS_UNCOMMITED=`cat c.xml | xmllint --xpath "string(//*[name()='uncommitted'])" -` DS_MULTIPLEHOSTS=`cat c.xml | xmllint --xpath "string(//*[name()='multipleHostAccess'])" -` DS_TYPE=`cat c.xml | xmllint --xpath "string(//*[name()='type'])" -` echo $VM_NAME $VM_DATASTORE fi done # list of datastores: # curl -c c.cookies -b c.cookies -v -k 'https://${VCENTER_IP}/folder?dcPath=DC' # curl -c c.cookies -b c.cookies -v -k 'https://${VCENTER_IP}/folder?dcPath=CD&dsName=DS_CLUSTER_1' # curl -c c.cookies -b c.cookies -v -k 'https://${VCENTER_IP}/folder/server0116?dcPath=DC&dsName=DS%255fCLUSTER%255f1'