feldsam-inc/one-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

feldsam-inc/one-php

最新稳定版本:1.4.2

Composer 安装命令:

composer require feldsam-inc/one-php

包简介

OpenNebula XML-RPC API Bindings

README 文档

README

Latest Stable Version Total Downloads License

This library provides you with XML-RPC client, which parses XML responses to an array.
You can traverse over it by using dot notation.
We generated all public methods from api.rst file.

Check example method with doc block. For more, check src/One.php

/**
 * Retrieves information for all or part of the VMs in the pool.
 *
 * @param int $a Filter flag  -4: Resources belonging to the user's primary group  -3: Resources belonging to the user  -2: All resources  -1: Resources belonging to the user and any of his groups * >= 0: UID User's Resources
 * @param int $b When the next parameter is >= -1 this is the Range start ID. Can be -1. For smaller values this is the offset used for pagination.
 * @param int $c For values >= -1 this is the Range end ID. Can be -1 to get until the last ID. For values < -1 this is the page size used for pagination.
 * @param int $d VM state to filter by.
 * @param string $e Filter in KEY=VALUE format.
 * @return \One\Resource
 */
public function vmpoolInfoextended(int $a, int $b, int $c, int $d, string $e) {
    return $this->makeCall('one.vmpool.infoextended', $a, $b, $c, $d, $e);
}

Your IDE will use this doc blocks, and you have handy documentation inside code. No need to look into official docs page.

Examples

Connect to API, create client instance

$client = new \One\One('http://{IP}:2633/RPC2', 'username:password');

Call some method and get response - \One\Resource class instance

try {
    $response = $client->vmpoolInfoextended(-1, -1, -1, -1, '');
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
    exit(1);
}

Work with response
\One\Resource class instance is wrapper over adbario/php-dot-notation

$vms = $response->get('VM');

echo "Total number of VMs is " , $vms->count() , "\n";

foreach($vms->all() as $vm) {
    if (!$vm->isEmpty('USER_TEMPLATE.LABELS')) {
        echo "VM ID ", $vm->get('ID'), " has label(s): ", $vm->get('USER_TEMPLATE.LABELS'), "\n";
    } else {
        echo "VM ID ", $vm->get('ID'), " doesn't have any labels.\n";
    }
}

Index result array by specific subkey

$vms = $response->getIndexedBy('ID', 'VM');
// get VM with ID 2403
$vm = $vms->get(2403);

Working with ACL rules

Understanding ACL Rules

// user readable acl rule
$aclRule = '@131 DATASTORE/%100 USE #0';

// parse rule to hex numbers
list($user, $resource, $rights, $zone) = \One\Acl::parseRule($aclRule);

// use hex in api call
$client->aclAddrule($user, $resource, $rights, $zone);

Development

To contribute bug patches or new features, you can use the github Pull Request model. It is assumed that code and documentation are contributed under the Apache License 2.0.

More info:

Authors

Support

FeldHost™ as OpenNebula Contributor offers design, implementation, operation and management of a cloud solution based on OpenNebula.

统计信息

  • 总下载量: 499
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2020-09-19