Exemple #1
0
/**
 * activates a lab (deploys to a host)
 *
 * @api
 *
 * @param   int $lab_id lab id
 *
 * @return  bool                    on success TRUE/FALSE
 */
function ace_lab_activate($lab_id)
{
    # only if user has no active labs (i.e. must deactivate other labs first)
    $user_id = ace_lab_get_user_id($lab_id);
    $user_lab_table = ace_user_get_lab_table($user_id);
    $another_user_lab_is_active = FALSE;
    foreach ($user_lab_table as $lab) {
        if ($lab['state'] == 1) {
            $another_user_lab_is_active = TRUE;
        }
    }
    if (!$another_user_lab_is_active) {
        # determine best host, and update lab record
        $host_id = ace_db_get_best_host();
        if (is_numeric($host_id)) {
            # set lab as activated in db
            $db_success = ace_db_lab_set_state($lab_id, TRUE);
            # this lab was inactive, and was successfully activated
            $activated = $db_success;
            # update lab record with host_id
            ace_db_lab_set_host_id($lab_id, $host_id);
            # construct lab on host
            $net_table = ace_db_lab_get_network_table($lab_id);
            foreach ($net_table as $net) {
                # create (define) each network
                ace_virt_network_create($net['id']);
                # start each network if marked active in db
                if ($net['state'] == 1) {
                    ace_virt_network_activate($net['id']);
                }
            }
            $vol_table = ace_db_lab_get_volume_table($lab_id);
            foreach ($vol_table as $vol) {
                # create each volume
                ace_virt_volume_create($vol['id']);
            }
            $vm_table = ace_db_lab_get_vm_table($lab_id);
            foreach ($vm_table as $vm) {
                # create (define) each vm
                ace_virt_vm_create($vm['id']);
                $vm_cdrom_table = ace_db_vm_get_cdrom_table($vm['id']);
                foreach ($vm_cdrom_table as $vm_cdrom) {
                    ace_virt_vm_attach_cdrom($vm['id'], $vm_cdrom['instance']);
                    if ($vm_cdrom['volume_id'] != NULL) {
                        ace_virt_vm_cdrom_insert_media($vm['id'], $vm_cdrom['instance'], $vm_cdrom['volume_id']);
                    }
                }
                $vm_disk_table = ace_db_vm_get_disk_table($vm['id']);
                foreach ($vm_disk_table as $vm_disk) {
                    ace_virt_vm_attach_disk($vm['id'], $vm_disk['instance'], $vm_disk['volume_id']);
                }
                $vm_nic_table = ace_db_vm_get_nic_table($vm['id']);
                foreach ($vm_nic_table as $vm_nic) {
                    $vm_nic_mac_address = ace_gen_convert_int2mac($vm_nic['mac_index']);
                    ace_virt_vm_attach_nic($vm['id'], $vm_nic['instance'], $vm_nic_mac_address);
                    ace_virt_vm_nic_connect_network($vm['id'], $vm_nic['instance'], $vm_nic['network_id']);
                }
                # set each vm state
                if ($vm['state'] == 1) {
                    ace_vm_activate($vm['id']);
                }
            }
        } else {
            $activated = FALSE;
        }
    } else {
        $activated = FALSE;
    }
    return $activated;
}
Exemple #2
0
            if ($new_user_initial_password_text_block != '') {
                $element = '
                        <p align="center"><strong>New Student Initial Password(s)</strong></p>
                        <textarea rows=' . count($new_user_array) . ' cols="35" style="resize:none;" readonly>' . $new_user_initial_password_text_block . '</textarea>';
                $element_column[] = $element;
            }
            $element_table[] = $element_column;
            $element_column = array();
            $element = '
					<p align="center"><strong>My Labs</strong></p>';
            $element_column[] = $element;
            $element = '
					<form name="group_publish_lab_form" action="' . _MANAGER_URL_ . '" method="post">
						<input name="display" value="group_update_form" type="hidden" />
						<input name="group_id" value="' . $group_id . '" type="hidden" />';
            $lab_table = ace_user_get_lab_table($_SESSION['user_id']);
            if (is_array($lab_table)) {
                $element .= '
                        <table>';
                foreach ($lab_table as $lab) {
                    $element .= '
                            <tr>
                                <td>
                                    <input name="selected_lab_id" value="' . $lab['id'] . '" type="radio"/>
                                </td>
                                <td>
                                    ' . $lab['display_name'] . '
                                </td>
                            </tr>';
                }
                $element .= '
Exemple #3
0
        foreach ($group_lab_table as $lab) {
            $html_select_users_group_labs .= '<option value="' . $lab['id'] . '">' . $group['name'] . ':' . $lab['display_name'] . '</option>';
        }
    }
}
$create_lab_button_disabled = $num_user_labs >= $user_quota_array['labs'] ? 'disabled' : '';
$select_student_lab_count = 0;
$select_class_table = ace_user_get_owned_academic_groups($user_id);
$html_select_class_labs_none = '
                        <option value="none">select lab...</option>';
$html_selected_option_class = '';
$html_select_class_labs_options = '';
foreach ($select_class_table as $select_class) {
    $select_student_table = ace_group_get_members_table($select_class['id']);
    foreach ($select_student_table as $select_student) {
        $select_lab_table = ace_user_get_lab_table($select_student['user_id']);
        foreach ($select_lab_table as $select_lab) {
            $select_student_lab_count++;
            if ($select_lab['state'] == 1) {
                $html_select_option_class = 'active';
            } else {
                $html_select_option_class = 'inactive';
            }
            if ($select_lab['id'] == $lab_id) {
                $html_select_option_selected = ' selected';
                $html_selected_option_class = $html_select_option_class;
            } else {
                $html_select_option_selected = '';
            }
            $html_select_class_labs_options .= '
                        <option value="' . $select_lab['id'] . '" class="' . $html_select_option_class . '"' . $html_select_option_selected . '>' . $select_class['name'] . ':' . $select_student['user_name'] . ':' . $select_lab['display_name'] . '</option>';