2 つの「物理」ESX があり、どちらも vSphere Server が主導しているとします。私がやろうとしているのは、指定された VM にファイルをアップロードするスクリプトを実行することです。したがって、基本的には、VMWare コミュニティによって提供される VIFS.pl スクリプトを使用します。 .ref.doc%2Fvifs.htmlにアクセスし、コード ソースはhttp://communities.vmware.com/docs/DOC-10774にあります。
ソースコードは非常に単純でhttp_put_file()
、モジュールの関数を使用するだけVIExt
で、この関数は実際には失敗します。エラー 500 が表示されるためです。ログはここにあります (印刷して取得しました$resp->as_string()
)。
do_put() 関数
sub do_put {
my ($local_source, $remote_target, $datacenter) = @_;
my ($mode, $dc, $ds, $filepath) = VIExt::parse_remote_path($remote_target);
# bug 322577
if (defined $local_source and -d $local_source) {
VIExt::fail("Error: File to be uploaded cannot be a folder.");
}
# bug 266936
unless (-e $local_source) {
VIExt::fail("Error: File $local_source does not exist.");
}
my $resp = VIExt::http_put_file($mode, $local_source, $filepath, $ds, $datacenter);
# bug 301206
print $resp->as_string(); # => Trace
if ($resp && $resp->is_success) {
print "Uploaded file $local_source to $filepath successfully.\n";
} else {
print "Failed to upload !";
}
}
** 痕跡 **
# vSphere server : @192.168.20.2
# Datastore : nfs
# Datacenter : dc
# Target VM name : target_vm
# Target filename : VM.txt
>> perl vifs --server 192.168.20.2 --username root --password root -p "/tmp/foo.txt" "[nfs] target_vm/VM.txt" -Z "dc"
HTTP/1.1 500 Internal Server Error
Connection: close
Date: Thu, 6 Dec 2012 10:32:30 GMT
Content-Length: 0
Content-Type: text; charset=plain
Client-Date: Thu, 06 Dec 2012 11:32:53 GMT
Client-Peer: 192.168.20.2:443
Client-Response-Num: 9
Client-SSL-Cert-Issuer: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./CN=localhost.localdom CA 26fc6343/emailAddress=ssl-certificates@vmware.com
Client-SSL-Cert-Subject: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./OU=VMware vCenter Server Certificate/emailAddress=ssl-certificates@vmware.com/CN=localhost.localdom/unstructuredName=1352217590,031bd875,564d7761726520496e632e
Client-SSL-Cipher: AES256-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Failed to upload !
関数で引数として渡されたすべての変数の値を確認したことに注意してくださいhttp_put_file
。それらはすべて正しいです。
誰かがこの問題を経験したことがあるなら、大歓迎です...