perl - Perl VMOMI 找不到通过 SOAP VSphere API 获取 VmwareTools 状态的方法
问题描述
我尝试从 Perl 的 VMOMI 模块中获取特定 VM 的 VmWare 工具状态,但我不知道该怎么做。
我尝试了什么:
use strict; use warnings;
use VMOMI;
use Data::Dumper;
my $host = 'vcenter1.example.com',
my $user = 'myuser';
my $pass = 'STRONG';
my $stub = new VMOMI::SoapStub(host => $host) || die "Failed to initialize VMOMI::SoapStub";
my $instance = new VMOMI::ServiceInstance(
$stub,
new VMOMI::ManagedObjectReference(
type => 'ServiceInstance',
value => 'ServiceInstance',
),
);
# Login
my $content = $instance->RetrieveServiceContent;
my $session = $content->sessionManager->Login(userName => $user, password => $pass);
my $vm = new VMOMI::VirtualMachineToolsRunningStatus(
$stub,
new VMOMI::VirtualMachineToolsRunningStatus(
type => 'VirtualMachine',
value => 'vm-name-foobar'
)
);
use Data::Dumper;
print Dumper $vm;
# Logout
$content->sessionManager->Logout();
我有一个密钥service_version
,但我猜它是远程 VSphere 服务器的版本。
有什么线索吗?我没有任何 vmware 工具状态,这就是我要找的。
我想我不明白如何使用VirtualMachineToolsRunningStatus
类:/
解决方案
pythonpyvmomi
有更好的文档记录。
检查https://github.com/vmware/pyvmomi并有一个示例脚本来测试 vmware 工具https://github.com/vmware/pyvmomi-community-samples.git
python list_vmwaretools_status.py
像魅力一样工作!
推荐阅读
- node.js - 为什么我的 rpm 安装后文件丢失了?
- android - 动态更改 BottomNavigationView 内嵌套导航图的 startDestination
- firebase - Firestore:如何计算读取?
- java - 下面的模式代码没有按预期工作
- angular - 删除数组Typescript Angular中的选定对象
- bootstrap-4 - 在导航栏下,我需要类似小字体的东西自动化你的工作。请帮助我,我是引导程序的新手
- pycharm - Pycharm的注释/取消注释命令
- sql - TIBCO MDM 目录冲突
- bundle - Symfony 5 可重用捆绑配置 TreeBuilder:路径的无效类型
- python-3.x - pip 不构建 .so 文件