function getData($args) { $data = getImages($args['includedeleted'], $args['rscid']); $noimageid = getImageId('noimage'); if ($noimageid) { unset($data[$noimageid]); } return $data; }
function scheduleVMsToAvailable($vmids) { # TODO test with vcld that will handle reservation for noimage okay # schedule $vmids to have noimage "loaded" on them in 15 minutes $allids = implode(',', $vmids); $query = "UPDATE computer " . "SET stateid = 5, " . "notes = '' " . "WHERE id IN ({$allids})"; doQuery($query); $imageid = getImageId('noimage'); $revid = getProductionRevisionid($imageid); $start = time() + 900; $end = $start + 3600; $startdt = unixToDatetime($start); $enddt = unixToDatetime($end); $vclreloadid = getUserlistID('vclreload@Local'); foreach ($vmids as $vmid) { // if simpleAddRequest fails, vm is left assigned and in failed state, which is fine simpleAddRequest($vmid, $imageid, $revid, $startdt, $enddt, 19, $vclreloadid); } }
<div id="preview<?php echo $kermert->getCurrIdx(); ?> " class="imagedetail" style="display:none"> <div class="imagethumbleft"><img src="<?php echo getImageThumb(); ?> "/></div> <?php echo getImageBody(); ?> <div style="clear:both; text-align:right;"><input type="button" id="b<?php echo getImageId(); ?> " value="mettre en ligne" onclick="javascript:updateStatus(<?php echo getImageId(); ?> );"/></div> </div> </div> <?php $kermert->moveNext(); } ?> <div id="listtools" class="imagedetail" style="text-align:center;"> <?php echo paginate($offset, $list_step); ?> </div> <?php } elseif ($op == 'operations') {
function getCompFinalVMReservationTime($hostid, $addsemaphores = 0, $notomaintenance = 0) { global $uniqid, $mysql_link_vcl; if ($addsemaphores) { $query = "SELECT vm.id " . "FROM computer vm, " . "vmhost v " . "WHERE v.computerid = {$hostid} AND " . "vm.vmhostid = v.id"; $qh = doQuery($query); $compids = array(); while ($row = mysql_fetch_assoc($qh)) { $compids[] = $row['id']; } if (empty($compids)) { return 0; } $allcompids = implode(',', $compids); $imageid = getImageId('noimage'); $revid = getProductionRevisionid($imageid); $tmp = getManagementNodes(); $tmp = array_keys($tmp); $mnid = $tmp[0]; $query = "INSERT INTO semaphore " . "SELECT c.id, " . "{$imageid}, " . "{$revid}, " . "{$mnid}, " . "NOW() + INTERVAL " . SEMTIMEOUT . " SECOND, " . "'{$uniqid}' " . "FROM computer c " . "LEFT JOIN semaphore s ON (c.id = s.computerid) " . "WHERE c.id IN ({$allcompids}) AND " . "(s.expires IS NULL OR s.expires < NOW()) " . "GROUP BY c.id"; doQuery($query); $cnt = mysql_affected_rows($mysql_link_vcl); if ($cnt != count($compids)) { return -1; } } $end = 0; $skipstates = '1,5,12'; if ($notomaintenance) { $skipstates .= ',18'; } $query = "SELECT UNIX_TIMESTAMP(rq.end) as end " . "FROM request rq, " . "reservation rs " . "WHERE rs.requestid = rq.id AND " . "rq.stateid NOT IN ({$skipstates}) AND " . "rs.computerid IN (SELECT vm.id " . "FROM computer vm, " . "vmhost v " . "WHERE v.computerid = {$hostid} AND " . "vm.vmhostid = v.id) " . "ORDER BY rq.end DESC " . "LIMIT 1"; $qh = doQuery($query, 101); if ($row = mysql_fetch_assoc($qh)) { $end = $row['end']; } $query = "SELECT UNIX_TIMESTAMP(t.end) as end " . "FROM blockComputers c, " . "blockTimes t " . "WHERE c.blockTimeid = t.id AND " . "t.end > NOW() AND " . "c.computerid IN (SELECT vm.id " . "FROM computer vm, " . "vmhost v " . "WHERE v.computerid = {$hostid} AND " . "vm.vmhostid = v.id) " . "ORDER BY t.end DESC " . "LIMIT 1"; $qh = doQuery($query, 101); if ($row = mysql_fetch_assoc($qh)) { if ($row['end'] > $end) { $end = $row['end']; } } return $end; }
function AJnewProfile() { $newprofile = processInputVar('newname', ARG_STRING); if (get_magic_quotes_gpc()) { $newprofile = stripslashes($newprofile); $newprofile = mysql_real_escape_string($newprofile); } $query = "SELECT id FROM vmprofile WHERE profilename = '{$newprofile}'"; $qh = doQuery($query, 101); if ($row = mysql_fetch_assoc($qh)) { sendJSON(array('failed' => 'exists')); return; } $imageid = getImageId('noimage'); $query = "INSERT INTO vmprofile (profilename, imageid) VALUES ('{$newprofile}', {$imageid})"; doQuery($query, 101); $qh = doQuery("SELECT LAST_INSERT_ID() FROM vmprofile", 101); $row = mysql_fetch_row($qh); $newid = $row[0]; AJprofileData($newid); }