Manage Virtual machines and hosts in GLPI¶
Step one : VM in GLPI done.
Enhancements : see VirtualMachines_enhancements : to be discussed
Database changes¶
- add uuid field in glpi_computers VARCHAR (255)
- add import_vm field in glpi_ocslinks LONGTEXT
- add import_vms & import_general_uuid fields in glpi_ocsservers TINYINT (1)
//VM Type : VirtualBox, Vmware, etc. CREATE TABLE `glpi_virtualmachinetypes` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `comment` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM ; //VM Subsystem : Vmware Fusion, ESX, ESXI, etc. CREATE TABLE `glpi_virtualmachinesystems` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `comment` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM ; //Vm states : running, stopped, etc. CREATE TABLE `glpi_virtualmachinestates` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `comment` TEXT NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM ; //Virtual machines CREATE TABLE `glpi_computervirtualmachines` ( `id` INT NOT NULL AUTO_INCREMENT , `entities_id` INT( 11 ) NOT NULL DEFAULT '0', `computers_id` INT( 11 ) NOT NULL DEFAULT '0', `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `virtualmachinetypes_id` INT( 11 ) NOT NULL DEFAULT '0', `virtualmachinestates_id` INT( 11 ) NOT NULL DEFAULT '0', `virtualmachinesystems_id` INT( 11 ) NOT NULL DEFAULT '0', `virtualmachinetypes_id` INT( 11 ) NOT NULL DEFAULT '0', `uuid` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `vcpu` INT( 11 ) NOT NULL DEFAULT '0', `ram` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY ( `id` )
Objects¶
Add object : ComputerVirtualmachine extends CommonDBChild
OCS synchronization¶
OCS 1.3.x has a table called virtualmachines :
CREATE TABLE IF NOT EXISTS `virtualmachines` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `HARDWARE_ID` int(11) NOT NULL, `NAME` varchar(255) DEFAULT NULL, `STATUS` varchar(255) DEFAULT NULL, `SUBSYSTEM` varchar(255) DEFAULT NULL, `VMTYPE` varchar(255) DEFAULT NULL, `UUID` varchar(255) DEFAULT NULL, `VCPU` int(11) DEFAULT NULL, `MEMORY` int(11) DEFAULT NULL, PRIMARY KEY (`ID`,`HARDWARE_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Import data into GLPI¶
- Import data from the ocsweb.virtualmachine table into glpi_computervirtualmachines
- Create method OcsServer::updateVirtualMachines()
- Add uuid synchronization in OCsServer::update:hardhware (uuid is in ocsweb.hardware table)
Link between vms and hosts¶
For Vmware ESX and VirtualBox make link on uuid
For other systems (solaris, aix), it might not be the case. It's better to use macaddress
Walid : create a specific rules engine for it ? Maybe a first step would be to link on uuid and then add the rules engine in an upcoming version ?
Association between an host and a vm is done using a function ie at runtime (no association in DB)
Entity visibility¶
Walid : A host can host virtualmanchines located in several entities. Should the computers be recursive ?
Remi : I don't think this is mandatory as this is not a true "relation"- List will display all VM, with a link to computer according to user right.
- adding a new VM could propose an UUID dropdown with all visible values for the use (in all entities) OR a test field (when addding a VM which doesn't exist yet).
Rights¶
Use 'computer' rights, as for ComputerDisk
Discussions¶
Pour le champ : Etat de la machine virtuelle, avec l'agent fusion, le champ remonte en anglais - type : running, off. Peut-ĂȘtre faudrait -il penser a faire une dictionnaire pour nettoyer lors de l'import.