This commit is contained in:
2018-09-28 17:01:56 +08:00
Unverified
2 changed files with 34 additions and 2 deletions
+16
View File
@@ -10,6 +10,8 @@ This project is to make it easier for developers to manage virtual machines.
You need install php_ssh2 module to use this manager.
Maybe this document has some grammatical mistakes, because the author is Chinese :P
### Example code for connect a server
```php
@@ -78,4 +80,18 @@ This method can get any registered virtual machine xml config file and return.
```php
String dumpxml ( Name )
```
#### Clone an exist virtual machine
You can use this method to clone a exist virtual machine.
This method may take a long time, you need add a line `set_time_limit(120)` in your code.
```php
String cloneVM ( Name, New name, New disk path )
```
#### Set the virtual machine network
This method can control the virtual machine network.
The third param is Boolean type, if you give it a true value, the network will enable, else the network will disable.
```php
String setNetwork ( Server, Network name, Status )
```
You can find out more info in `libvirt/libvirt.php`
+18 -2
View File
@@ -7,6 +7,8 @@
你需要安装 PHP_SSH2 模块来使用此管理器。
唔...第一次写英文 ReadMe,英文很蹩脚,请不要在意...嘤嘤嘤
### 连接到服务器的示例代码
```php
@@ -35,9 +37,9 @@ $Libvirt->start("Test");
String createDisk ( Name, Format, Size )
```
#### 创建一个虚拟机 XML 配置文件
The method of createVMXML have 13 args.
createVMXML 方法一共有 13 个参数
```php
void createVMXL ( Name, vCPU, Ram, Disk, ISO, Boot Device, Network type, Network name, MAC Address, Network bridge, Bandwidth in, Bandwidth out, VNC Port )
void createVMXML ( Name, vCPU, Ram, Disk, ISO, Boot Device, Network type, Network name, MAC Address, Network bridge, Bandwidth in, Bandwidth out, VNC Port )
```
#### 将虚拟机 XML 配置文件注册到系统
```php
@@ -75,4 +77,18 @@ String getInfo ( Name )
```php
String dumpxml ( Name )
```
#### 克隆现有的虚拟机
你可以使用此方法复制一个现有的虚拟机
此方法也许需要消耗很长时间,具体视磁盘性能而定,建议加一行代码 `set_time_limit(120)` 以防止脚本超时。
```php
String cloneVM ( Name, New name, New disk path )
```
#### 设置虚拟机网卡
此方法可以设置虚拟机的网卡
第三个参数是布尔型的,如果赋值是 true,将会启用网卡,如果赋值是 false,将会禁用网卡。
```php
String setNetwork ( Server, Network name, Status )
```
你可以在 `libvirt/libvirt.php` 找到更多信息