コード例 #1
0
ファイル: Manager.php プロジェクト: mheydt/scalr
 public static function extendMessage(Scalr_Messaging_Msg $message, AbstractServerEvent $event, DBServer $eventServer, DBServer $targetServer)
 {
     $db = \Scalr::getDb();
     $retval = array();
     try {
         $scripts = self::getEventScriptList($event, $eventServer, $targetServer);
         if (count($scripts) > 0) {
             foreach ($scripts as $script) {
                 $itm = new stdClass();
                 // Script
                 $itm->asynchronous = $script['issync'] == 1 ? '0' : '1';
                 $itm->timeout = $script['timeout'];
                 if ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_SCALR) {
                     $itm->name = $script['name'];
                     $itm->body = $script['body'];
                 } elseif ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_LOCAL) {
                     $itm->name = "local-" . crc32($script['path']) . mt_rand(100, 999);
                     $itm->path = $script['path'];
                 } elseif ($script['type'] == self::ORCHESTRATION_SCRIPT_TYPE_CHEF) {
                     $itm->name = "chef-" . crc32($script['path']) . mt_rand(100, 999);
                     $itm->chef = $script['chef'];
                 }
                 if ($script['run_as']) {
                     $itm->runAs = $script['run_as'];
                 }
                 $itm->executionId = $script['execution_id'];
                 $retval[] = $itm;
                 $event->scriptsCount++;
             }
         }
     } catch (Exception $e) {
         $scriptingError = $e->getMessage();
     }
     $message->scripts = $retval;
     $message->eventId = $event->GetEventID();
     $message->debugScriptingCount = count($scripts);
     $message->debugScriptingError = $scriptingError;
     $message->setGlobalVariables($targetServer, true, $event);
     return $message;
 }