Ejemplo n.º 1
0
/**
 * delete a volume
 *
 * @param   int $volume_id volume id
 *
 * @return bool                 on success TRUE/FALSE
 */
function ace_db_volume_delete($volume_id)
{
    # remove volume from vms first
    $sql = "SELECT *\n            FROM vdisk\n            WHERE volume_id={$volume_id}";
    $db_result = ace_db_query($sql);
    if ($db_result->row_count > 0) {
        foreach ($db_result->table as $row) {
            ace_db_vm_detach_disk($row['vm_id'], $row['instance']);
        }
    }
    $sql = "DELETE\n            FROM volume\n            WHERE id={$volume_id}";
    $db_result = ace_db_query($sql);
    return $db_result->row_count > 0 ? TRUE : FALSE;
}
Ejemplo n.º 2
0
/**
 * 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;
}