ESXi 5.1 はデフォルトではSSHアクセスが有効になっていませんが、DCUI((Direct Console User Interface)からSSHアクセス可能な設定を行うことが出来ます。
SSHアクセスが出来ると、コマンドラインからも様々なオペレーションが可能になります。
まず、DCUI画面を表示します。
「F2」(ファンクションキー2)を押下し、「Customize System/View Logs」画面を表示します。
メニュー「Troubleshooting Options」から次の画面を表示すると、以下のメニューが出てきます。
- Enable ESXi Shell
- Enable SSH
- Modify ESXi Shell and SSH timeouts
- Restart Management Agents
この中の上の2つ「Enable ESXi Shell」と「Enable SSH」でEnterキーを押下すると、SSHアクセスが可能になります。
TTSSHで、ESXi にアクセスし、「チャレンジレスポンス認証を使う」ラジオボタンを選択し、次の画面でパスワードを入力します。
問題なければ、SSH接続できます。
unameコマンドを打ってみます。
~ # uname -a VMkernel localhost 5.1.0 #1 SMP Release build-838463 Sep 11 2012 18:13:24 x86_64 GNU/Linux ~ #
vim-cmd コマンドを確認します。
~ # vim-cmd vmsvc Commands available under vmsvc/: acquiremksticket get.snapshotinfo acquireticket get.spaceNeededForConsolidation connect get.summary convert.toTemplate get.tasklist convert.toVm getallvms createdummyvm gethostconstraints destroy login device.connection logout device.connusbdev message device.disconnusbdev power.getstate device.diskadd power.hibernate device.diskaddexisting power.off device.diskremove power.on device.getdevices power.reboot device.toolsSyncSet power.reset device.vmiadd power.shutdown device.vmiremove power.suspend devices.createnic power.suspendResume disconnect queryftcompat get.capability reload get.config setscreenres get.config.cpuidmask snapshot.create get.configoption snapshot.dumpoption get.datastores snapshot.get get.disabledmethods snapshot.remove get.environment snapshot.removeall get.filelayout snapshot.revert get.filelayoutex snapshot.setoption get.guest tools.cancelinstall get.guestheartbeatStatus tools.install get.managedentitystatus tools.upgrade get.networks unregister get.runtime upgrade ~ #
見る限り、いろんなオペレーションが可能です。
次に、仮想マシンの一覧を取得してみます。
~ # vim-cmd vmsvc/getallvms Vmid Name File Guest OS Version Annotation 1 vCenterServer [datastore1] vCenterServer/vCenterServer.vmx windows7Server64Guest vmx-08 2 AD [datastore1] AD/AD.vmx windows7Server64Guest vmx-08 27 dp-1 [datastore1] dp-1/dp-1.vmx windows7_64Guest vmx-08 3 ConnectionServer [datastore1] ConnectionServer/ConnectionServer.vmx windows7Server64Guest vmx-08 ~ #
ちゃんと表示されます。
次は少し出力が長いですが「vim-cmd vmsvc/get.summary」コマンドの実行結果です。
~ # vim-cmd vmsvc/get.summary 1 Listsummary: (vim.vm.Summary) { dynamicType = , vm = 'vim.VirtualMachine:1', runtime = (vim.vm.RuntimeInfo) { dynamicType = , device = (vim.vm.DeviceRuntimeInfo) [ (vim.vm.DeviceRuntimeInfo) { dynamicType = , runtimeState = (vim.vm.DeviceRuntimeInfo.VirtualEthernetCardRuntimeState) { dynamicType = , vmDirectPathGen2Active = false, vmDirectPathGen2InactiveReasonVm = (string) [ "vmNptIncompatibleAdapterType", "vmNptDisabledOrDisconnectedAdapter" ], vmDirectPathGen2InactiveReasonOther = (string) [ "vmNptIncompatibleNetwork" ], vmDirectPathGen2InactiveReasonExtended = , }, key = 4000, } ], host = 'vim.HostSystem:ha-host', connectionState = "connected", powerState = "poweredOff", faultToleranceState = "notConfigured", dasVmProtection = (vim.vm.RuntimeInfo.DasProtectionState) null, toolsInstallerMounted = false, suspendTime = , bootTime = , suspendInterval = 0, question = (vim.vm.QuestionInfo) null, memoryOverhead = 131354624, maxCpuUsage = 2196, maxMemoryUsage = 2048, numMksConnections = 0, recordReplayState = "inactive", cleanPowerOff = true, needSecondaryReason = , onlineStandby = false, minRequiredEVCModeKey = , consolidationNeeded = false, offlineFeatureRequirement = (vim.vm.FeatureRequirement) [ (vim.vm.FeatureRequirement) { dynamicType = , key = "cpuid.lm", featureName = "cpuid.lm", value = "Bool:Min:1", } ], }, guest = (vim.vm.Summary.GuestSummary) { dynamicType = , guestId = , guestFullName = , toolsStatus = "toolsNotRunning", toolsVersionStatus = "guestToolsCurrent", toolsVersionStatus2 = "guestToolsCurrent", toolsRunningStatus = "guestToolsNotRunning", hostName = , ipAddress = , }, config = (vim.vm.Summary.ConfigSummary) { dynamicType = , name = "vCenterServer", template = false, vmPathName = "[datastore1] vCenterServer/vCenterServer.vmx", memorySizeMB = 2048, cpuReservation = 0, memoryReservation = 0, numCpu = 1, numEthernetCards = 1, numVirtualDisks = 1, (中略) guestFullName = "Microsoft Windows Server 2008 R2 (64-bit)", annotation = "", product = (vim.vApp.ProductInfo) null, installBootRequired = , ftInfo = (vim.vm.FaultToleranceConfigInfo) null, managedBy = (vim.ext.ManagedByInfo) null, }, storage = (vim.vm.Summary.StorageSummary) { dynamicType = , (中略) }, quickStats = (vim.vm.Summary.QuickStats) { dynamicType = , (中略) }, overallStatus = "green", } ~ #
コマンドラインからも色々情報を拾えたり、オペレーションが可能となります。