/** * deletes a vm * * @api * * @param int $vm_id vm id * * @return bool on success TRUE/FALSE */ function ace_vm_delete($vm_id) { $lab_id = ace_db_vm_get_lab_id($vm_id); $lab_active = ace_lab_is_active($lab_id); if ($lab_active) { $virt_vm_is_active = ace_virt_vm_get_state($vm_id) == 1 ? TRUE : FALSE; if ($virt_vm_is_active) { ace_virt_vm_deactivate($vm_id); } ace_virt_vm_delete($vm_id); } $cdrom_table = ace_db_vm_get_cdrom_table($vm_id); foreach ($cdrom_table as $cdrom) { ace_db_vm_detach_cdrom($vm_id, $cdrom['instance']); } $disk_table = ace_db_vm_get_disk_table($vm_id); foreach ($disk_table as $disk) { ace_db_vm_detach_disk($vm_id, $disk['instance']); } $nic_table = ace_db_vm_get_nic_table($vm_id); foreach ($nic_table as $nic) { ace_db_vm_detach_nic($vm_id, $nic['instance']); } $success = ace_db_vm_delete($vm_id); return $success ? TRUE : FALSE; }
<!-- </div> </div>--> <?php // } // } ?> <!-- <div class="clear"></div> </div> --> <!-- END VM HEADER ROW SECTION--> <!-- BEGIN VM DETAIL SECTION --> <!-- any number of vertical divs here depending on number of vms --> <div id="lab_vm" class="element_table"> <?php $lab_state = ace_lab_is_active($lab_id); $lab_vm_table = ace_lab_get_vm_table($lab_id); foreach ($lab_vm_table as $vm) { if ($vm['user_visible'] == 1) { $vm_id = $vm['id']; $vm_active = $vm['state'] == 1 ? TRUE : FALSE; if ($lab_state) { $virt_vm_active = ace_vm_get_virt_state($vm_id); if (!$virt_vm_active && $vm_active) { $db_success = ace_vm_deactivate($vm_id); $vm['state'] = 0; $vm_active = FALSE; } if ($virt_vm_active && !$vm_active) { $db_success = ace_vm_activate($vm_id); $vm['state'] = 1;