xelon-ag / vmware-php-client
VMWare的PHP API客户端
Requires
- php: ^7.4|^8.0|^8.1|^8.2
- ext-soap: *
- 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
- dev-main
- 0.2.2
- 0.2.1
- 0.2
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-feat/connect-network-adapter
- dev-fix/floppy-device-classes
- dev-feat/add-new-network-class
- dev-feat/add-virtual-devices
- dev-develop
- dev-fix/isset-issue
- dev-feat/import
- dev-dependabot/github_actions/actions/checkout-4
- dev-test-merge
- dev-dependabot/github_actions/dependabot/fetch-metadata-1.6.0
- dev-fix/hide-password-in-logs
- dev-feat/add-request-event
- dev-dependabot/github_actions/aglipanci/laravel-pint-action-2.3.0
- dev-php8.x-support
This package is auto-updated.
Last update: 2024-09-18 12:31:55 UTC
README
VMWare的PHP API客户端
安装
您可以通过composer安装此包:
composer require xelon-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 Xelon\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword' ); $vmInfo = $vcenterClient->getVmInfo('vm-123');
此库可以在三种模式下运行:rest
、soap
和both
。默认情况下,它以rest
模式运行,但您可以在构造函数中设置另一种模式
$vcenterClient = new Xelon\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', 'soap' );
但我们推荐使用常量
$vcenterClient = new Xelon\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', Xelon\VmWareClient\VcenterClient::MODE_SOAP );
rest
模式
使用rest
模式,您可以使用在VMWare API开发者中心中找到的REST方法。目前,库中仅提供一些方法。您可以在vendor/xelon-ag/vmware-php-client/src/Traits/Rest
文件夹中找到文件的全列表。
我们计划稍后添加方法的全列表。
soap
模式
使用soap
模式,您可以使用在VMWare SOAP开发者中心中找到的SOAP方法。目前,库中仅提供一些方法。您可以在vendor/xelon-ag/vmware-php-client/src/Traits/SOAP
文件夹中找到文件的全列表。
我们计划稍后添加方法的全列表。
以下是如何进行第一次SOAP调用的示例
$folder = $vcenterClient->soap->createFolder('group-v3', 'foldername');
如果您想同时使用两种模式,可以设置both
模式(Xelon\VmWareClient\VcenterClient::MODE_BOTH)。如果您想运行库中没有找到的自定义soap
方法,可以直接运行此方法
$vcenterClient = new Xelon\VmWareClient\VcenterClient( 'https://10.20.30.40', 'mylogin', 'mypassword', Xelon\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)。有关更多信息,请参阅许可文件。