35 ->
set(
'stateID', self::getCheckedInState())
36 ->set(
'checkinTime', self::formatTime(
'now',
'Y-m-d H:i:s'))
39 throw new Exception(_(
'Failed to update task'));
41 if ($this->imagingTask) {
44 self::getSubObjectIDs(
45 'MulticastSessionAssociation',
47 'taskID' => $this->
Task->
get(
'id')
56 if (!$MulticastSession->isValid()) {
57 throw new Exception(_(
'Invalid Multicast Session'));
59 if ($MulticastSession->get(
'clients') < 0) {
62 $clients = $MulticastSession->get(
'clients') + 1;
65 ->set(
'clients', $clients);
66 if (!$MulticastSession->save()) {
67 throw new Exception(_(
'Failed to update Session'));
73 $MulticastSession->get(
'image')
78 self::getClass(
'StorageNode', $this->
Task->
get(
'storagenodeID')),
81 if ($MulticastSession->get(
'stateID') == 1) {
89 throw new Exception(
$msg);
92 self::$HookManager->processEvent(
100 self::$HookManager->processEvent(
107 $method =
'getOptimalStorageNode';
109 || $this->Task->isMulticast()
111 $method =
'getMasterStorageNode';
122 $this->
Task->
get(
'storagenodeID')
132 _(
'The node trying to be used is currently'),
134 _(
'On reboot we will try to find a new node'),
137 throw new Exception(
$msg);
142 $groupOpenSlots = $totalSlots - $usedSlots;
143 if ($groupOpenSlots < 1) {
151 throw new Exception(
$msg);
153 if ($groupOpenSlots <= $inFront) {
156 _(
'There are open slots'),
159 _(
'before me on this node')
161 throw new Exception(
$msg);
173 throw new Exception(_(
'Failed to update/create image log'));
177 ->
set(
'stateID', self::getProgressState())
178 ->set(
'checkInTime', self::formatTime(
'now',
'Y-m-d H:i:s'));
180 throw new Exception(_(
'Failed to update Task'));
183 throw new Exception(_(
'Failed to update/create task log'));
185 self::$EventManager->notify(
192 }
catch (Exception $e) {
193 echo $e->getMessage();
208 ) = self::getSubObjectIDs(
225 if (!$emailAction || !$emailAddress) {
232 $SnapinTasks = self::getSubObjectIDs(
235 'stateID' => self::getQueuedStates(),
240 $SnapinNames = array();
242 $SnapinNames = self::getSubObjectIDs(
245 'id' => $SnapinTasks,
251 $emailBinary =
'/usr/sbin/sendmail -t -f noreply@fogserver.com -i';
253 $reg =
'#\$\{server-name\}#';
254 $nodeName =
'fogserver';
258 $emailBinary = preg_replace(
264 $fromEmail =
'noreply@fogserver.com';
266 $fromEmail = preg_replace(
272 "From: %s\r\nX-Mailer: PHP/%s",
279 $primaryUser = ucwords(
282 $replaceUser =
'#\$\{user-name\}#';
283 $emailAddress = preg_replace(
288 $emailAddress = preg_replace(
296 $Snapins = implode(
',', (array)$SnapinNames);
298 sprintf(
"%s:-\n", _(
'Machine Details')) =>
'',
299 sprintf(
"\n%s: ", _(
'Host Name')) =>
self::$Host->
get(
'name'),
300 sprintf(
"\n%s: ", _(
'Computer Model')) =>
$Inventory->get(
'sysproduct'),
301 sprintf(
"\n%s: ", _(
'Serial Number')) =>
$Inventory->get(
'sysserial'),
302 sprintf(
"\n%s: ", _(
'MAC Address')) =>
$mac,
304 sprintf(
"\n%s: ", _(
'Image Used')) => $ImageName,
305 sprintf(
"\n%s: ", _(
'Snapin Used')) => $Snapins,
307 sprintf(
"\n%s: ", _(
'Imaged By')) => $engineer,
308 sprintf(
"\n%s: ", _(
'Imaged For')) => $primaryUser
310 self::$HookManager->processEvent(
318 foreach ((array)$email as $key => &
$val) {
319 printf(
'%s%s', $key,
$val);
322 $emailMe = ob_get_clean();
326 _(
'Image Task Completed')
365 if (!(isset($_REQUEST[
'mac'])
366 && is_string($_REQUEST[
'mac']))
370 $macftp = strtolower(
378 basename($_REQUEST[
'mac'])
389 $this->Image->get(
'path')
397 ->rename($src, $dest)
400 if ($this->
Image->
get(
'format') == 1) {
403 ->set(
'srvsize', self::getFilesize($dest));
408 self::niceDate()->format(
'Y-m-d H:i:s')
425 $MCTask = self::getClass(
'MulticastSessionAssociation')
430 $MulticastSession = $MCTask->getMulticastSession();
431 if ($MulticastSession->get(
'clients') < 0) {
434 $clients = $MulticastSession->get(
'clients') - 1;
437 ->set(
'clients', $clients)
442 ->set(
'sec_tok',
'');
445 ->set(
'deployed', self::niceDate()->format(
'Y-m-d H:i:s'));
448 $this->_moveUpload();
452 ->set(
'percent', 100)
453 ->set(
'stateID', self::getCompleteState());
455 throw new Exception(_(
'Failed to update Host'));
458 throw new Exception(_(
'Failed to update Task'));
462 'HOST_TASKING_COMPLETE',
465 'Task' => &$this->
Task
468 if (!$this->taskLog()) {
469 throw new Exception(_(
'Failed to update task log'));
471 if ($this->imagingTask) {
472 if (!$this->imageLog(
false)) {
473 throw new Exception(_(
'Failed to update imaging log'));
476 self::$EventManager->notify(
477 'HOST_IMAGE_COMPLETE',
483 }
catch (Exception $e) {
484 echo $e->getMessage();