Example #1
1
function RPCisAvailable($imageid, $start, $end, $userid)
{
    #FIXME this function doesn't properly handle cluster reservations
    global $requestInfo;
    $images = getImages();
    $requestInfo["start"] = $start;
    $requestInfo["end"] = $end;
    $requestInfo["imageid"] = $imageid;
    $allocatedcompids = array(0);
    if ($requestInfo["start"] <= time()) {
        $now = 1;
    } else {
        $now = 0;
    }
    # get list of schedules
    $starttime = minuteOfWeek($start);
    $endtime = minuteOfWeek($end);
    # request is within a single week
    if (weekOfYear($start) == weekOfYear($end)) {
        $query = "SELECT scheduleid " . "FROM scheduletimes " . "WHERE start <= {$starttime} AND " . "end >= {$endtime}";
    } elseif ($end - $start >= SECINDAY * 7) {
        $query = "SELECT scheduleid " . "FROM scheduletimes " . "WHERE start = 0 AND " . "end = 10080";
    } else {
        $query = "SELECT s1.scheduleid " . "FROM scheduletimes s1, " . "scheduletimes s2 " . "WHERE s1.scheduleid = s2.scheduleid AND " . "s1.start <= {$starttime} AND " . "s1.end = 10080 AND " . "s2.start = 0 AND " . "s2.end >= {$endtime}";
    }
    $scheduleids = array();
    $qh = doQuery($query, 127);
    while ($row = mysql_fetch_row($qh)) {
        array_push($scheduleids, $row[0]);
    }
    $requestInfo["computers"] = array();
    $requestInfo["computers"][0] = 0;
    $requestInfo["images"][0] = $imageid;
    # loop to check for available computers for all needed images
    if ($images[$imageid]["imagemetaid"] != NULL) {
        $count = 1;
        foreach ($images[$imageid]["subimages"] as $imgid) {
            $requestInfo['computers'][$count] = 0;
            $requestInfo['images'][$count] = $imgid;
            $count++;
        }
    }
    // get semaphore lock
    if (!semLock()) {
        abort(3);
    }
    $startstamp = unixToDatetime($start);
    $endstamp = unixToDatetime($end + 900);
    foreach ($requestInfo["images"] as $key => $imageid) {
        #$osid = getOSid($os);
        # check for max concurrent usage of image
        if ($images[$imageid]['maxconcurrent'] != NULL) {
            $query = "SELECT COUNT(rs.imageid) AS currentusage " . "FROM reservation rs, " . "request rq " . "WHERE '{$startstamp}' < rq.end AND " . "'{$endstamp}' > (rq.start - INTERVAL 900 SECOND) AND " . "rs.requestid = rq.id AND " . "rs.imageid = {$imageid} AND " . "rq.stateid NOT IN (1,5,11,12,16,17)";
            $qh = doQuery($query, 101);
            if (!($row = mysql_fetch_assoc($qh))) {
                semUnlock();
                return 0;
            }
            if ($row['currentusage'] >= $images[$imageid]['maxconcurrent']) {
                semUnlock();
                return -1;
            }
        }
        # get platformid that matches $imageid
        $query = "SELECT platformid FROM image WHERE id = {$imageid}";
        $qh = doQuery($query, 125);
        if (!($row = mysql_fetch_row($qh))) {
            semUnlock();
            return 0;
        }
        $platformid = $row[0];
        # get computers $imageid maps to
        $tmp = getMappedResources($imageid, "image", "computer");
        if (!count($tmp)) {
            semUnlock();
            return 0;
        }
        $mappedcomputers = implode(',', $tmp);
        # get computers for available schedules and platforms
        $computerids = array();
        $currentids = array();
        $blockids = array();
        # get list of available computers
        $resources = getUserResources(array("imageAdmin", "imageCheckOut"), array("available"), 0, 0, $userid);
        $computers = implode("','", array_keys($resources["computer"]));
        $computers = "'{$computers}'";
        $alloccompids = implode(",", $allocatedcompids);
        $schedules = implode(',', $scheduleids);
        $query = "SELECT DISTINCT c.id, " . "c.currentimageid " . "FROM computer c, " . "image i, " . "state s " . "WHERE c.scheduleid IN ({$schedules}) AND " . "c.platformid = {$platformid} AND " . "c.stateid = s.id AND " . "s.name != 'maintenance' AND " . "s.name != 'vmhostinuse' AND " . "s.name != 'hpc' AND " . "s.name != 'failed' AND ";
        if ($now) {
            $query .= "s.name != 'reloading' AND " . "s.name != 'timeout' AND " . "s.name != 'inuse' AND ";
        }
        $query .= "i.id = {$imageid} AND " . "c.RAM >= i.minram AND " . "c.procnumber >= i.minprocnumber AND " . "c.procspeed >= i.minprocspeed AND " . "c.network >= i.minnetwork AND " . "c.id IN ({$computers}) AND " . "c.id IN ({$mappedcomputers}) AND " . "c.id NOT IN ({$alloccompids}) " . "ORDER BY (c.procspeed * c.procnumber) DESC, " . "RAM DESC, " . "network DESC";
        $qh = doQuery($query, 129);
        while ($row = mysql_fetch_assoc($qh)) {
            array_push($computerids, $row['id']);
            if ($row['currentimageid'] == $imageid) {
                array_push($currentids, $row['id']);
            }
        }
        # get computer ids available from block reservations
        $blockids = getAvailableBlockComputerids($imageid, $start, $end, $allocatedcompids);
        # remove computers from list that are already scheduled
        $usedComputerids = array();
        $query = "SELECT DISTINCT rs.computerid " . "FROM reservation rs, " . "request rq, " . "user u " . "WHERE '{$startstamp}' < rq.end AND " . "'{$endstamp}' > (rq.start - INTERVAL 900 SECOND) AND " . "rs.requestid = rq.id AND " . "rq.stateid != 1 AND " . "rq.stateid != 5 AND " . "rq.stateid != 12 AND " . "rq.userid = u.id AND " . "u.unityid != 'vclreload'";
        $qh = doQuery($query, 130);
        while ($row = mysql_fetch_row($qh)) {
            array_push($usedComputerids, $row[0]);
        }
        $computerids = array_diff($computerids, $usedComputerids);
        $currentids = array_diff($currentids, $usedComputerids);
        $blockids = array_diff($blockids, $usedComputerids);
        if (count($currentids)) {
            $return = array_shift($currentids);
        } elseif (count($computerids)) {
            $return = array_shift($computerids);
        } else {
            $return = 0;
        }
    }
    semUnlock();
    return $return;
}
Example #2
0
function isAvailable($images, $imageid, $imagerevisionid, $start, $end, $holdcomps, $requestid = 0, $userid = 0, $ignoreprivileges = 0, $forimaging = 0, $ip = '', $mac = '', $skipconcurrentcheck = 0)
{
    global $requestInfo, $user;
    $requestInfo["start"] = $start;
    $requestInfo["end"] = $end;
    $requestInfo["imageid"] = $imageid;
    $requestInfo["ipwarning"] = 0;
    $allocatedcompids = array(0);
    if (!is_array($imagerevisionid)) {
        $imagerevisionid = array($imageid => array($imagerevisionid));
    } elseif (empty($imagerevisionid)) {
        $imagerevisionid = array($imageid => array(getProductionRevisionid($imageid)));
    }
    if (schCheckMaintenance($start, $end)) {
        return debugIsAvailable(-2, 1, $start, $end, $imagerevisionid);
    }
    if (!array_key_exists($imageid, $images)) {
        return debugIsAvailable(0, 20, $start, $end, $imagerevisionid);
    }
    if ($requestInfo["start"] <= time()) {
        $now = 1;
        $nowfuture = 'now';
    } else {
        $now = 0;
        $nowfuture = 'future';
    }
    $scheduleids = getAvailableSchedules($start, $end);
    $requestInfo["computers"] = array();
    $requestInfo["computers"][0] = 0;
    $requestInfo["images"][0] = $imageid;
    $requestInfo["imagerevisions"][0] = $imagerevisionid[$imageid][0];
    # build array of subimages
    # TODO handle mininstance
    if (!$forimaging && $images[$imageid]["imagemetaid"] != NULL) {
        $count = 1;
        foreach ($images[$imageid]["subimages"] as $imgid) {
            $requestInfo['computers'][$count] = 0;
            $requestInfo['images'][$count] = $imgid;
            if (array_key_exists($imgid, $imagerevisionid) && array_key_exists($count, $imagerevisionid[$imgid])) {
                $requestInfo['imagerevisions'][$count] = $imagerevisionid[$imgid][$count];
            } else {
                $requestInfo['imagerevisions'][$count] = getProductionRevisionid($imgid);
            }
            $count++;
        }
    }
    $startstamp = unixToDatetime($start);
    $endstamp = unixToDatetime($end + 900);
    if (!empty($mac) || !empty($ip)) {
        # check for overlapping use of mac or ip
        $query = "SELECT rq.id " . "FROM reservation rs, " . "request rq, " . "serverrequest sr " . "WHERE '{$startstamp}' < (rq.end + INTERVAL 900 SECOND) AND " . "'{$endstamp}' > rq.start AND " . "sr.requestid = rq.id AND " . "rs.requestid = rq.id AND " . "(sr.fixedIP = '{$ip}' OR " . "sr.fixedMAC = '{$mac}') AND " . "rq.stateid NOT IN (1,5,11,12) ";
        if ($requestid) {
            $query .= "AND rq.id != {$requestid} ";
        }
        $query .= "LIMIT 1";
        $qh = doQuery($query, 101);
        if (mysql_num_rows($qh)) {
            return debugIsAvailable(-3, 2, $start, $end, $imagerevisionid);
        }
        # check for IP being used by a management node
        $query = "SELECT id " . "FROM managementnode " . "WHERE IPaddress = '{$ip}' AND " . "stateid != 1";
        $qh = doQuery($query, 101);
        if (mysql_num_rows($qh)) {
            return debugIsAvailable(-4, 16, $start, $end, $imagerevisionid);
        }
    }
    if ($requestid) {
        $requestData = getRequestInfo($requestid);
    }
    $vmhostcheckdone = 0;
    $ignorestates = "'maintenance','vmhostinuse','hpc','failed'";
    if ($now) {
        $ignorestates .= ",'reloading','reload','timeout','inuse'";
    }
    foreach ($requestInfo["images"] as $key => $imageid) {
        # check for max concurrent usage of image
        if (!$skipconcurrentcheck && $images[$imageid]['maxconcurrent'] != NULL) {
            if ($userid == 0) {
                $usersgroups = $user['groups'];
            } else {
                $testuser = getUserInfo($userid, 0, 1);
                if (is_null($testuser)) {
                    return debugIsAvailable(0, 17, $start, $end, $imagerevisionid);
                }
                $usersgroups = $testuser['groups'];
            }
            $decforedit = 0;
            $compids = array();
            $reloadid = getUserlistID('vclreload@Local');
            $query = "SELECT rs.computerid, " . "rq.id AS reqid " . "FROM reservation rs, " . "request rq " . "WHERE '{$startstamp}' < (rq.end + INTERVAL 900 SECOND) AND " . "'{$endstamp}' > rq.start AND " . "rs.requestid = rq.id AND " . "rs.imageid = {$imageid} AND " . "rq.stateid NOT IN (1,5,11,12,16,17) AND " . "rq.userid != {$reloadid}";
            $qh = doQuery($query, 101);
            while ($row = mysql_fetch_assoc($qh)) {
                $compids[] = $row['computerid'];
                if ($row['reqid'] == $requestid) {
                    $decforedit = 1;
                }
            }
            $usagecnt = count($compids);
            $allids = implode("','", $compids);
            $ignoregroups = implode("','", array_keys($usersgroups));
            $query = "SELECT COUNT(bc.imageid) AS currentusage " . "FROM blockComputers bc, " . "blockRequest br, " . "blockTimes bt " . "WHERE bc.blockTimeid = bt.id AND " . "bt.blockRequestid = br.id AND " . "bc.imageid = {$imageid} AND " . "bc.computerid NOT IN ('{$allids}') AND " . "br.groupid NOT IN ('{$ignoregroups}') AND " . "'{$startstamp}' < (bt.end + INTERVAL 900 SECOND) AND " . "'{$endstamp}' > bt.start AND " . "bt.skip != 1 AND " . "br.status != 'deleted'";
            $qh = doQuery($query);
            if (!($row = mysql_fetch_assoc($qh))) {
                cleanSemaphore();
                return debugIsAvailable(0, 3, $start, $end, $imagerevisionid);
            }
            if ($usagecnt + $row['currentusage'] - $decforedit >= $images[$imageid]['maxconcurrent']) {
                cleanSemaphore();
                return debugIsAvailable(-1, 4, $start, $end, $imagerevisionid);
            }
        }
        $platformid = getImagePlatform($imageid);
        if (is_null($platformid)) {
            cleanSemaphore();
            return debugIsAvailable(0, 5, $start, $end, $imagerevisionid);
        }
        # get computers $imageid maps to
        $compids = getMappedResources($imageid, "image", "computer");
        if (!count($compids)) {
            cleanSemaphore();
            return debugIsAvailable(0, 6, $start, $end, $imagerevisionid);
        }
        $mappedcomputers = implode(',', $compids);
        // if $ip specified, only look at computers under management nodes that can
        #   handle that network
        if ($ip != '') {
            $mappedmns = getMnsFromImage($imageid);
            $mnnets = checkAvailableNetworks($ip);
            $intersect = array_intersect($mappedmns, $mnnets);
            $tmpcompids = array();
            foreach ($intersect as $mnid) {
                $tmp2 = getMappedResources($mnid, 'managementnode', 'computer');
                $tmpcompids = array_merge($tmpcompids, $tmp2);
            }
            $tmpcompids = array_unique($tmpcompids);
            $newcompids = array_intersect($compids, $tmpcompids);
            if (!count($newcompids)) {
                cleanSemaphore();
                return debugIsAvailable(0, 18, $start, $end, $imagerevisionid);
            }
            $mappedcomputers = implode(',', $newcompids);
        }
        #get computers for available schedules and platforms
        $computerids = array();
        $currentids = array();
        $blockids = array();
        $altRemoveBlockCheck = 0;
        // if we are modifying a request and it is after the start time, only allow
        // the scheduled computer(s) to be modified
        if ($requestid && datetimeToUnix($requestData["start"]) <= time()) {
            $altRemoveBlockCheck = 1;
            foreach ($requestData["reservations"] as $key2 => $res) {
                if ($res["imageid"] == $imageid) {
                    $compid = $res["computerid"];
                    unset($requestData['reservations'][$key2]);
                    break;
                }
            }
            array_push($computerids, $compid);
            array_push($currentids, $compid);
            $query = "SELECT scheduleid " . "FROM computer " . "WHERE id = {$compid}";
            $qh = doQuery($query, 128);
            $row = mysql_fetch_row($qh);
            if (!in_array($row[0], $scheduleids)) {
                cleanSemaphore();
                return debugIsAvailable(0, 7, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids);
            }
            // set $virtual to 0 so that it is defined later but skips the additional code
            $virtual = 0;
        } else {
            # determine if image is bare metal or virtual
            $query = "SELECT OS.installtype " . "FROM image i " . "LEFT JOIN OS ON (i.OSid = OS.id) " . "WHERE i.id = {$imageid}";
            $qh = doQuery($query, 101);
            if (!($row = mysql_fetch_assoc($qh))) {
                cleanSemaphore();
                return debugIsAvailable(0, 8, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids);
            }
            # TODO might need to check for other strings for KVM, OpenStack, etc
            if (preg_match('/(vmware)/', $row['installtype'])) {
                $virtual = 1;
            } else {
                $virtual = 0;
            }
            # get list of available computers
            if (!$ignoreprivileges) {
                $resources = getUserResources(array("imageAdmin", "imageCheckOut"), array("available"), 0, 0, $userid);
                $usercomputers = implode("','", array_keys($resources["computer"]));
                $usercomputers = "'{$usercomputers}'";
            }
            $alloccompids = implode(",", $allocatedcompids);
            # get list of computers we can provision image to
            $schedules = implode(',', $scheduleids);
            #image.OSid->OS.installtype->OSinstalltype.id->provisioningOSinstalltype.provisioningid->computer.provisioningid
            $query = "SELECT DISTINCT c.id, " . "c.currentimageid, " . "c.imagerevisionid " . "FROM state s, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OSinstalltype oi ON (oi.name = o.installtype) " . "LEFT JOIN provisioningOSinstalltype poi ON (poi.OSinstalltypeid = oi.id) " . "LEFT JOIN computer c ON (poi.provisioningid = c.provisioningid) " . "LEFT JOIN semaphore se ON (c.id = se.computerid) " . "WHERE i.id = {$imageid} AND " . "c.scheduleid IN ({$schedules}) AND " . "c.platformid = {$platformid} AND " . "c.stateid = s.id AND " . "s.name NOT IN ({$ignorestates}) AND " . "c.RAM >= i.minram AND " . "c.procnumber >= i.minprocnumber AND " . "c.procspeed >= i.minprocspeed AND " . "c.network >= i.minnetwork AND " . "c.deleted = 0 AND " . "(c.type != 'virtualmachine' OR c.vmhostid IS NOT NULL) AND ";
            if (!$ignoreprivileges) {
                $query .= "c.id IN ({$usercomputers}) AND ";
            }
            $query .= "c.id IN ({$mappedcomputers}) AND " . "c.id NOT IN ({$alloccompids}) AND " . "(se.expires IS NULL OR se.expires < NOW()) " . "ORDER BY RAM, " . "(c.procspeed * c.procnumber), " . "network";
            $qh = doQuery($query, 129);
            while ($row = mysql_fetch_assoc($qh)) {
                array_push($computerids, $row['id']);
                if ($row['currentimageid'] == $imageid && $row['imagerevisionid'] == $requestInfo['imagerevisions'][$key]) {
                    array_push($currentids, $row['id']);
                }
            }
            # get computer ids available from block allocations
            $blockdata = getAvailableBlockComputerids($imageid, $start, $end, $allocatedcompids);
            $blockids = $blockdata['compids'];
        }
        # return 0 if no computers available
        if (empty($computerids) && empty($blockids)) {
            return debugIsAvailable(0, 21, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
        }
        #remove computers from list that are already scheduled
        $usedComputerids = array();
        $query = "SELECT DISTINCT rs.computerid " . "FROM reservation rs, " . "request rq " . "WHERE '{$startstamp}' < (rq.end + INTERVAL 900 SECOND) AND " . "'{$endstamp}' > rq.start AND " . "rq.id != {$requestid} AND " . "rs.requestid = rq.id AND " . "rq.stateid NOT IN (1, 5, 12)";
        # deleted, failed, complete
        $qh = doQuery($query, 130);
        while ($row = mysql_fetch_row($qh)) {
            array_push($usedComputerids, $row[0]);
        }
        $computerids = array_diff($computerids, $usedComputerids);
        $currentids = array_diff($currentids, $usedComputerids);
        $blockids = array_diff($blockids, $usedComputerids);
        // if modifying a reservation and $computerids is now empty, return 0
        if ($requestid && empty($computerids)) {
            cleanSemaphore();
            return debugIsAvailable(0, 9, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
        }
        # return 0 if no computers available
        if (empty($computerids) && empty($currentids) && empty($blockids)) {
            return debugIsAvailable(0, 19, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
        }
        # remove computers from list that are allocated to block allocations
        if ($altRemoveBlockCheck) {
            if (editRequestBlockCheck($computerids[0], $imageid, $start, $end)) {
                cleanSemaphore();
                return debugIsAvailable(0, 10, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
            }
        } elseif (!count($blockids)) {
            # && ! $altRemoveBlockCheck
            $usedBlockCompids = getUsedBlockComputerids($start, $end);
            $computerids = array_diff($computerids, $usedBlockCompids);
            $currentids = array_diff($currentids, $usedBlockCompids);
        }
        if ($virtual && empty($currentids) && !empty($computerids)) {
            # find computers whose hosts can handle the required RAM - we don't
            #   need to do this if there are VMs with the requested image already
            #   available because they would already fit within the host's available
            #   RAM
            if (!$vmhostcheckdone) {
                $vmhostcheckdone = 1;
                $query = "DROP TEMPORARY TABLE IF EXISTS VMhostCheck";
                doQuery($query, 101);
                $query = "CREATE TEMPORARY TABLE VMhostCheck ( " . "RAM mediumint unsigned NOT NULL, " . "allocRAM mediumint unsigned NOT NULL, " . "vmhostid smallint unsigned NOT NULL " . ") ENGINE=MEMORY";
                doQuery($query, 101);
                $query = "INSERT INTO VMhostCheck " . "SELECT c.RAM, " . "SUM(i.minram), " . "v.id " . "FROM vmhost v " . "LEFT JOIN computer c ON (v.computerid = c.id) " . "LEFT JOIN computer c2 ON (v.id = c2.vmhostid) " . "LEFT JOIN image i ON (c2.currentimageid = i.id) " . "WHERE c.stateid = 20 " . "GROUP BY v.id";
                doQuery($query, 101);
            }
            $inids = implode(',', $computerids);
            // if want overbooking, modify the last part of the WHERE clause
            $query = "SELECT c.id " . "FROM VMhostCheck v " . "LEFT JOIN computer c ON (v.vmhostid = c.vmhostid) " . "LEFT JOIN image i ON (c.currentimageid = i.id) " . "WHERE c.id IN ({$inids}) AND " . "(v.allocRAM - i.minram + {$images[$imageid]['minram']}) < v.RAM " . "ORDER BY c.RAM, " . "(c.procspeed * c.procnumber), " . "c.network";
            $qh = doQuery($query, 101);
            $newcompids = array();
            while ($row = mysql_fetch_assoc($qh)) {
                $newcompids[] = $row['id'];
            }
            $computerids = $newcompids;
        }
        # check for use of specified IP address, have to wait until here
        #   because there may be a computer already assigned the IP that
        #   can be used for this reservation
        if (!empty($ip) && $now) {
            $allcompids = array_merge($computerids, $blockids);
            if (empty($allcompids)) {
                return debugIsAvailable(0, 13, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
            }
            $inids = implode(',', $allcompids);
            $query = "SELECT id " . "FROM computer " . "WHERE id NOT IN ({$inids}) AND " . "deleted = 0 AND " . "stateid != 1 AND " . "IPaddress = '{$ip}' AND " . "(type != 'virtualmachine' OR " . "vmhostid IS NOT NULL)";
            $qh = doQuery($query);
            if (mysql_num_rows($qh)) {
                if ($now) {
                    return debugIsAvailable(-4, 18, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
                }
                $requestInfo['ipwarning'] = 1;
            }
            $query = "SELECT id " . "FROM computer " . "WHERE id in ({$inids}) AND " . "IPaddress = '{$ip}'";
            if ($requestid) {
                $query .= " AND id != {$compid}";
            }
            # TODO test this
            $qh = doQuery($query);
            $cnt = mysql_num_rows($qh);
            if ($cnt > 1) {
                if ($now) {
                    return debugIsAvailable(-4, 19, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
                }
                $requestInfo['ipwarning'] = 1;
            } elseif ($cnt == 1) {
                $row = mysql_fetch_assoc($qh);
                $computerids = array($row['id']);
                $blockids = array();
            }
        }
        # remove any recently reserved computers that could have been an
        #   undetected failure
        $failedids = getPossibleRecentFailures($userid, $imageid);
        $shortened = 0;
        if (!empty($failedids)) {
            $origcomputerids = $computerids;
            $origcurrentids = $currentids;
            $origblockids = $blockids;
            if (!empty($computerids)) {
                $testids = array_diff($computerids, $failedids);
                if (!empty($testids)) {
                    $shortened = 1;
                    $computerids = $testids;
                    $currentids = array_diff($currentids, $failedids);
                }
            }
            if (!empty($blockids)) {
                $testids = array_diff($blockids, $failedids);
                if (!empty($testids)) {
                    $shortened = 1;
                    $blockids = $testids;
                }
            }
        }
        # allocate a computer
        $_imgrevid = $requestInfo['imagerevisions'][$key];
        $comparr = allocComputer($blockids, $currentids, $computerids, $startstamp, $endstamp, $nowfuture, $imageid, $_imgrevid, $holdcomps, $requestid);
        if (empty($comparr) && $shortened) {
            $comparr = allocComputer($origblockids, $origcurrentids, $origcomputerids, $startstamp, $endstamp, $nowfuture, $imageid, $_imgrevid, $holdcomps, $requestid);
        }
        if (empty($comparr)) {
            cleanSemaphore();
            return debugIsAvailable(0, 11, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, $failedids, $virtual);
        }
        $requestInfo["computers"][$key] = $comparr['compid'];
        $requestInfo["mgmtnodes"][$key] = $comparr['mgmtid'];
        $requestInfo["loaded"][$key] = $comparr['loaded'];
        $requestInfo['fromblock'][$key] = $comparr['fromblock'];
        if ($comparr['fromblock']) {
            $requestInfo['blockdata'][$key] = $blockdata[$comparr['compid']];
        }
        array_push($allocatedcompids, $comparr['compid']);
    }
    return debugIsAvailable(1, 12, $start, $end, $imagerevisionid, $computerids, $currentids, $blockids, array(), $virtual);
}