alexisducastel/vmwarephp
Composer 安装命令:
composer require alexisducastel/vmwarephp
包简介
Vmware vSphere bindings for PHP
README 文档
README
Vmwarephp is a library containing bindings for vSphere API using PHP. You can use it to manage ESX and vCenter servers. It was inspired by other efforts of constructing vSphere bindings for other dynamically typed languages like RbvMomi for Ruby. Currently the library supports vSphere API from version 4.1 to 5.1.1.
Prerequisites
Vmwarephp requires PHP version 5.3.2 or greater with soap and ssl enabled. For more information on how to compile PHP from source and enable extensions please check: http://www.php.net/manual/en/install.php.
Installation
Vmwarephp can be installed using Composer or by cloning it from its GitHub repository.
Using Composer
You can read more about Composer and its main repository at http://packagist.org. To install Vmwarephp using Composer, first install Composer following the instructions on the Packagist home page. After that, you can define a dependency on Vmwarephp by adding the following lines to your composer.json:
{
"require": {
"vmwarephp/vmwarephp": "dev-master"
}
}
Using Git / GitHub
You can clone the latest development branch from its github repository:
git clone git://github.com/vadimcomanescu/vmwarephp.git
Usage
Vmwarephp aims to provide the least boilerplate code possibile for handling vSphere objects. The ESX/vCenter on which the operations are performed is represented by a \Vmwarephp\Vhost object. A Vhost object provides two finder methods to obtain server side ManagedObjects. The following example describes a way to collect all virtual machines from a ESX/vCenter with their config status prefetched:
$vhost = new \Vmwarephp\Vhost('vcenter:443', 'Admin', 'password');
$virtualMachines = $vhost->findAllManagedObjects('VirtualMachine', array('configStatus'));
For collecting all virtual machines with all their properties pre-fetched, which normally is a very expensive operation considering that a lot of objects need to be traversed you can do it in the following way:
$virtualMachines = $vhost->findAllManagedObjects('VirtualMachine', 'all');
You can find a given object using its server side id. For example finding a datastore with id datastore-182 with none of its properties prefetched:
$vhost = new \Vmwarephp\Vhost('vcenter:443', 'Admin', 'password');
$datastore = $vhost->findOneManagedObject('Datastore', 'datastore-182', array());
A managed object can also be found by name:
$vhost = new \Vmwarephp\Vhost('vcenter:443', 'Admin', 'password');
$datastore = $vhost->findManagedObjectByName('VirtualMachine', 'myvmname', array('configStatus'));
Managed objects can be a generic managed object represented by \Vmwarephp\ManagedObject or a user defined extension of a managed object defined in Extensions directory. Each managed object depending on its managed object reference type ('VirtualMachine', 'Datastore', etc.) can execute any of methods defined by the vSphere api on that reference type. For example taking a virtual machine snapshot can be as easy as:
$vhost = new \Vmwarephp\Vhost('vcenter:443', 'Admin', 'password');
$virtualMachine = $vhost->findOneManagedObject('VirtualMachine', 'vm-192', array());
$snapshotTask = $virtualMachine->CreateSnapshot_Task(array('name' => 'snapshot_name', 'memory' => false, 'quiesce' => false));
or considering that the VirtualMachine managed object type has a built in extension already:
$snapshotTask = $virtualMachine->takeSnapshot(array('name' => 'snapshot_name', 'memory' => false, 'quiesce' => false));
All managed object properties are defined as object accessors. You can pre-fetch all accessors when looking for the object or you can query an object property on the fly (note that we are not pre-fetching the configStatus property):
$virtualMachine = $vhost->findOneManagedObject('VirtualMachine', 'vm-192', array());
$configStatus = $virtualMachine->configStatus;
Or prefetching the configStatus:
$virtualMachine = $vhost->findOneManagedObject('VirtualMachine', 'vm-192', array('configStatus'));
As you can see working with managed objects is extremely easy. Each method supported by a managed object on the server side is mapped to a method on \Vmwarephp\ManagedObject or an extension. Properties are exposed as simple accessor methods. All data object properties are also mapped to their respective types. A full list of defined types can be found in TypeDefinitions.inc file.
You can write your own extensions by extending the \Vmwarephp\ManagedObject and adding it to Extensions directory. If you consider the extensions is really useful we can easily integrate it in the main branch. Enjoy!
alexisducastel/vmwarephp 适用场景与选型建议
alexisducastel/vmwarephp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 61 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 07 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「VMware」 「vsphere」 「bindings」 「vsphere sdk」 「vmware php」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alexisducastel/vmwarephp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alexisducastel/vmwarephp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alexisducastel/vmwarephp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
VMware vCloud SDK for PHP - patched version
Vmware vSphere bindings for PHP
PHP library for interacting with the VMware Rest API.
VMware vCloud SDK for PHP - patched version (Forked from Purple-DBU)
MyAdmin VMware VPS provisioning plugin - integrates VMware hypervisor management with the MyAdmin billing and service platform
VMware vCloud SDK for PHP
统计信息
- 总下载量: 61
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-07-30