Skip to content

Instantly share code, notes, and snippets.

@minazou67
Last active January 22, 2019 02:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save minazou67/f39b28cca48a5cf4ebf70eaf52bdd975 to your computer and use it in GitHub Desktop.
Save minazou67/f39b28cca48a5cf4ebf70eaf52bdd975 to your computer and use it in GitHub Desktop.
How to install VMware vSphere CLI on Ubuntu

How to install VMware vSphere CLI on Ubuntu

Ubuntu に VMware vSphere CLI をインストールする方法です。
CLI ツールを使用して、ホストの構成情報のバックアップやリストアが可能です。

Environment

  • Ubuntu 16.04.3 LTS
  • VMware vSphere 6 Standard
  • VMware vSphere CLI 6.0 U2

How to Install

Download CLI tool

下記のサイトから CLI ツールをダウンロードします。

https://my.vmware.com/jp/web/vmware/details?downloadGroup=VCLI60U2&productId=491

  • VMware-vSphere-CLI-6.0.0-3561779.x86_64.tar.gz

Installing the Perl module

必要な Perl モジュールをインストールします。
CPAN ではなく apt でインストールします。

$ sudo apt install -y perl-doc libmodule-build-perl libssl-dev libxml-libxml-perl libsoap-lite-perl libuuid-perl
  • OS の種類やバージョン、CLI ツールのバージョン毎に必要なモジュールは異なります。
  • 本環境では、試行錯誤した結果、上記モジュールのインストールのみで正常にインストールが完了し動作します。

Installing the CLI tool

ダウンロードしたファイルを適切な場所に配置して展開します。

$ tar xfvz VMware-vSphere-CLI-6.0.0-3561779.x86_64.tar.gz

インストール用スクリプトを実行します。

$ sudo ./vmware-vsphere-cli-distrib/vmware-install.pl
Creating a new vSphere CLI installer database using the tar4 format.

Installing vSphere CLI 6.0.0 build-3561779 for Linux.

You must read and accept the vSphere CLI End User License Agreement to
continue.
Press enter to display it.

VMware(r) vSphere Software Development Kit License Agreement

承認します。

Do you accept? (yes/no) yes

Thank you.

WARNING: The http_proxy environment variable is not set. If your system is
using a proxy for Internet access, you must set the http_proxy environment
variable .

If your system has direct Internet access, you can ignore this warning .

WARNING: The ftp_proxy environment variable is not set.  If your system is
using a proxy for Internet access, you must set the ftp_proxy environment
variable .

If your system has direct Internet access, you can ignore this warning .

Please wait while configuring CPAN ...

Below mentioned modules with their version needed to be installed,
these modules are available in your system but vCLI need specific
version to run properly

Module: ExtUtils::MakeMaker, Version: 6.96
Module: Module::Build, Version: 0.4205
Module: Net::FTP, Version: 2.77
Module: LWP, Version: 5.837

Proxy とモジュールバージョンの警告が出力されますが、無視して進みます。

Do you want to continue? (yes/no) yes

Please wait while configuring perl modules using CPAN ...

CPAN is downloading and installing pre-requisite Perl module "Devel::StackTrace" .
CPAN is downloading and installing pre-requisite Perl module "Class::Data::Inheritable" .
CPAN is downloading and installing pre-requisite Perl module "Convert::ASN1" .
CPAN is downloading and installing pre-requisite Perl module "Crypt::OpenSSL::RSA" .
CPAN is downloading and installing pre-requisite Perl module "Crypt::X509" .
CPAN is downloading and installing pre-requisite Perl module "Exception::Class".
CPAN is downloading and installing pre-requisite Perl module "UUID::Random" .
CPAN is downloading and installing pre-requisite Perl module "Path::Class" .
CPAN is downloading and installing pre-requisite Perl module "Crypt::SSLeay" .
CPAN is downloading and installing pre-requisite Perl module "Class::MethodMaker" .
CPAN is downloading and installing pre-requisite Perl module "Data::Dump" .
CPAN is downloading and installing pre-requisite Perl module "Socket6 " .
CPAN is downloading and installing pre-requisite Perl module "IO::Socket::INET6" .
CPAN is downloading and installing pre-requisite Perl module "Net::INET6Glue" .

デフォルトのディレクトリにインストールします。

In which directory do you want to install the executable files?
[/usr/bin]

Please wait while copying vSphere CLI files...

The installation of vSphere CLI 6.0.0 build-3561779 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
"/usr/bin/vmware-uninstall-vSphere-CLI.pl".

This installer has successfully installed both vSphere CLI and the vSphere SDK
for Perl.

Enjoy,

--the VMware team

How to Uninstall

Uninstalling the CLI tool

$ sudo /usr/bin/vmware-uninstall-vSphere-CLI.pl
Uninstalling the tar installation of vSphere CLI.

File /usr/share/perl/5.22/VMware/VICommon.pm is backed up to
/usr/share/perl/5.22/VMware/VICommon.pm.old.0.

The removal of vSphere CLI 6.0.0 build-2503617 for Linux completed
successfully.  Thank you for having tried this software.

Execute command

CLI ツールでは、下記のコマンド以外にも多数のコマンドが提供されています。
ESX/ESXi ホストの IP アドレスを 192.168.100.200 として仮定しています。
コマンド実行時に下記の警告が出力されますが、Perl 5.20.0 で新しく追加された警告なので無視します。

Possible precedence issue with control flow operator at /usr/share/perl/5.22/VMware/VICommon.pm line 2332.

Confirm version

$ vmware-cmd --version
vSphere SDK for Perl version: 6.0.0
Script 'vmware-cmd' version: 6.0.0

Confirm connection

$ /usr/lib/vmware-vcli/apps/general/connect.pl --url https://192.168.100.200/sdk --username root
Enter password:

Connection Successful
Server Time : 2017-10-24T03:12:14.370793Z

Display information about the host

$ vicfg-hostops --server 192.168.100.200 --username root --operation info
Enter password:
Host Name            : esxi6.example.com
Manufacturer         : Dell Inc.
Model                : PowerEdge R430
Processor Type       : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
CPU Cores            : 12 CPUs x 2497 GHz
Memory Capacity      : 65439.2421875 MB
VMotion Enabled      : no
In Maintenance Mode  : no
Last Boot Time       : 2017-01-13T12:07:27.459716Z

Back up host configuration

$ vicfg-cfgbackup --server 192.168.100.200 --username root -s esxi6_backup.cfg
Enter password:
Saving firmware configuration to esxi6_backup.cfg ...

Restore host configuration

$ vicfg-cfgbackup --server 192.168.100.200 --username root -l esxi6_backup.cfg
  • リストアを実行する前には必ずバックアップを取得してください。

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment