/** * Profile command * * @param string $command * @return array */ public function profileCommand($command) { $tasks = $this->Task->find('all', array('conditions' => array('command' => $command, 'status' => array(TaskType::STOPPED, TaskType::FINISHED), 'runtime >' => 0), 'fields' => array('runtime', 'id', 'started', 'stopped', 'created', 'waittime'), 'limit' => Configure::read('Task.profilerLimit'), 'order' => array('id' => 'DESC'))); if (!$tasks) { return null; } $statistics = array_map(function ($item) { $endDate = new DateTime($item['stopped']); $startDate = new DateTime($item['started']); $createdDate = new DateTime($item['created']); $item['runtimeHuman'] = $startDate->diff($endDate)->format(Configure::read('Task.dateDiffFormat')); $item['waittimeHuman'] = $createdDate->diff($startDate)->format(Configure::read('Task.dateDiffFormat')); $item['startedTimestamp'] = $startDate->getTimestamp(); $item['runtime'] = (int) $item['runtime']; $item['waittime'] = (int) $item['waittime']; return $item; }, Hash::extract($tasks, '{n}.{s}')); $runtimes = Hash::extract($statistics, '{n}.runtime'); $runtimeAverage = (int) round($runtimes ? array_sum($runtimes) / count($runtimes) : 0); $runtimeMax = $runtimes ? max($runtimes) : 0; $runtimeMin = $runtimes ? min($runtimes) : 0; $waittimes = Hash::extract($statistics, '{n}.waittime'); $waittimeAverage = (int) round($waittimes ? array_sum($waittimes) / count($waittimes) : 0); $waittimeMax = $waittimes ? max($waittimes) : 0; $waittimeMin = $waittimes ? min($waittimes) : 0; $countByStatus = array(); foreach (TaskType::getTypes() as $statusCode) { $countByStatus[$statusCode] = $this->Task->find('count', array('conditions' => array('command' => $command, 'status' => $statusCode))); } $errored = $this->Task->find('count', array('conditions' => array('command' => $command, 'errored' => true))); return array('command' => $command, 'countByStatus' => $countByStatus, 'errored' => $errored, 'statistics' => $statistics, 'runtimeAverage' => $runtimeAverage, 'runtimeAverageHuman' => $this->_secondsToHuman($runtimeAverage), 'runtimeMax' => $runtimeMax, 'runtimeMaxHuman' => $this->_secondsToHuman($runtimeMax), 'runtimeMin' => $runtimeMin, 'runtimeMinHuman' => $this->_secondsToHuman($runtimeMin), 'waittimeAverage' => $waittimeAverage, 'waittimeAverageHuman' => $this->_secondsToHuman($waittimeAverage), 'waittimeMax' => $waittimeMax, 'waittimeMaxHuman' => $this->_secondsToHuman($waittimeMax), 'waittimeMin' => $waittimeMin, 'waittimeMinHuman' => $this->_secondsToHuman($waittimeMin)); }
public function tasktypes($args) { $this->vars["pagename"] = "Adminstration :: Task Types"; $p = PermissionHandler::getInstance(); if (!$p->allowedto(PermissionHandler::PERM_MANAGE_TASKTYPES)) { Utils::error("You don't have permission to create task types."); return; } if (isset($_POST["action"])) { switch ($_POST["action"]) { case "create": if (isset($_POST["tasktype"]) && !empty($_POST["tasktype"])) { $tasktype = new TaskType(); $tasktype->name = $_POST["tasktype"]; $tasktype->created = date("Y-m-d H:i:s"); $tasktype->save(); } else { Utils::error("No task type entered to create."); return; } break; case "delete": if (isset($_POST["tasktypes"]) && !empty($_POST["tasktypes"])) { $q = Doctrine_Query::create()->delete("TaskType"); foreach ($_POST["tasktypes"] as $task => $status) { if ($status == "on") { $q->orWhere("id = ?", $task); } } $q->execute(); Utils::success("Task types successfully deleted."); } else { Utils::error("No task types selected to delete."); } break; default: // THIS SHOULD NOT HAPPEN! D: break; } } $this->vars["tasktypes"] = Doctrine_Query::create()->from("TaskType")->fetchArray(); }
public function hostdeploy() { $Host = new Host($this->REQUEST['id']); $taskTypeID = $this->REQUEST['type']; $TaskType = new TaskType($_REQUEST['type']); $snapin = '-1'; $enableShutdown = false; $enableSnapins = $_REQUEST['type'] == 17 ? false : -1; $taskName = 'Quick Deploy'; try { if ($TaskType->isUpload() && $Host->getImage()->isValid() && $Host->getImage()->get('protected')) { throw new Exception(sprintf('%s: %s %s: %s %s', _('Hostname'), $Host->get('name'), _('Image'), $Host->getImage()->get('name'), _('is protected'))); } $Host->createImagePackage($taskTypeID, $taskName, false, false, $enableSnapins, false, $this->FOGUser->get('name')); $this->FOGCore->setMessage('Successfully created tasking!'); $this->FOGCore->redirect('?node=task&sub=active'); } catch (Exception $e) { printf('<div class="task-start-failed"><p>%s</p><p>%s</p></div>', _('Failed to create deploy task'), $e->getMessage()); } }
<?php // // Post_Stage2.php // Triggered: After image upload // Actions: Moves uploaded image to final location via FTP // require_once '../commons/base.inc.php'; try { $Host = $FOGCore->getHostItem(false); // Task for Host $Task = $Host->get('task'); if (!$Task->isValid()) { throw new Exception(sprintf('%s: %s (%s)', _('No Active Task found for Host'), $Host->get('name'), $MACAddress)); } $TaskType = new TaskType($Task->get('typeID')); // Get the storage group $StorageGroup = $Task->getStorageGroup(); if ($TaskType->isUpload() && !$StorageGroup->isValid()) { throw new Exception(_('Invalid Storage Group')); } // Get the storage node. $StorageNode = $StorageGroup->getMasterStorageNode(); if ($TaskType->isUpload() && !$StorageNode) { throw new Exception(_('Could not find a Storage Node. Is there one enabled within this Storage Group?')); } // Image Name store for logging the image task later. $Image = $Task->getImage(); $ImageName = $Image->get('name'); // Sets the class for ftp of files and deletion as necessary. $ftp = $FOGFTP;
public function checkIfExist($taskTypeID) { // TaskType: Variables $TaskType = new TaskType($taskTypeID); $isUpload = $TaskType->isUpload(); // Image: Variables $Image = $this->getImage(); $StorageGroup = $Image->getStorageGroup(); $StorageNode = $isUpload ? $StorageGroup->getMasterStorageNode() : $this->getOptimalStorageNode(); if (!$isUpload) { $this->HookManager->processEvent('HOST_NEW_SETTINGS', array('Host' => &$this, 'StorageNode' => &$StorageNode, 'StorageGroup' => &$StorageGroup)); } if (!$StorageGroup || !$StorageGroup->isValid()) { throw new Exception(_('No Storage Group found for this image')); } if (!$StorageNode || !$StorageNode->isValid()) { throw new Exception(_('No Storage Node found for this image')); } if (in_array($TaskType->get('id'), array('1', '8', '15', '17')) && in_array($Image->get('osID'), array('5', '6', '7'))) { // FTP $this->FOGFTP->set('username', $StorageNode->get('user'))->set('password', $StorageNode->get('pass'))->set('host', $this->FOGCore->resolveHostname($StorageNode->get('ip'))); if ($this->FOGFTP->connect()) { if (!$this->FOGFTP->chdir(rtrim($StorageNode->get('path'), '/') . '/' . $Image->get('path'))) { return false; } } $this->FOGFTP->close(); } return true; }
function doPopulateDatabase() { // Check for a config file, if it doesn't exist go through the steps to create it. if (!file_exists(dirname(__FILE__) . '/config.php')) { header("Location: " . $_SERVER["SCRIPT_NAME"] . "?do=step1"); return; } require_once dirname(__FILE__) . "/config.php"; require_once dirname(__FILE__) . "/fwork/lib/Doctrine/Doctrine.php"; spl_autoload_register(array("Doctrine", "autoload")); Doctrine_Manager::connection($config["database"]["dsn"]); Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, $config["database"]["prefix"] . "%s"); Doctrine::createTablesFromModels(dirname(__FILE__) . "/models"); $time = date("Y-m-d H:i:s"); // roles $role_admin = new Role(); $role_admin->name = "Admin"; $role_admin->auth = 0xffffffff; $role_admin->created = $time; $role_admin->save(); $role_staff = new Role(); $role_staff->name = "Staff"; $role_staff->auth = 0x7c700; $role_staff->created = $time; $role_staff->save(); $role_guest = new Role(); $role_guest->name = "Guest"; $role_guest->auth = 0x0; $role_guest->created = $time; $role_guest->save(); // staff $staff = new Staff(); $staff->nickname = "admin"; $staff->setPassword("admin"); $staff->Role = $role_admin; $staff->admin = true; $staff->comment = "Administrator"; $staff->created = $time; $staff->save(); // task types $tasktypes = array('Raw Cap', 'Translate', 'Time', 'Translation Check', 'Typeset', 'Edit', 'Encode', 'Quality Check', 'Karaoke', 'Miscellaneous', 'Translate Signs', 'Release'); foreach ($tasktypes as $key => $name) { $tasktype = new TaskType(); $tasktype->name = $name; $tasktype->created = $time; $tasktype->save(); $tasktypes[$key] = $tasktype; } // template $template = new Template(); $template->name = "Default"; $template->model = $tasktypes[0]->id . ":0->" . $tasktypes[1]->id . ":0; " . $tasktypes[0]->id . ":0->" . $tasktypes[10]->id . ":0; " . $tasktypes[10]->id . ":0->" . $tasktypes[4]->id . ":0; " . $tasktypes[4]->id . ":0->" . $tasktypes[3]->id . ":0; " . $tasktypes[1]->id . ":0->" . $tasktypes[2]->id . ":0; " . $tasktypes[1]->id . ":0->" . $tasktypes[3]->id . ":0; " . $tasktypes[3]->id . ":0->" . $tasktypes[5]->id . ":0; " . $tasktypes[5]->id . ":0->" . $tasktypes[6]->id . ":0; " . $tasktypes[6]->id . ":0->" . $tasktypes[7]->id . ":0; " . $tasktypes[7]->id . ":0->" . $tasktypes[11]->id . ":0; " . $tasktypes[2]->id . ":0->" . $tasktypes[5]->id . ":0; "; $template->created = $time; $template->save(); // settings $settings = array('site.gzip' => true, 'site.gentime' => true); foreach ($settings as $name => $value) { $setting = new Setting(); $setting->name = $name; $setting->value = $value; $setting->save(); unset($setting); } echo <<<EOS <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> \t<title>Frac :: Install</title> \t<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> \t<h2>Frac Installer</h2> \t<p>Table data populated successfully. You may now proceed to your <a href="./">Frac installation</a>. The username and password are "admin".</p> </body> </html> EOS; }
/** @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); } } } }
/** * Test types */ public function testType() { $this->assertSame(array('UNSTARTED' => (int) 0, 'DEFFERED' => (int) 1, 'RUNNING' => (int) 2, 'FINISHED' => (int) 3, 'STOPPING' => (int) 4, 'STOPPED' => (int) 5), TaskType::getTypes()); }
/** deploy_post() actually create the deployment task * @return void */ public function deploy_post() { $Data = $this->obj; $TaskType = new TaskType($_REQUEST['type']); $Snapin = $_REQUEST['snapin'] ? new Snapin($_REQUEST['snapin']) : -1; $enableShutdown = $_REQUEST['shutdown'] ? true : false; $enableSnapins = $TaskType->get('id') != '17' ? $Snapin instanceof Snapin && $Snapin->isValid() ? $Snapin->get('id') : $Snapin : false; $enableDebug = $_REQUEST['debug'] == 'true' || $_REQUEST['isDebugTask'] ? true : false; $scheduleDeployTime = $this->nice_date($_REQUEST['scheduleSingleTime']); $imagingTasks = in_array($TaskType->get('id'), array(1, 2, 8, 15, 16, 17, 24)); try { if (!$TaskType || !$TaskType->isValid()) { throw new Exception(_('Task type is not valid')); } $taskName = $TaskType->get('name') . ' Task'; if ($Data && $Data->isValid()) { // Error Checking if ($Data instanceof Host && $imagingTasks) { if (!$Data->getImage() || !$Data->getImage()->isValid()) { throw new Exception(_('You need to assign an image to the host')); } if ($TaskType->isUpload() && $Data->getImage()->get('protected')) { throw new Exception(_('You cannot upload to this image as it is currently protected')); } if (!$Data->checkIfExist($TaskType->get('id'))) { throw new Exception(_('You must first upload an image to create a download task')); } } else { if ($Data instanceof Group && $imagingTasks) { if ($TaskType->isMulticast() && !$Data->doMembersHaveUniformImages()) { throw new Exception(_('Hosts do not contain the same image assignments')); } unset($NoImage, $ImageExists, $Tasks); foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $NoImage[] = !$Host->getImage() || !$Host->getImage()->isValid(); } } if (in_array(true, $NoImage)) { throw new Exception(_('One or more hosts do not have an image set')); } foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $ImageExists[] = !$Host->checkIfExist($TaskType->get('id')); } } if (in_array(true, $ImageExists)) { throw new Exception(_('One or more hosts have an image that does not exist')); } foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && $Host->get('task') && $Host->get('task')->isValid()) { $Tasks[] = $Host->get('task'); } } if (count($Tasks) > 0) { throw new Exception(_('One or more hosts are currently in a task')); } } } $passreset = trim($_REQUEST['account']); if ($TaskType->get('id') == 11 && empty($passreset)) { throw new Exception(_('Password reset requires a user account to reset')); } try { if ($_REQUEST['scheduleType'] == 'instant') { if ($Data instanceof Group) { foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { if ($Host->createImagePackage($TaskType->get('id'), $taskName, $enableShutdown, $enableDebug, $enableSnapins, $Data instanceof Group, $_SESSION['FOG_USERNAME'], $passreset)) { $success[] = sprintf('<li>%s – %s</li>', $Host->get('name'), $Host->getImage()->get('name')); } } } } else { if ($Data instanceof Host) { if ($Data->createImagePackage($TaskType->get('id'), $taskName, $enableShutdown, $enableDebug, $enableSnapins, $Data instanceof Group, $_SESSION['FOG_USERNAME'], $passreset)) { $success[] = sprintf('<li>%s – %s</li>', $Data->get('name'), $Data->getImage()->get('name')); } } } } else { if ($_REQUEST['scheduleType'] == 'single') { if ($scheduleDeployTime < $this->nice_date()) { throw new Exception(sprintf('%s<br>%s: %s', _('Scheduled date is in the past'), _('Date'), $scheduleDeployTime->format('Y/d/m H:i'))); } $ScheduledTask = new ScheduledTask(array('taskType' => $TaskType->get('id'), 'name' => $taskName, 'hostID' => $Data->get('id'), 'shutdown' => $enableShutdown, 'other2' => $enableSnapins, 'isGroupTask' => $Data instanceof Group, 'type' => 'S', 'scheduleTime' => $scheduleDeployTime->getTimestamp(), 'other3' => $this->FOGUser->get('name'))); } else { if ($_REQUEST['scheduleType'] == 'cron') { $ScheduledTask = new ScheduledTask(array('taskType' => $TaskType->get('id'), 'name' => $taskName, 'hostID' => $Data->get('id'), 'shutdown' => $enableShutdown, 'other2' => $enableSnapins, 'isGroupTask' => $Data instanceof Group, 'type' => 'C', 'other3' => $this->FOGUser->get('name'), 'minute' => $_REQUEST['scheduleCronMin'], 'hour' => $_REQUEST['scheduleCronHour'], 'dayOfMonth' => $_REQUEST['scheduleCronDOM'], 'month' => $_REQUEST['scheduleCronMonth'], 'dayOfWeek' => $_REQUEST['scheduleCronDOW'])); } } } if ($ScheduledTask && $ScheduledTask->save()) { if ($Data instanceof Group) { foreach ((array) $Data->get('hosts') as $Host) { if ($Host && $Host->isValid() && !$Host->get('pending')) { $success[] = sprintf('<li>%s – %s</li>', $Host->get('name'), $Host->getImage()->get('name')); } } } else { if ($Data instanceof Host) { if ($Data && $Data->isValid() && !$Data->get('pending')) { $success[] = sprintf('<li>%s – %s</li>', $Data->get('name'), $Data->getImage()->get('name')); } } } } } catch (Exception $e) { $error[] = sprintf('%s: %s', $Data instanceof Group ? $Host->get('name') : $Data->get('name'), $e->getMessage()); } } // Failure if (count($error)) { throw new Exception('<ul><li>' . implode('</li><li>', $error) . '</li></ul>'); } } catch (Exception $e) { // Failure printf('<div class="task-start-failed"><p>%s</p><p>%s</p></div>', _('Failed to create deployment tasking for the following hosts'), $e->getMessage()); } // Success if (count($success)) { printf('<div class="task-start-ok"><p>%s</p><p>%s%s%s</p></div>', sprintf(_('Successfully created tasks for deployment to the following Hosts'), $Data instanceof Group ? $Host->getImage()->get('name') : $Data->getImage()->get('name')), $_REQUEST['scheduleType'] == 'cron' ? sprintf('%s: %s', _('Cron Schedule'), implode(' ', array($_REQUEST['scheduleCronMin'], $_REQUEST['scheduleCronHour'], $_REQUEST['scheduleCronDOM'], $_REQUEST['scheduleCronMonth'], $_REQUEST['scheduleCronDOW']))) : '', $_REQUEST['scheduleType'] == 'single' ? sprintf('%s: %s', _('Scheduled to start at'), $scheduleDeployTime->format('Y/m/d H:i')) : '', count($success) ? sprintf('<ul>%s</ul>', implode('', $success)) : ''); } }