6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VMware ESXi 5.X をコマンドラインから操作する #VMWare

Last updated at Posted at 2014-07-14

目的

VMWareの作成をGUIからではなく、コマンドラインからの操作をする。

どうすればできる?

VIX API を使えばできるようです。

The VIX API helps you write scripts to automate virtual machine operations and manipulate files within guest >operating systems.
VIX programs run on different systems and support management of vSphere, Workstation, Player, and Fusion.
Bindings are provided for C, Perl, and COM (Visual Basic, VBscript, C#).

できるようにした

CentOS6.5でできるようにしました。

ダウンロード
https://my.vmware.com/jp/web/vmware/free#desktop_end_user_computing/vmware_player/6_0|PLAYER-600-A|drivers_tools

sudo sh VMware-VIX-1.13.0-1295980.x86_64.bundle

以下のようなエラーが出るので、シンボリックリンクを張って回避。
SSLLoadSharedLibraries error Failed to load OpenSSL libraries. libdir is /usr/lib/vmware

ln -s /usr/lib/vmware-vix/Workstation-10.0.0-and-vSphere-5.5.0/64bit /usr/lib/vmware

参考:http://virtlab.wordpress.com/2013/11/23/vmware-vix-1-13-and-the-sslloadsharedlibraries-error/

できること

1.Power Commands
2.Snapshot Commands
3.Guest Operating System Commands
4.Maintenance Commands
5.VProbes Commands

マシンの起動、停止、スナップショットの取得、ゲストOSへのコマンドの実行などはできそうなのですが、
マシンを新しくつくる、ということができなさそう。
+現在あるマシンからcloneを作成しようとしても、そのようなオペレーションはサポートされていないというエラーがでてしまう。

参考:https://www.vmware.com/support/developer/vix-api/vix112_vmrun_command.pdf
参考:http://www.virtuatopia.com/index.php/Controlling_VMware_Virtual_Machines_from_the_Command_Line_with_vmrun

サンプルコマンド

-リスト表示

 vmrun -T esx -h 192.168.X.XX -u <user> -p <password> list

Total running VMs: 2
[ha-datacenter/hdd] vm01/vm01.vmx
[ha-datacenter/hdd] vm02/vm02.vmx

スナップショットを取得

vmrun -T esx -h  192.168.X.XX -u <user> -p <password>  snapshot "[ha-datacenter/hdd] vm01/vm01.vmx" mysnapshot

取得したスマップショットの表示

vmrun -T esx -h 192.168.X.XX -u <user> -p <password> listSnapshots "[ha-datacenter/hdd] vm01/vm01.vmx"
Total snapshots: 1
mysnapshot

-clone

vmrun -T esx -h 192.168.X.XX -u <user> -p <password>  clone  "[ha-datacenter/hdd] vm01/vm01.vmx"  "[ha-datacenter/hdd] test/test.vmx" full

これが、オペレーションがサポートされていないとでてしまう。。

-削除

vmrun -T esx -h 192.168.X.XX -u <user> -p <password>  deleteVM  "[ha-datacenter/hdd] vm01/vm01.vmx"

ほんとにやりたいことは

仮想環境をコマンドラインからつくりたいのですが。。

これ、知っている人がいたら、教えてください!

(ちょっと宣伝)東洋経済オンラインで連載はじめました

毎週日曜日の夜18時更新です〜。

img_6027d31591e9809474754482881bf99a85306 2.jpg

応援よろしくおねがいします。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?