public function getUsedSlotCount() { $UsedTasks = explode(',', $this->FOGCore->getSetting('FOG_USED_TASKS')); $countTasks = 0; if (in_array(8, (array) $UsedTasks)) { foreach ($UsedTasks as $ind => $val) { if ($val = 8) { unset($UsedTasks[$ind]); } } foreach ($this->getClass('TaskManager')->find(array('stateID' => 3, 'typeID' => 8)) as $MulticastTask) { $Multicast = current($this->getClass('MulticastSessionsAssociationManager')->find(array('taskID' => $MulticastTask->get('id')))); if ($Multicast && $Multicast->isValid()) { $MulticastJob = new MulticastSessions($Multicast->get('msID')); if ($MulticastJob && $MulticastJob->isValid()) { $MulticastJobID[] = $MulticastJob->get('id'); } } } $MulticastJobID = array_unique((array) $MulticastJobID); $countTasks = count($MulticastJobID); $UsedTasks = array_values((array) $UsedTasks); } $countTasks += $this->getClass('TaskManager')->count(array('stateID' => 3, 'typeID' => $UsedTasks, 'NFSMemberID' => $this->get('id'))); return $countTasks; }
} // Get the count of total associations. $Task->get('typeID') == 8 ? $MSAs = $FOGCore->getClass('MulticastSessionsAssociationManager')->count(array('msID' => $MultiSess->get('id'))) : null; // Set the task state for this host as in-progress. $Task->set('stateID', 3); if ($Task->get('typeID') == 8) { // If client count is equal, place session task in-progress as it will likely start soon. if ($MSAs == $MultiSess->get('clients') || $MultiSess->get('sessclients') > 0 && $MultiSess->get('clients') > 0) { $MultiSess->set('stateID', 3); } else { $MultiSess->set('stateID', 1); } } // Save the info. if ($Task->save() && ($Task->get('typeID') == 8 ? $MultiSess->save() : true)) { if ($MultiSess && $MultiSess->isValid()) { $Host->set('imageID', $MultiSess->get('image')); } // Log it $ImagingLogs = $FOGCore->getClass('ImagingLogManager')->find(array('hostID' => $Host->get('id'), 'type' => $_REQUEST['type'], 'complete' => '0000-00-00 00:00:00')); foreach ($ImagingLogs as $ImagingLog) { $id[] = $ImagingLog->get('id'); } if (!$id) { $il = new ImagingLog(array('hostID' => $Host->get('id'), 'start' => $FOGCore->nice_date()->format('Y-m-d H:i:s'), 'image' => $Task->getImage()->get('name'), 'type' => $_REQUEST['type'])); } else { $il = new ImagingLog(max($id)); $il->set('start', $FOGCore->nice_set()->format('Y-m-d H:i:s')); } $il->save(); $TaskLog = new TaskLog(array('taskID' => $Task->get('id'), 'taskStateID' => $Task->get('stateID'), 'createdTime' => $Task->get('createdTime'), 'createdBy' => $Task->get('createdBy')));
/** @function getTasking() Finds out if there's a tasking for the relevant host. * if there is, returns the printTasking, otherwise * presents the menu. * @return void */ public function getTasking() { $Task = $this->Host->get('task'); if (!$Task->isValid()) { if ($this->FOGCore->getSetting('FOG_NO_MENU')) { $this->noMenu(); } else { $this->printDefault(); } } else { if ($this->Host->get('mac')->isImageIgnored()) { $this->printImageIgnored(); } $TaskType = new TaskType($Task->get('typeID')); $imagingTasks = array(1, 2, 8, 15, 16, 17, 24); if ($TaskType->isMulticast()) { $MulticastSessionAssoc = current($this->getClass('MulticastSessionsAssociationManager')->find(array('taskID' => $Task->get('id')))); $MulticastSession = new MulticastSessions($MulticastSessionAssoc->get('msID')); if ($MulticastSession && $MulticastSession->isValid()) { $this->Host->set('imageID', $MulticastSession->get('image')); } } if (in_array($TaskType->get('id'), $imagingTasks)) { $Image = $Task->getImage(); $StorageGroup = $Image->getStorageGroup(); $StorageNode = $StorageGroup->getOptimalStorageNode(); $this->HookManager->processEvent('BOOT_TASK_NEW_SETTINGS', array('Host' => &$this->Host, 'StorageNode' => &$StorageNode, 'StorageGroup' => &$StorageGroup)); if ($TaskType->isUpload() || $TaskType->isMulticast()) { $StorageNode = $StorageGroup->getMasterStorageNode(); } $osid = $Image->get('osID'); $storage = in_array($TaskType->get('id'), $imagingTasks) ? sprintf('%s:/%s/%s', $this->FOGCore->resolveHostname(trim($StorageNode->get('ip'))), trim($StorageNode->get('path'), '/'), $TaskType->isUpload() ? 'dev/' : '') : null; } if ($this->Host && $this->Host->isValid()) { $mac = $this->Host->get('mac'); } else { $mac = $_REQUEST['mac']; } $clamav = in_array($TaskType->get('id'), array(21, 22)) ? sprintf('%s:%s', $this->FOGCore->resolveHostname(trim($StorageNode->get('ip'))), '/opt/fog/clamav') : null; $storageip = in_array($TaskType->get('id'), $imagingTasks) ? $this->FOGCore->resolveHostname($StorageNode->get('ip')) : null; $img = in_array($TaskType->get('id'), $imagingTasks) ? $Image->get('path') : null; $imgFormat = in_array($TaskType->get('id'), $imagingTasks) ? $Image->get('format') : null; $imgType = in_array($TaskType->get('id'), $imagingTasks) ? $Image->getImageType()->get('type') : null; $imgPartitionType = in_array($TaskType->get('id'), $imagingTasks) ? $Image->getImagePartitionType()->get('type') : null; $imgid = in_array($TaskType->get('id'), $imagingTasks) ? $Image->get('id') : null; $ftp = $this->FOGCore->resolveHostname($this->FOGCore->getSetting('FOG_TFTP_HOST')); $chkdsk = $this->FOGCore->getSetting('FOG_DISABLE_CHKDSK') == 1 ? 0 : 1; $PIGZ_COMP = in_array($TaskType->get('id'), $imagingTasks) ? $Image->get('compress') > -1 && is_numeric($Image->get('compress')) ? $Image->get('compress') : $this->FOGCore->getSetting('FOG_PIGZ_COMP') : $this->FOGCore->getSetting('FOG_PIGZ_COMP'); $kernelArgsArray = array("mac={$mac}", "ftp={$ftp}", "storage={$storage}", "storageip={$storageip}", "web={$this->web}", "osid={$osid}", "consoleblank=0", "irqpoll", "hostname=" . $this->Host->get('name'), array('value' => "clamav={$clamav}", 'active' => in_array($TaskType->get('id'), array(21, 22))), array('value' => "chkdsk={$chkdsk}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "img={$img}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "imgType={$imgType}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "imgPartitionType={$imgPartitionType}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "imgid={$imgid}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "imgFormat={$imgFormat}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => "PIGZ_COMP=-{$PIGZ_COMP}", 'active' => in_array($TaskType->get('id'), $imagingTasks)), array('value' => 'shutdown=1', 'active' => $Task->get('shutdown')), array('value' => 'adon=1', 'active' => $this->Host->get('useAD')), array('value' => 'addomain=' . $this->Host->get('ADDomain'), 'active' => $this->Host->get('useAD')), array('value' => 'adou=' . $this->Host->get('ADOU'), 'active' => $this->Host->get('useAD')), array('value' => 'aduser='******'ADUser'), 'active' => $this->Host->get('useAD')), array('value' => 'adpass='******'ADPass'), 'active' => $this->Host->get('useAD')), array('value' => 'fdrive=' . $this->Host->get('kernelDevice'), 'active' => $this->Host->get('kernelDevice')), array('value' => 'hostearly=1', 'active' => $this->FOGCore->getSetting('FOG_CHANGE_HOSTNAME_EARLY') && in_array($TaskType->get('id'), $imagingTasks) ? true : false), array('value' => 'pct=' . (is_numeric($this->FOGCore->getSetting('FOG_UPLOADRESIZEPCT')) && $this->FOGCore->getSetting('FOG_UPLOADRESIZEPCT') >= 5 && $this->FOGCore->getSetting('FOG_UPLOADRESIZEPCT') < 100 ? $this->FOGCore->getSetting('FOG_UPLOADRESIZEPCT') : '5'), 'active' => $TaskType->isUpload() && in_array($TaskType->get('id'), $imagingTasks) ? true : false), array('value' => 'ignorepg=' . ($this->FOGCore->getSetting('FOG_UPLOADIGNOREPAGEHIBER') ? 1 : 0), 'active' => $TaskType->isUpload() && in_array($TaskType->get('id'), $imagingTasks) ? true : false), array('value' => 'port=' . ($TaskType->isMulticast() ? $MulticastSession->get('port') : null), 'active' => $TaskType->isMulticast()), array('value' => 'mining=1', 'active' => $this->FOGCore->getSetting('FOG_MINING_ENABLE')), array('value' => 'miningcores=' . $this->FOGCore->getSetting('FOG_MINING_MAX_CORES'), 'active' => $this->FOGCore->getSetting('FOG_MINING_ENABLE')), array('value' => 'winuser='******'passreset'), 'active' => $TaskType->get('id') == '11' ? true : false), array('value' => 'miningpath=' . $this->FOGCore->getSetting('FOG_MINING_PACKAGE_PATH'), 'active' => $this->FOGCore->getSetting('FOG_MINING_ENABLE')), array('value' => 'isdebug=yes', 'active' => $Task->get('isDebug')), array('value' => 'debug', 'active' => $this->FOGCore->getSetting('FOG_KERNEL_DEBUG')), $TaskType->get('kernelArgs'), $this->FOGCore->getSetting('FOG_KERNEL_ARGS'), $this->Host->get('kernelArgs')); if ($Task->get('typeID') == 12 || $Task->get('typeID') == 13) { $this->printDefault(); } else { if ($Task->get('typeID') == 4) { $Send['memtest'] = array("#!ipxe", "{$this->memdisk} iso raw", "{$this->memtest}", "boot"); $this->parseMe($Send); } else { $this->printTasking($kernelArgsArray); } } } }