Download the PHP package macromindonline/xenapi without Composer
On this page you can find all versions of the php package macromindonline/xenapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download macromindonline/xenapi
More information about macromindonline/xenapi
Files in macromindonline/xenapi
Package xenapi
Short Description A Xen PHP API for managment of Hypervisor and their Virtual Machine for php
License MIT
Informations about the package xenapi
Xenapi for PHP
A Xen PHP API for managment of Hypervisor and Citrix Server and their Virtual Machines for PHP, it works on Laravel 4, Laravel 5, Codeigniter and other PHP framework. Before install this library make sure to have installed xmlrpc php module
API in PHP to communicate with Xen Server . This packages is available on Composer's repositories . The package Allows to completely Manage an Hypervisvor Citrix . With this , you can clone , start , stop and reboot any VPS of your Hypervisor Also, this APi allow you toi have a realtime graph of your Hypervisor's VPS! I've create the Method that obtain XML realtime stats of Machine and convert it to RRD file, needed for the FlotJS library to draw the graph. This API is available for all the major PHP Frameworks, such as Laravel, Symfony or Codeigniter.
Table Of Contents
- Installation
- Documentation
- Namespace Import
- Connect With an Hypervisor
- Get Virtual Machine
- Virtual Machine Managment
- Get Host
- Host Management
- Response Management
- Exceptions
Installation :
Package is available on Packagist, you can install it using Composer.
In the require key of composer.json file add the following:
Or type this command from your project folder
Documentation:
Namespace Import
Sircamp\Xenapi is namespaced, but you can make your life easier by importing a single class into your context:
Connect With an Hypervisor
Make sure that you have IP, User and Password of your hypervisor:
Get Virtual Machine
This serves to have a virtual machine (by the hostname) that is on selected hypervisor :
Virtual Machine Management
Now you have the an XenVirtualMachine object that map your virtual machine, so we are ready to manage the VM
Start VM
This method starts a stopped VM
You can, also, pass two parameters at this method:
StartOn VM
This method starts the specified VM on a particular host. This function can only be called with the VM is in the Halted State. This method needs an XenHost object as parameter, but if you want you can pass a UUID host string
Shutdown VM
This method sends a shutdown command to the Virtual Machine
Hard Shutdown VM
This method immediatly a shutdown the Virtual Machine
Reboot VM
This method sends a reboot command to the Virtual Machine
Hard Reboot VM
This method immediatly restarts the Virtual Machine
Suspend VM
This method puts Virtual Machine in a suspend mode (read the Citrix manual)
Resume VM
This method resumes a Virtual Machine that is in a suspend mode (read the Citrix manual)
ResumeOn VM
This method awaken the specified VM and resume it on a particular Host. This can only be called when the specified VM is in the Suspended state. This method needs an XenHost object as parameter, but if you want you can pass a UUID host string
Pause VM
This method puts a Virtual Machine in pause
Unpause VM
This method restores a Virtual Machine that is in pause
Clone VM
This method clones the selected Virtual Machine into another ( please check if your hypervisor supports another machine).
before this, you must stop the virtual machine that you want clone
Power Status of VM
This method gets the power status of the selected Virtual Machine
Power State Reset of VM
Reset the power-state of the VM to halted in the database only. (Used to recover from slave failures in pooling scenarios by resetting the power-states of VMs running on dead slaves to halted.) This is a potentially dangerous operation; use with care.
UUID of VM
This method obtains the UUID of the selected Virtual Machine.
Consoles of VM
This method returns the all console instances of selected Virtual Machine. The console istance allows you to have and manage a SSH or RDP session of Virtual Machine
UUID of VM Console
This method returns the UUID of selected Virtual Machine's console. The UUID is very usefull for console istance mangement.
Guest Metrics of VM
This method returns the guest metrics of selected Virtual Machine. This metrics contains:
- uuid
- os_version (name, uname, distro, relase version)
- memory
- disks
- networks
- other
in the future, i will write an example
Metrics of VM
This method returns the metrics of selected Virtual Machine. This metrics contains:
- uuid
- memory_actual
- VCPUs_number
- VCPUs_utilisation
as for guest metrics, in the future, i will write an example
Statistics of VM
This method returns the current stats of the running selected Virtual Machine. With this method, you can obtain the stats of CPUs, RAM and DISK I/O in realtime!
However, this method return an response object that contains a XML string in the value attribute. Inside this XML string you find the required statistics.
as for last two methods, in the future, i will write an example. Also, i would to show you how to obtain a realtime stats graph, stay tuned ;)
Disks Total Space of VM
This method returns the total amount of Virtual Machine's Disks space. Actually this method return the total in bytes.
Also, you can pass an argument:
This allow you to have the disk space in the format as you want. NB: this feature is not yet implemented
Name of VM
This method returns the name of VM
GetAll VMs
This method returns a list of all the VMs known to the system.
PoolMigrate VM
Migrate a VM to another Host. This can only be called when the specified VM is in the Running state. This method needs an XenHost object as parameter, but if you want you can pass a UUID host string The optionsMap parameter is a map that contains the options for pool migrating.
MigrateSend VM
Assert whether a VM can be migrated to the specified destination. In this method the first parameter, dest, is the result of a Host.migrate receive call. The vdiMap parameter is the map of source VDI to destination SR. The vifMap parameter is the map of VIF to destination network. The optionsMap Extra configuration operations. The live parameter allows to migrate the VM in live mode or nothing, on default this paramter is set to false.
NB: this method is still in testing mode
AssertCanMigrate VM
Assert whether a VM can be migrated to the specified destination. In this method the first parameter, dest, is the result of a Host.migrate receive call. The vdiMap parameter is the map of source VDI to destination SR. The vifMap parameter is the map of VIF to destination network. The optionsMap Extra configuration operations. The live parameter allows to migrate the VM in live mode or nothing, on default this paramter is set to false.
NB: this method is still in testing mode
Snapshot of VM
Snapshots the specified VM, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM’s disk images are stored
Snapshot of VM
Snapshots the specified VM with quiesce, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM’s disk images are stored
GetSnapshot of VM
Get the snapshot info field of the given VM.
Revert of VM
Reverts the specified VM to a previous state
Copy VM
Copied the specified VM, making a new VM. Unlike clone, copy does not exploits the capabilities of the underlying storage repository in which the VM’s disk images are stored. Instead, copy guarantees that the disk images of the newly created VM will be ’full disks’ - i.e. not part of a CoW chain. This function can only be called when the VM is in the Halted State
Destroy VM
Destroy the specified VM. The VM is completely removed from the system. This function can only be called when the VM is in the Halted State.
Checkpoints of VM
Checkpoints the specified VM, making a new VM. Checkpoint automatically exploits the capabil-ities of the underlying storage repository in which the VM’s disk images are stored (e.g. Copy on Write) and saves the memory image as well
SetStartDelay of VM
Set this VM’s start delay in seconds.
SetShutdownDelay of VM
Set this VM’s start delay in seconds.
GetStartDelay of VM
Get this VM’s start delay in seconds.
GetShutdownDelay of VM
Get this VM’s start delay in seconds.
GetCurrentOperations of VM
Get the current operations field of the given VM.
GetAllowedOperations of VM
Get the allowed operations field of the given VM.
GetNameDescription of VM
Get the name/description field of the given VM.
SetNameDescription of VM
Set the name/description field of the given VM.
GetIsATemplate of VM
Get the is a template field of the given VM.
SetIsATemplate of VM
Set the is a template field of the given VM.
GetResidentOn of VM
Get the resident on field of the given VM. In the response of this method you’ll find a XenHost object that you can use.
GetPlatform of VM
Get the platform field of the given VM.
SetPlatform of VM
Set the platform field of the given VM.
GetOtherConfig of VM
Get the other config field of the given VM.
SetOtherConfig of VM
Set the other config field of the given VM.
AddToOtherConfig of VM
Set the other config field of the VM given key-value pair to the other config field of the given vm.
RemoveFromOtherConfig of VM
Remove the given key and its corresponding value from the other config field of the given vm. If the key is not in that Map, then do nothing.
GetNameLabel of VM
Get name label VM.
Get Host
This serves to obtain the target host (by the hostname) :
Host Management
Now you have the an XenHost object that map your hypervisor, so we are ready to manage the HOST
Disable HOST
Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute.
Enable HOST
Puts the host into a state in which new VMs can be started.
Shutdown HOST
Shutdown the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.).
Reboot HOST
Reboot the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.).
Dmesg of HOST
Get the host xen dmesg.
DmesgClear of HOST
Get the host xen dmesg, and clear the buffer
GetLog of HOST
Get the host’s log file.
ListMethods of HOST
List all supported methods.
LicenseApply of HOST
Apply a new license to a host. The default value of $license is an empty string
NB: $license must be an base64 encoded file
AssertCanEvacuate HOST
Check this host can be evacuated.
Evacuate HOST
Migrate all VMs off of this host, where possible.
GetServerTime of HOST
This call queries the host’s clock for the current time.
GetServerLocaltime of HOST
This call queries the host's clock for the current time in the host’s local timezone.
GetServerCertificate of HOST
Get the installed server SSL certificate.
NB: This method returns the SSL certificate in .pem format
ApplyEdition of HOST
Change to another edition, or reactivate the current edition after a license has expired. This may be subject to the successful checkout of an appropriate license. Default $force param is false, this means which you want force an update edition.
RefreshPackInfo of HOST
Refresh the list of installed Supplemental Packs.
EnableLocalStorageCaching of HOST
Enable the use of a local SR for caching purposes.
DisableLocalStorageCaching of HOST
Disable the use of a local SR for caching purposes.
MigrateReceive of HOST
Prepare to receive a VM, returning a token which can be passed to VM->migrate(). The $features is an associative array that cotains the configuration value that you need to run the migrating machine, it default value is an empty array.
GETUUID of HOST
Get the uuid field of the given host.
GetNameLabel of HOST
Get the name/label field of the given host.
SetNameLabel of HOST
Set the name/label field of the given host.
GetNameDescription of HOST
Get the name/description field of the given HOST.
SetNameDescription of HOST
Set the name/description field of the given HOST.
SetNameDescription of HOST
Set the name/description field of the given HOST.
GetAllowedOperations of HOST
Get the allowed operations field of the given HOST.
GetSoftwareVersion of HOST
Get the software version field of the given host.
GetOtherConfig of HOST
Get the other config field of the given HOST.
SetOtherConfig of HOST
Set the other config field of the given HOST.
AddOtherConfig of HOST
Add the given key-value pair to the other config field of the given host.
RemoveOtherConfig of HOST
Remove the given key and its corresponding value from the other config field of the given host. If the key is not in that Map, then do nothing.
GetSupportedBootloaders of HOST
Get the supported bootloaders field of the given host.
GetResidentVMs of HOST
Get the resident VMs field of the given host. In the response of this method you'll find, if there exists at least a VM inside this Host, an array of VMs object that you can use.
GetPatches of HOST
Get the patches field of the given host.
GetHostCPUs of HOST
Get the host CPUs field of the given host.
GetCPUInfo of HOST
Get the cpu info field of the given host.
GetHostname of HOST
Get the hostname of the given host.
SetHostname of HOST
Set the hostname of the given host.
GetAddress of HOST
Get the address field of the given host.
SetAddress of HOST
Set the address field of the given host.
GetMetrics of HOST
Get the metrics field of the given host.
GetLicenseParam of HOST
Get the license params field of the given host.
GetEdition of HOST
Get the edition field of the given host.
GetLicenseServer of HOST
Get the license server field of the given host.
SetLicenseServer of HOST
Set the license server field of the given host.
AddToLicenseServer of HOST
Add the given key-value pair to the license server field of the given host.
RemoveFromLicenseServer of HOST
Remove the given key and its corresponding value from the license server field of the given host. If the key is not in that Map, then do nothing.
GetChipsetInfo of HOST
Get the chipset info field of the given host.
Response Management
Every method return an istance of XenResponse class. This object contains three attributes:
- Value
- Status
- ErrorDescription
Value attribute
This attribute contains the value of response, sach as message, XML string or something else.
use this method to obtain it:
Status attribute
This attribute contains the status of response. If status is Success the request is OK. Otherwise is request is KO, use this for check the result of your operations
use this method to obtain it:
ErrorDescription attribute
This attribute contains message of KO response. Just take the value of this attribute and check why the response isn't OK.
For example if your connection credentials are wrong:
Exceptions
This is exaplained the custom excetions
XenConnectionException
This exception is launched when you try to connect to a hypervisor with a wrong credentials.
To catch this exception, remember to use the namespace of this class: