[英]How do I run/test the VMware Perl SDK with ESXi 5.1?
Does any one know of the specifics for running Perl scripts against an VMware ESXi 5.1
server that I have at home? 有没有人知道我在家里使用
VMware ESXi 5.1
服务器运行Perl脚本的细节? I have downloaded the following and installed the packages on a Ubuntu 12.04 LTS
machine but I don't know how to get started. 我已下载以下内容并在
Ubuntu 12.04 LTS
机器上安装了这些软件包,但我不知道如何开始使用。
VMware-vSphere-CLI-5.1.0-780721.x86_64.gz
VMware的的vSphere-CLI-5.1.0-780721.x86_64.gz
VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.gzVMware的的vSphere Perl的-SDK-5.1.0-780721.x86_64.gz
VMware-vSphere-SDK-5.1.0-774886.zipVMware-vSphere-SDK-5.1.0-774886.zip
When packages were installed, I ensured that all the Perl module dependencies were met. 安装软件包时,我确保满足所有Perl模块依赖项。 What do I do next?
接下来我该怎么办? Eg How would I just query for a list of VMs running on the ESXi server in Perl?
例如,我如何查询Perl中ESXi服务器上运行的VM列表?
Check the code below to get the VM names: 检查下面的代码以获取VM名称:
#!/usr/bin/perl -w
use strict;
use VMware::VIRuntime;
my %opts = (
datacenter => {
type => "=s",
help => "Enter the Dacenter Name",
required => 1,
},
);
Opts::add_options(%opts);
Opts::parse();
Opts::validate();
Util::connect();
my $dc = Opts::get_option("datacenter");
my $datacenter = Vim::find_entity_view ( view_type => "Datacenter",
properties => [ "name" ],
filter => { name => $dc },
);
my $vms = Vim::find_entity_views ( view_type => "VirtualMachine",
properties => [ "name" ],
begin_entity => $datacenter,
);
foreach my $vm ( @$vms )
{
print $vm->name."\n";
}
Util::disconnect();
Run above script as below: 运行以上脚本如下:
perl vm_list.pl --server <vCenter_server_name> --datacenter <Datacenter_name>
Of course above code wont make any sense to you unless you read vSphere perl SDK documentation. 当然,除非您阅读vSphere perl SDK文档,否则上面的代码对您没有任何意义。 refer below links to get you started:
为了帮助您入门,请参阅以下链接:
sample code with explantion of vpshere objects: http://www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_guide_idx.html 示例代码以及vpshere对象的说明: http : //www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_guide_idx.html
API reference Guide: http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html API参考指南: http : //pubs.vmware.com/vsphere-50/index.jsp?topic =%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html
client Object: http://pubs.vmware.com/vi301/admin/wwhelp/wwhimpl/common/html/wwhelp.htm?context=admin&file=BSA_Inventory.9.2.html 客户端对象: http : //pubs.vmware.com/vi301/admin/wwhelp/wwhimpl/common/html/wwhelp.htm?context=admin&file=BSA_Inventory.9.2.html
General API docs: http://www.vmware.com/support/developer/viperltoolkit/ 常规API文档: http : //www.vmware.com/support/developer/viperltoolkit/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.