/** * delete a network for a given network id * * @param int $network_id network id * * @return bool on success TRUE/FALSE */ function ace_db_network_delete($network_id) { # remove network from vms first $sql = "SELECT vm_id FROM vnic WHERE network_id={$network_id}"; $db_result = ace_db_query($sql); if ($db_result->row_count > 0) { foreach ($db_result->table as $row) { ace_db_vm_detach_nic($row['vm_id'], $row['instance']); } } $sql = "DELETE FROM network WHERE id={$network_id}"; $db_result = ace_db_query($sql); return $db_result->row_count > 0 ? TRUE : FALSE; }
/** * 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; }