sulochanatutorials / vmware-client
VMWare的PHP API客户端
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.0.1
- illuminate/contracts: ^8.0|^9.0|^10.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^6.1
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-15 09:41:26 UTC
README
VMWare的PHP API客户端
安装
使用composer安装此包:
composer require VmWare-ag/vmware-php-client
使用以下命令发布配置文件:
php artisan vendor:publish --tag="vmware-php-client-config"
return [ 'session_ttl' => env('VMWARE_SESSION_TTL', 10), 'enable_logs' => env('VMWARE_ENABLE_LOGS', true), ];
入门
创建到您的虚拟化机的连接,以便您可以调用方法
$vcenterClient = new VmWare\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword' ); $vmInfo = $vcenterClient->getVmInfo('vm-123');
此库可以运行在三种模式下:rest
、soap
和both
。默认情况下,它以rest
模式运行,但您可以在构造函数中设置其他模式
$vcenterClient = new VmWare\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', 'soap' );
我们仍然建议使用常量
$vcenterClient = new VmWare\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', VmWare\VmWareClient\VcenterClient::MODE_SOAP );
rest
模式
使用rest
模式,您可以使用REST方法,您可以在VMWare API开发者中心中找到这些方法。目前,库中只有一些方法可用。您可以在vendor/VmWare-ag/vmware-php-client/src/Traits/Rest
文件夹中找到完整的方法列表。
我们计划稍后添加完整的方法列表。
soap
模式
使用soap
模式允许您使用您可以在VMWare SOAP开发者中心中找到的SOAP方法。目前,库中只有一些方法可用。您可以在vendor/VmWare-ag/vmware-php-client/src/Traits/SOAP
文件夹中找到完整的方法列表。
我们计划稍后添加完整的方法列表。
这是如何进行第一次SOAP调用的示例
$folder = $vcenterClient->soap->createFolder('group-v3', 'foldername');
如果您想同时使用这两种模式,可以设置both
模式(VmWare\VmWareClient\VcenterClient::MODE_BOTH)。 如果您想运行库中找不到的自定义soap
方法,可以直接运行此方法
$vcenterClient = new VmWare\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', VmWare\VmWareClient\VcenterClient::MODE_SOAP ); $taskInfo = $vcenterClient->soap->request('ReconfigureComputeResource_Task', [ '_this' => [ '_' => 'domain-c33', 'type' => 'ComputeResource', ], 'spec' => [ '@type' => 'ClusterConfigSpecEx', 'drsConfig' => [ '@type' => 'ClusterDrsConfigInfo', ], 'rulesSpec' => [ '@type' => 'ClusterRuleSpec', 'operation' => 'add', 'info' => [ '@type' => 'ClusterAntiAffinityRuleSpec', 'enabled' => true, 'name' => 'VM-VM Affinity rule', 'userCreated' => true, 'vm' => [ ['_' => 'vm-133', 'type' => 'VirtualMachine'], ['_' => 'vm-134', 'type' => 'VirtualMachine'] ] ], ], 'dpmConfig' => [ '@type' => 'ClusterDpmConfigInfo', ], ], 'modify' => false, ])
参数的顺序非常重要。您可以在文档中的每个对象类型的
WSDL类型定义
部分中找到正确的顺序。
致谢
问题和反馈
如果您对设置有问题或只想与开发者聊天,请随时联系 a.hazhur@bitcat.agency。
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。