LoginSignup
4
4

More than 5 years have passed since last update.

Windows用vSphere CLIのActive Perlについて

Last updated at Posted at 2015-09-03

メモ。

Windows用VMware vSphere CLIはActive Perlを同梱しており、各コマンドはPerlスクリプトとして実装されている。管理環境にはvSphere CLIがインストールされることが多くなり、同時にActive Perlが利用できる環境にもなる。

ユーティリティを自作するときにはこのPerlを使う形にすると、動作環境が整いやすいが、このPerlは相当に古い版数で固定されている。いま手元のWindows環境に入っているメインのPerlはStrawberry Perl v5.16.3で、これだって新しくないけど、それに比べても相当古い。

c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -v

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 50 registered patches, see perl -V for more detail)

同梱のTest::Moreは0.75版。noteやexplain、subtestといったメソッドが実装される前で、これらを使ったテストコードを含むライブラリが軒並みSyntax Errorになった。これらはより本気のテストを書こうと思ったら欠かせないもので、ユーティリティには新しいTest::Moreを同梱することにした。

c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MTest::More -e "print Test::More->VERSION"
0.75
c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MTest::More -e "note Test::More->VERSION"
Can't locate object method "note" via package "Test::More" at -e line 1.

File::Pathは1.08。make_pathメソッドがない。これは新しいFile::Pathモジュールではレガシーインターフェースとしてmkpathが残されているので、こちらを使うことにした。

c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MFile::Path -e "print File::Path->VERSION"
1.08
c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MFile::Path -e "print File::Path->can('make_path')"

c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MFile::Path -e "print File::Path->can('mkpath')"
CODE(0x3bcd2e8)

Archive::Tarは1.30版。旧来、Archive::Tarはtar書庫内容を全部メモリに読み込んでしまうのが標準の動作なのだけど、最近の版では先頭から順次処理するためのiterメソッドがある。でもこれが1.30版にはない。

c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MArchive::Tar -e "print Archive::Tar->VERSION"
1.30
c:\>"c:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" -MArchive::Tar -e "print Archive::Tar->can('iter')"

数百GBのtar.gzファイルを扱うつもりだったので、これで手詰まりになった。どうするかまだ考えているけど...GNU tarか7zipコマンドにパスするとかかな。

モダンなPerlでも動いて、vSphere CLIのPerlでも動くユーティリティを書くのは、意外に厄介だ。どこかで行き詰ったら、早々にどちらかに絞るか、2バージョン書いてしまうことをお勧めする。

4
4
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
4
4