Ejemplo n.º 1
0
/**
 * deletes a lab
 *
 * @api
 *
 * @param   int $lab_id lab id
 *
 * @return  bool                    on success TRUE/FALSE
 */
function ace_lab_delete($lab_id)
{
    if (ace_lab_is_active($lab_id)) {
        ace_lab_deactivate($lab_id);
    }
    $lab_group_ids = ace_lab_get_group_ids($lab_id);
    if (is_array($lab_group_ids)) {
        foreach ($lab_group_ids as $group_id) {
            ace_group_remove_lab($group_id, $lab_id);
        }
    }
    $vm_table = ace_db_lab_get_vm_table($lab_id);
    foreach ($vm_table as $vm) {
        $cdrom_table = ace_db_vm_get_cdrom_table($vm['id']);
        foreach ($cdrom_table as $cdrom) {
            ace_db_vm_detach_cdrom($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($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($nic['vm_id'], $nic['instance']);
        }
        ace_db_vm_delete($vm['id']);
    }
    $volume_table = ace_db_lab_get_volume_table($lab_id);
    foreach ($volume_table as $volume) {
        ace_db_volume_delete($volume['id']);
    }
    $network_table = ace_db_lab_get_network_table($lab_id);
    foreach ($network_table as $network) {
        ace_db_network_delete($network['id']);
    }
    return ace_db_lab_delete($lab_id);
}
Ejemplo n.º 2
0
         $old_lab_display_name = ace_lab_get_display_name_by_id($lab_id);
         $new_lab_display_name = $_POST['lab_display_name'];
         if ($old_lab_display_name != $new_lab_display_name) {
             $success = ace_lab_rename($lab_id, $new_lab_display_name);
             $message = create_message($success, "renaming lab '{$old_lab_display_name}' to '{$new_lab_display_name}'");
         } else {
             $message = create_message(FALSE, 'renaming lab, name did not change');
         }
     } else {
         $message = create_message(FALSE, 'renaming lab, no lab_id specified');
     }
     break;
 case 'lab_unpublish':
     if (isset($lab_id)) {
         if (ace_lab_is_published($lab_id)) {
             $lab_group_ids = ace_lab_get_group_ids($lab_id);
             $group_count = count($lab_group_ids);
             if ($lab_group_ids !== FALSE) {
                 foreach ($lab_group_ids as $group_id) {
                     ace_group_remove_lab($group_id, $lab_id);
                 }
                 $messages[] = create_message(TRUE, 'un-publishing lab, lab was unpublished from ' . $group_count . ' group(s)');
             } else {
                 $messages[] = create_message(FALSE, 'un-publishing lab, lab was marked as published but no published groups were found');
             }
         } else {
             $messages[] = create_message(FALSE, 'un-publishing lab, lab was not published');
         }
     } else {
         $messages[] = create_message(FALSE, 'un-publishing lab, no lab_id apecified');
     }