当前位置: 首页>>代码示例>>PHP>>正文


PHP DBServer::LoadByFarmRoleIDAndIndex方法代码示例

本文整理汇总了PHP中DBServer::LoadByFarmRoleIDAndIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP DBServer::LoadByFarmRoleIDAndIndex方法的具体用法?PHP DBServer::LoadByFarmRoleIDAndIndex怎么用?PHP DBServer::LoadByFarmRoleIDAndIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBServer的用法示例。


在下文中一共展示了DBServer::LoadByFarmRoleIDAndIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xListTasksAction

 public function xListTasksAction()
 {
     $this->request->defineParams(array('sort' => array('type' => 'json')));
     $sql = 'SELECT id, name, type, comments, target_id as targetId, target_server_index as targetServerIndex, target_type as targetType, start_time as startTime,
         end_time as endTime, last_start_time as lastStartTime, restart_every as restartEvery, config, order_index as orderIndex,
         status, timezone FROM `scheduler` WHERE `env_id` = ? AND :FILTER:';
     $response = $this->buildResponseFromSql2($sql, array('id', 'name', 'type', 'startTime', 'endTime', 'lastStartTime', 'timezone', 'orderIndex', 'status', 'timezone'), array('id', 'name'), array($this->getEnvironmentId()));
     foreach ($response['data'] as &$row) {
         switch ($row['targetType']) {
             case Scalr_SchedulerTask::TARGET_FARM:
                 try {
                     $DBFarm = DBFarm::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarm->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_ROLE:
                 try {
                     $DBFarmRole = DBFarmRole::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarmRole->GetRoleObject()->name;
                     $row['targetFarmId'] = $DBFarmRole->FarmID;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_INSTANCE:
                 try {
                     $DBServer = DBServer::LoadByFarmRoleIDAndIndex($row['targetId'], $row['targetServerIndex']);
                     $row['targetName'] = "({$DBServer->remoteIp})";
                     $DBFarmRole = $DBServer->GetFarmRoleObject();
                     $row['targetFarmId'] = $DBServer->farmId;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                     $row['targetRoleId'] = $DBServer->farmRoleId;
                     $row['targetRoleName'] = $DBFarmRole->GetRoleObject()->name;
                 } catch (Exception $e) {
                 }
                 break;
             default:
                 break;
         }
         $row['type'] = Scalr_SchedulerTask::getTypeByName($row['type']);
         $row['startTime'] = $row['startTime'] ? Scalr_Util_DateTime::convertDateTime($row['startTime'], $row['timezone']) : 'Now';
         $row['endTime'] = $row['endTime'] ? Scalr_Util_DateTime::convertDateTime($row['endTime'], $row['timezone']) : 'Never';
         $row['lastStartTime'] = $row['lastStartTime'] ? Scalr_Util_DateTime::convertDateTime($row['lastStartTime'], $row['timezone']) : '';
         $row['config'] = unserialize($row['config']);
         $script = Script::findPk($row['config']['scriptId']);
         if ($script) {
             $row['config']['scriptName'] = $script->name;
         }
     }
     $this->response->data($response);
 }
开发者ID:rickb838,项目名称:scalr,代码行数:52,代码来源:Schedulertasks.php

示例2: farmUpdateRoleSettings

 public static function farmUpdateRoleSettings(DBFarmRole $dbFarmRole, $oldSettings, $newSettings)
 {
     $db = \Scalr::getDb();
     $dbFarm = $dbFarmRole->GetFarmObject();
     if ($newSettings[Entity\FarmRoleSetting::CLOUDSTACK_NETWORK_ID] == 'SCALR_MANUAL') {
         return true;
     }
     $dbFarmRole->SetSetting(Entity\FarmRoleSetting::CLOUDSTACK_STATIC_NAT_MAP, null, Entity\FarmRoleSetting::TYPE_LCL);
     $cs = $dbFarm->GetEnvironmentObject()->cloudstack($dbFarmRole->Platform);
     // Disassociate IP addresses if checkbox was unchecked
     if (!$newSettings[Entity\FarmRoleSetting::CLOUDSTACK_USE_STATIC_NAT] && $oldSettings[Entity\FarmRoleSetting::CLOUDSTACK_USE_STATIC_NAT]) {
         $eips = $db->Execute("\n                SELECT * FROM elastic_ips WHERE farm_roleid = ?\n            ", array($dbFarmRole->ID));
         while ($eip = $eips->FetchRow()) {
             try {
                 $cs->disassociateIpAddress($eip['allocation_id']);
             } catch (Exception $e) {
             }
         }
         $db->Execute("DELETE FROM elastic_ips WHERE farm_roleid = ?", array($dbFarmRole->ID));
     }
     //TODO: Handle situation when tab was not opened, but max instances setting was changed.
     if ($newSettings[Entity\FarmRoleSetting::CLOUDSTACK_STATIC_NAT_MAP] && $newSettings[Entity\FarmRoleSetting::CLOUDSTACK_USE_STATIC_NAT]) {
         $map = explode(";", $newSettings[Entity\FarmRoleSetting::CLOUDSTACK_STATIC_NAT_MAP]);
         foreach ($map as $ipconfig) {
             list($serverIndex, $ipAddress) = explode("=", $ipconfig);
             if (!$serverIndex) {
                 continue;
             }
             $dbServer = false;
             try {
                 $dbServer = \DBServer::LoadByFarmRoleIDAndIndex($dbFarmRole->ID, $serverIndex);
                 if ($dbServer->remoteIp == $ipAddress) {
                     continue;
                 }
                 // Remove old association
                 $db->Execute("\n                        DELETE FROM elastic_ips WHERE farm_roleid = ? AND instance_index=?\n                    ", array($dbFarmRole->ID, $serverIndex));
             } catch (Exception $e) {
             }
             // Allocate new IP if needed
             if ($ipAddress == "" || $ipAddress == '0.0.0.0') {
                 if ($dbServer) {
                     $ipAddress = self::setStaticNatForServer($dbServer);
                 } else {
                     continue;
                 }
             } else {
                 //Remove old IP association
                 $db->Execute("\n                        DELETE FROM elastic_ips WHERE ipaddress=?\n                    ", array($ipAddress));
                 $requestObject = new ListIpAddressesData();
                 $requestObject->ipaddress = $ipAddress;
                 $info = $cs->listPublicIpAddresses($requestObject);
                 $info = count($info > 0) ? $info[0] : null;
                 // Associate IP with server in our db
                 $db->Execute("INSERT INTO elastic_ips SET\n                        env_id=?,\n                        farmid=?,\n                        farm_roleid=?,\n                        ipaddress=?,\n                        state='0',\n                        instance_id='',\n                        clientid=?,\n                        instance_index=?,\n                        allocation_id=?\n                    ", array($dbFarm->EnvID, $dbFarmRole->FarmID, $dbFarmRole->ID, $ipAddress, $dbFarm->ClientID, $serverIndex, $info->id));
             }
             $ipInfo = $db->GetRow("SELECT allocation_id FROM elastic_ips WHERE ipaddress = ? LIMIT 1", array($ipAddress));
             // Associate IP on AWS with running server
             if ($dbServer) {
                 try {
                     $db->Execute("UPDATE elastic_ips SET state='1', server_id = ? WHERE ipaddress = ?", array($dbServer->serverId, $ipAddress));
                     if ($dbServer->remoteIp != $ipAddress) {
                         if ($dbServer && $dbServer->status == \SERVER_STATUS::RUNNING) {
                             $fireEvent = self::associateIpAddress($dbServer, $ipAddress, $ipInfo['allocation_id']);
                         }
                     }
                     if ($fireEvent) {
                         $event = new \IPAddressChangedEvent($dbServer, $ipAddress, $dbServer->localIp);
                         \Scalr::FireEvent($dbServer->farmId, $event);
                     }
                 } catch (Exception $e) {
                 }
             }
         }
     }
 }
开发者ID:scalr,项目名称:scalr,代码行数:75,代码来源:CloudstackHelper.php

示例3: farmUpdateRoleSettings

 public static function farmUpdateRoleSettings(DBFarmRole $DBFarmRole, $oldSettings, $newSettings)
 {
     $db = \Scalr::getDb();
     $DBFarm = $DBFarmRole->GetFarmObject();
     $DBFarmRole->SetSetting(DBFarmRole::SETTING_AWS_ELASIC_IPS_MAP, null, DBFarmRole::TYPE_LCL);
     $isVPC = $DBFarm->GetSetting(DBFarm::SETTING_EC2_VPC_ID);
     $aws = $DBFarm->GetEnvironmentObject()->aws($DBFarmRole->CloudLocation);
     // Disassociate IP addresses if checkbox was unchecked
     if (!$newSettings[DBFarmRole::SETTING_AWS_USE_ELASIC_IPS] && $oldSettings[DBFarmRole::SETTING_AWS_USE_ELASIC_IPS]) {
         $eips = $db->Execute("\n                SELECT * FROM elastic_ips WHERE farm_roleid = ?\n            ", array($DBFarmRole->ID));
         while ($eip = $eips->FetchRow()) {
             try {
                 $aws->ec2->address->disassociate($eip['ipaddress']);
             } catch (Exception $e) {
             }
         }
         $db->Execute("\n                DELETE FROM elastic_ips\n                WHERE farm_roleid = ?\n            ", array($DBFarmRole->ID));
     }
     //TODO: Handle situation when tab was not opened, but max instances setting was changed.
     if ($newSettings[DBFarmRole::SETTING_AWS_ELASIC_IPS_MAP] && $newSettings[DBFarmRole::SETTING_AWS_USE_ELASIC_IPS]) {
         $map = explode(";", $newSettings[DBFarmRole::SETTING_AWS_ELASIC_IPS_MAP]);
         foreach ($map as $ipconfig) {
             list($serverIndex, $ipAddress) = explode("=", $ipconfig);
             if (!$serverIndex) {
                 continue;
             }
             try {
                 $dbServer = DBServer::LoadByFarmRoleIDAndIndex($DBFarmRole->ID, $serverIndex);
             } catch (Exception $e) {
             }
             // Allocate new IP if needed
             if (!$ipAddress || $ipAddress == '0.0.0.0') {
                 if ($dbServer) {
                     $domain = $isVPC ? 'vpc' : null;
                     $address = $aws->ec2->address->allocate($domain);
                     $ipAddress = $address->publicIp;
                     $allocationId = $address->allocationId;
                 } else {
                     continue;
                 }
             }
             // Remove old association
             $db->Execute("\n                    DELETE FROM elastic_ips\n                    WHERE farm_roleid = ? AND instance_index=?\n                ", array($DBFarmRole->ID, $serverIndex));
             if ($ipAddress) {
                 //Remove old IP association
                 $db->Execute("\n                        DELETE FROM elastic_ips\n                        WHERE ipaddress=?\n                    ", array($ipAddress));
                 if (!$allocationId && $isVPC) {
                     $allocationId = $aws->ec2->address->describe($ipAddress)->get(0)->allocationId;
                 }
                 // Associate IP with server in our db
                 $db->Execute("\n                        INSERT INTO elastic_ips\n                        SET env_id=?,\n                            farmid=?,\n                            farm_roleid=?,\n                            ipaddress=?,\n                            state='0',\n                            instance_id='',\n                            clientid=?,\n                            instance_index=?,\n                            allocation_id=?\n                    ", array($DBFarm->EnvID, $DBFarmRole->FarmID, $DBFarmRole->ID, $ipAddress, $DBFarm->ClientID, $serverIndex, $allocationId));
                 // Associate IP on AWS with running server
                 try {
                     $dbServer = DBServer::LoadByFarmRoleIDAndIndex($DBFarmRole->ID, $serverIndex);
                     $db->Execute("\n                            UPDATE elastic_ips\n                            SET state='1',\n                                server_id = ?\n                            WHERE ipaddress = ?\n                        ", array($dbServer->serverId, $ipAddress));
                     $update = false;
                     if ($dbServer->remoteIp != $ipAddress) {
                         if ($dbServer && $dbServer->status == SERVER_STATUS::RUNNING) {
                             $fireEvent = self::associateIpAddress($dbServer, $ipAddress, $isVPC ? $allocationId : null);
                         }
                     }
                     if ($fireEvent) {
                         $event = new IPAddressChangedEvent($dbServer, $ipAddress, $dbServer->localIp);
                         Scalr::FireEvent($dbServer->farmId, $event);
                     }
                 } catch (Exception $e) {
                 }
             } else {
                 Logger::getLogger(LOG_CATEGORY::FARM)->fatal(sprintf(_("Cannot allocate elastic ip address for instance %s on farm %s (2)"), $dbServer->serverId, $DBFarm->Name));
             }
         }
     }
 }
开发者ID:recipe,项目名称:scalr,代码行数:73,代码来源:Eip.php

示例4: xListAction

 public function xListAction()
 {
     $sql = "SELECT `id`, `name`, `type`, `comments`, `target_id` as `targetId`, `target_server_index` as `targetServerIndex`, `target_type` as `targetType`, `start_time` as `startTime`,\n            `last_start_time` as `lastStartTime`, `restart_every` as `restartEvery`, `config`, `status`, `timezone` FROM `scheduler` WHERE `env_id` = ? AND :FILTER:";
     $response = $this->buildResponseFromSql2($sql, ['id', 'name', 'type', 'startTime', 'lastStartTime', 'timezone', 'status'], ['name'], [$this->getEnvironmentId()]);
     foreach ($response['data'] as &$row) {
         switch ($row['targetType']) {
             case Scalr_SchedulerTask::TARGET_FARM:
                 try {
                     $DBFarm = DBFarm::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarm->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_ROLE:
                 try {
                     $DBFarmRole = DBFarmRole::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarmRole->GetRoleObject()->name;
                     $row['targetFarmId'] = $DBFarmRole->FarmID;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_INSTANCE:
                 try {
                     $DBServer = DBServer::LoadByFarmRoleIDAndIndex($row['targetId'], $row['targetServerIndex']);
                     $row['targetName'] = "({$DBServer->remoteIp})";
                     $DBFarmRole = $DBServer->GetFarmRoleObject();
                     $row['targetFarmId'] = $DBServer->farmId;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                     $row['targetRoleId'] = $DBServer->farmRoleId;
                     $row['targetRoleName'] = $DBFarmRole->GetRoleObject()->name;
                 } catch (Exception $e) {
                 }
                 break;
             default:
                 break;
         }
         //$row['type'] = Scalr_SchedulerTask::getTypeByName($row['type']);
         $row['startTime'] = $row['startTime'] ? Scalr_Util_DateTime::convertDateTime($row['startTime'], $row['timezone']) : 'Now';
         $row['lastStartTime'] = $row['lastStartTime'] ? Scalr_Util_DateTime::convertDateTime($row['lastStartTime'], $row['timezone']) : '';
         $row['config'] = unserialize($row['config']);
         $script = Script::findPk($row['config']['scriptId']);
         if (!empty($script)) {
             $row['config']['scriptName'] = $script->name;
         }
     }
     $this->response->data($response);
 }
开发者ID:scalr,项目名称:scalr,代码行数:48,代码来源:Schedulertasks.php

示例5: xTransferAction

 public function xTransferAction()
 {
     foreach ($this->db->GetAll('SELECT * FROM scheduler_tasks WHERE client_id = ?', array($this->user->getAccountId())) as $taskOld) {
         $task = Scalr_SchedulerTask::init();
         $task->name = $taskOld['task_name'];
         $task->type = $taskOld['task_type'];
         $task->targetId = $taskOld['target_id'];
         $task->targetType = $taskOld['target_type'];
         $task->timezone = $taskOld['timezone'];
         $timezone = new DateTimeZone($taskOld['timezone']);
         $startTm = new DateTime($taskOld['start_time_date']);
         $endTm = new DateTime($taskOld['end_time_date']);
         $lastStartTm = new DateTime($taskOld['last_start_time']);
         // old time in timezone (from record) to server time (timezone leave for UI)
         Scalr_Util_DateTime::convertDateTime($startTm, null, $timezone);
         Scalr_Util_DateTime::convertDateTime($endTm, null, $timezone);
         Scalr_Util_DateTime::convertDateTime($lastStartTm, null, $timezone);
         $task->startTime = $startTm->format('Y-m-d H:i:s');
         $task->endTime = $endTm->format('Y-m-d H:i:s');
         $task->lastStartTime = $taskOld['last_start_time'] ? $lastStartTm->format('Y-m-d H:i:s') : NULL;
         switch ($taskOld['target_type']) {
             case SCRIPTING_TARGET::FARM:
                 try {
                     $DBFarm = DBFarm::LoadByID($taskOld['target_id']);
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
             case SCRIPTING_TARGET::ROLE:
                 try {
                     $DBFarmRole = DBFarmRole::LoadByID($taskOld['target_id']);
                     $a = $DBFarmRole->GetRoleObject()->name;
                     $a = $DBFarmRole->FarmID;
                     $a = $DBFarmRole->GetFarmObject()->Name;
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
             case SCRIPTING_TARGET::INSTANCE:
                 $serverArgs = explode(':', $taskOld['target_id']);
                 try {
                     $DBServer = DBServer::LoadByFarmRoleIDAndIndex($serverArgs[0], $serverArgs[1]);
                     $a = "({$DBServer->remoteIp})";
                     $DBFarmRole = $DBServer->GetFarmRoleObject();
                     $a = $DBServer->farmId;
                     $a = $DBFarmRole->GetFarmObject()->Name;
                     $a = $DBServer->farmRoleId;
                     $a = $DBFarmRole->GetRoleObject()->name;
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
         }
         $config = unserialize($taskOld['task_config']);
         $r = array();
         switch ($task->type) {
             case Scalr_SchedulerTask::SCRIPT_EXEC:
                 $r['scriptId'] = (string) $config['script_id'];
                 unset($config['script_id']);
                 $r['scriptIsSync'] = (string) $config['issync'];
                 unset($config['issync']);
                 $r['scriptTimeout'] = (string) $config['timeout'];
                 unset($config['timeout']);
                 $r['scriptVersion'] = (string) $config['revision'];
                 unset($config['revision']);
                 $r['scriptOptions'] = $config;
                 break;
             case Scalr_SchedulerTask::LAUNCH_FARM:
                 break;
             case Scalr_SchedulerTask::TERMINATE_FARM:
                 $r['deleteDNSZones'] = $config['deleteDNS'];
                 $r['deleteCloudObjects'] = $config['keep_elastic_ips'] == '1' || $config['keep_ebs'] == '1' ? NULL : '1';
                 break;
         }
         $task->config = $r;
         $task->restartEvery = $taskOld['restart_every'];
         $task->orderIndex = $taskOld['order_index'];
         $task->status = $taskOld['status'];
         $task->accountId = $taskOld['client_id'];
         $task->envId = $taskOld['env_id'];
         $task->save();
     }
     $this->db->Execute('DELETE FROM scheduler_tasks WHERE client_id = ?', array($this->user->getAccountId()));
     $this->response->success('All tasks transfered successfully');
 }
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:85,代码来源:Schedulertasks.php

示例6: getFarm2

 public function getFarm2($farmId)
 {
     $dbFarm = DBFarm::LoadByID($farmId);
     $this->user->getPermissions()->validate($dbFarm);
     $farmRoles = array();
     $variables = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), Scalr_Scripting_GlobalVariables::SCOPE_FARM);
     $farmRoleVariables = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), Scalr_Scripting_GlobalVariables::SCOPE_FARMROLE);
     foreach ($dbFarm->GetFarmRoles() as $dbFarmRole) {
         $scripts = $this->db->GetAll("\n                SELECT farm_role_scripts.*, scripts.name, scripts.os\n                FROM farm_role_scripts\n                LEFT JOIN scripts ON scripts.id = farm_role_scripts.scriptid\n                WHERE farm_roleid=? AND issystem='1'\n            ", array($dbFarmRole->ID));
         $scriptsObject = array();
         foreach ($scripts as $script) {
             if (!empty($script['scriptid']) && $script['script_type'] == Scalr_Scripting_Manager::ORCHESTRATION_SCRIPT_TYPE_SCALR || !empty($script['script_path']) && $script['script_type'] == Scalr_Scripting_Manager::ORCHESTRATION_SCRIPT_TYPE_LOCAL || !empty($script['params']) && $script['script_type'] == Scalr_Scripting_Manager::ORCHESTRATION_SCRIPT_TYPE_CHEF) {
                 $s = array('script_type' => $script['script_type'], 'script_id' => (int) $script['scriptid'], 'script' => $script['name'], 'os' => $script['os'], 'params' => unserialize($script['params']), 'target' => $script['target'], 'version' => (int) $script['version'], 'timeout' => $script['timeout'], 'isSync' => (int) $script['issync'], 'order_index' => $script['order_index'], 'event' => $script['event_name'], 'script_path' => $script['script_path'], 'run_as' => $script['run_as']);
                 if ($script['target'] == Script::TARGET_BEHAVIORS || $script['target'] == Script::TARGET_ROLES || $script['target'] == Script::TARGET_FARMROLES) {
                     switch ($script['target']) {
                         case $script['target'] == Script::TARGET_ROLES:
                             $varName = 'target_roles';
                             break;
                         case $script['target'] == Script::TARGET_FARMROLES:
                             $varName = 'target_farmroles';
                             break;
                         case $script['target'] == Script::TARGET_BEHAVIORS:
                             $varName = 'target_behaviors';
                             break;
                     }
                     $s[$varName] = array();
                     $r = $this->db->GetAll("SELECT `target` FROM farm_role_scripting_targets WHERE farm_role_script_id = ?", array($script['id']));
                     foreach ($r as $v) {
                         array_push($s[$varName], $v['target']);
                     }
                 }
                 $scriptsObject[] = $s;
             }
         }
         //Scripting params
         $scriptingParams = $this->db->Execute("\n                SELECT * FROM farm_role_scripting_params\n                WHERE farm_role_id = ? AND farm_role_script_id = '0'\n            ", array($dbFarmRole->ID));
         $sParams = array();
         while ($p = $scriptingParams->FetchRow()) {
             $sParams[] = array('hash' => $p['hash'], 'role_script_id' => $p['role_script_id'], 'params' => unserialize($p['params']));
         }
         $scalingManager = new Scalr_Scaling_Manager($dbFarmRole);
         $scaling = array();
         foreach ($scalingManager->getFarmRoleMetrics() as $farmRoleMetric) {
             $scaling[$farmRoleMetric->metricId] = $farmRoleMetric->getSettings();
         }
         $dbPresets = $this->db->GetAll("SELECT * FROM farm_role_service_config_presets WHERE farm_roleid=?", array($dbFarmRole->ID));
         $presets = array();
         foreach ($dbPresets as $preset) {
             $presets[$preset['behavior']] = $preset['preset_id'];
         }
         if ($dbFarmRole->NewRoleID) {
             $roleName = DBRole::loadById($dbFarmRole->NewRoleID)->name;
             $isBundling = true;
         } else {
             $roleName = $dbFarmRole->GetRoleObject()->name;
             $isBundling = false;
         }
         $storages = array('configs' => $dbFarmRole->getStorage()->getConfigs());
         foreach ($dbFarmRole->getStorage()->getVolumes() as $configKey => $config) {
             $storages['devices'][$configKey] = array();
             foreach ($config as $device) {
                 $info = array('farmRoleId' => $device->farmRoleId, 'placement' => $device->placement, 'serverIndex' => $device->serverIndex, 'storageId' => $device->storageId, 'storageConfigId' => $device->storageConfigId, 'status' => $device->status);
                 try {
                     $server = DBServer::LoadByFarmRoleIDAndIndex($device->farmRoleId, $device->serverIndex);
                     if ($server->status != SERVER_STATUS::TERMINATED && $server->status != SERVER_STATUS::TROUBLESHOOTING) {
                         $info['serverId'] = $server->serverId;
                         $info['serverInstanceId'] = $server->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID);
                     }
                 } catch (Exception $e) {
                     $this->response->debugException($e);
                 }
                 $storages['devices'][$configKey][] = $info;
             }
         }
         $image = $dbFarmRole->GetRoleObject()->__getNewRoleObject()->getImage($dbFarmRole->Platform, $dbFarmRole->CloudLocation);
         $securityGroups = $this->getInitialSecurityGroupsList($dbFarmRole);
         $farmRoles[] = array('farm_role_id' => $dbFarmRole->ID, 'alias' => $dbFarmRole->Alias ? $dbFarmRole->Alias : $dbFarmRole->GetRoleObject()->name, 'role_id' => $dbFarmRole->RoleID, 'platform' => $dbFarmRole->Platform, 'os' => $dbFarmRole->GetRoleObject()->getOs()->name, 'os_family' => $dbFarmRole->GetRoleObject()->getOs()->family, 'os_generation' => $dbFarmRole->GetRoleObject()->getOs()->generation, 'os_version' => $dbFarmRole->GetRoleObject()->getOs()->version, 'osId' => $dbFarmRole->GetRoleObject()->getOs()->id, 'generation' => $dbFarmRole->GetRoleObject()->generation, 'group' => $dbFarmRole->GetRoleObject()->getCategoryName(), 'cat_id' => $dbFarmRole->GetRoleObject()->catId, 'name' => $roleName, 'is_bundle_running' => $isBundling, 'behaviors' => implode(",", $dbFarmRole->GetRoleObject()->getBehaviors()), 'scripting' => $scriptsObject, 'scripting_params' => $sParams, 'settings' => $dbFarmRole->GetAllSettings(), 'cloud_location' => $dbFarmRole->CloudLocation, 'launch_index' => (int) $dbFarmRole->LaunchIndex, 'scaling' => $scaling, 'config_presets' => $presets, 'image' => $image->getImage(), 'storages' => $storages, 'variables' => $farmRoleVariables->getValues($dbFarmRole->GetRoleID(), $dbFarm->ID, $dbFarmRole->ID), 'running_servers' => $dbFarmRole->GetRunningInstancesCount(), 'suspended_servers' => $dbFarmRole->GetSuspendedInstancesCount(), 'security_groups' => $securityGroups, 'hourly_rate' => $this->getInstanceTypeHourlyRate($dbFarmRole->Platform, $dbFarmRole->CloudLocation, $dbFarmRole->getInstanceType(), $dbFarmRole->GetRoleObject()->osFamily));
     }
     $vpc = array();
     if ($dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_ID)) {
         $vpc = array('id' => $dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_ID), 'region' => $dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_REGION));
     }
     $farmOwnerEditable = $dbFarm->createdByUserId == $this->user->getId() || $this->user->isAccountOwner() || $this->request->isFarmAllowed($dbFarm, Acl::PERM_FARMS_CHANGE_OWNERSHIP);
     return array('farm' => array('name' => $dbFarm->Name, 'description' => $dbFarm->Comments, 'rolesLaunchOrder' => $dbFarm->RolesLaunchOrder, 'timezone' => $dbFarm->GetSetting(DBFarm::SETTING_TIMEZONE), 'variables' => $variables->getValues(0, $dbFarm->ID), 'vpc' => $vpc, 'status' => $dbFarm->Status, 'hash' => $dbFarm->Hash, 'owner' => $farmOwnerEditable ? $dbFarm->createdByUserId : $dbFarm->createdByUserEmail, 'ownerEditable' => $farmOwnerEditable, 'teamOwner' => $farmOwnerEditable ? $dbFarm->teamId : ($dbFarm->teamId ? (new Scalr_Account_Team())->loadById($dbFarm->teamId)->name : ''), 'teamOwnerEditable' => $farmOwnerEditable, 'launchPermission' => $this->request->isFarmAllowed($dbFarm, Acl::PERM_FARMS_LAUNCH_TERMINATE), DBFarm::SETTING_SZR_UPD_REPOSITORY => $dbFarm->GetSetting(DBFarm::SETTING_SZR_UPD_REPOSITORY), DBFarm::SETTING_SZR_UPD_SCHEDULE => $dbFarm->GetSetting(DBFarm::SETTING_SZR_UPD_SCHEDULE)), 'roles' => $farmRoles, 'lock' => $dbFarm->isLocked(false), 'changed' => $dbFarm->changedTime);
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:85,代码来源:Builder.php

示例7: getFarm2

 public function getFarm2($farmId)
 {
     $dbFarm = DBFarm::LoadByID($farmId);
     $this->user->getPermissions()->validate($dbFarm);
     $farmRoleId = $this->getParam('farmRoleId');
     $farmRoles = array();
     $variables = new Scalr_Scripting_GlobalVariables($this->getEnvironmentId(), Scalr_Scripting_GlobalVariables::SCOPE_FARM);
     $farmRoleVariables = new Scalr_Scripting_GlobalVariables($this->getEnvironmentId(), Scalr_Scripting_GlobalVariables::SCOPE_FARMROLE);
     foreach ($dbFarm->GetFarmRoles() as $dbFarmRole) {
         if ($farmRoleId && $farmRoleId != $dbFarmRole->ID) {
             continue;
         }
         $scripts = $this->db->GetAll("\n                SELECT farm_role_scripts.*, scripts.name\n                FROM farm_role_scripts\n                LEFT JOIN scripts ON scripts.id = farm_role_scripts.scriptid\n                WHERE farm_roleid=? AND issystem='1'\n            ", array($dbFarmRole->ID));
         $scriptsObject = array();
         foreach ($scripts as $script) {
             if (!empty($script['scriptid']) || !empty($script['script_path'])) {
                 $s = array('script_id' => $script['scriptid'], 'script' => $script['name'], 'params' => unserialize($script['params']), 'target' => $script['target'], 'version' => $script['version'], 'timeout' => $script['timeout'], 'issync' => $script['issync'], 'order_index' => $script['order_index'], 'event' => $script['event_name'], 'script_path' => $script['script_path'], 'run_as' => $script['run_as']);
             }
             if ($script['target'] == Scalr_Script::TARGET_BEHAVIORS || $script['target'] == Scalr_Script::TARGET_ROLES) {
                 $varName = $script['target'] == Scalr_Script::TARGET_ROLES ? 'target_roles' : 'target_behaviors';
                 $s[$varName] = array();
                 $r = $this->db->GetAll("SELECT `target` FROM farm_role_scripting_targets WHERE farm_role_script_id = ?", array($script['id']));
                 foreach ($r as $v) {
                     array_push($s[$varName], $v['target']);
                 }
             }
             $scriptsObject[] = $s;
         }
         //Scripting params
         $scriptingParams = $this->db->Execute("\n                SELECT * FROM farm_role_scripting_params\n                WHERE farm_role_id = ? AND farm_role_script_id = '0'\n            ", array($dbFarmRole->ID));
         $sParams = array();
         while ($p = $scriptingParams->FetchRow()) {
             $sParams[] = array('hash' => $p['hash'], 'role_script_id' => $p['role_script_id'], 'params' => unserialize($p['params']));
         }
         $scalingManager = new Scalr_Scaling_Manager($dbFarmRole);
         $scaling = array();
         foreach ($scalingManager->getFarmRoleMetrics() as $farmRoleMetric) {
             $scaling[$farmRoleMetric->metricId] = $farmRoleMetric->getSettings();
         }
         $dbPresets = $this->db->GetAll("SELECT * FROM farm_role_service_config_presets WHERE farm_roleid=?", array($dbFarmRole->ID));
         $presets = array();
         foreach ($dbPresets as $preset) {
             $presets[$preset['behavior']] = $preset['preset_id'];
         }
         if ($dbFarmRole->NewRoleID) {
             $roleName = DBRole::loadById($dbFarmRole->NewRoleID)->name;
             $isBundling = true;
         } else {
             $roleName = $dbFarmRole->GetRoleObject()->name;
             $isBundling = false;
         }
         $imageDetails = $dbFarmRole->GetRoleObject()->getImageDetails($dbFarmRole->Platform, $dbFarmRole->CloudLocation);
         $storages = array('configs' => $dbFarmRole->getStorage()->getConfigs());
         foreach ($dbFarmRole->getStorage()->getVolumes() as $configKey => $config) {
             $storages['devices'][$configKey] = array();
             foreach ($config as $device) {
                 $info = array('farmRoleId' => $device->farmRoleId, 'placement' => $device->placement, 'serverIndex' => $device->serverIndex, 'storageId' => $device->storageId, 'storageConfigId' => $device->storageConfigId, 'status' => $device->status);
                 try {
                     $server = DBServer::LoadByFarmRoleIDAndIndex($device->farmRoleId, $device->serverIndex);
                     if ($server->status != SERVER_STATUS::TERMINATED && $server->status != SERVER_STATUS::TROUBLESHOOTING) {
                         $info['serverId'] = $server->serverId;
                         $info['serverInstanceId'] = $server->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID);
                     }
                 } catch (Exception $e) {
                     $this->response->varDump($e->getMessage());
                     $this->response->varDump($e->getTraceAsString());
                 }
                 $storages['devices'][$configKey][] = $info;
             }
         }
         $imageInfo = $dbFarmRole->GetRoleObject()->getImageDetails($dbFarmRole->Platform, $dbFarmRole->CloudLocation);
         $architecture = $imageInfo['architecture'];
         $securityGroups = $this->getInitialSecurityGroupsList($dbFarmRole);
         $farmRoles[] = array('farm_role_id' => $dbFarmRole->ID, 'alias' => $dbFarmRole->Alias ? $dbFarmRole->Alias : $dbFarmRole->GetRoleObject()->name, 'role_id' => $dbFarmRole->RoleID, 'platform' => $dbFarmRole->Platform, 'os' => $dbFarmRole->GetRoleObject()->os, 'os_family' => $dbFarmRole->GetRoleObject()->osFamily, 'os_generation' => $dbFarmRole->GetRoleObject()->osGeneration, 'os_version' => $dbFarmRole->GetRoleObject()->osVersion, 'generation' => $dbFarmRole->GetRoleObject()->generation, 'group' => $dbFarmRole->GetRoleObject()->getCategoryName(), 'cat_id' => $dbFarmRole->GetRoleObject()->catId, 'arch' => $architecture, 'name' => $roleName, 'is_bundle_running' => $isBundling, 'behaviors' => implode(",", $dbFarmRole->GetRoleObject()->getBehaviors()), 'scripting' => $scriptsObject, 'scripting_params' => $sParams, 'settings' => $dbFarmRole->GetAllSettings(), 'cloud_location' => $dbFarmRole->CloudLocation, 'launch_index' => (int) $dbFarmRole->LaunchIndex, 'scaling' => $scaling, 'config_presets' => $presets, 'tags' => $dbFarmRole->GetRoleObject()->getTags(), 'storages' => $storages, 'variables' => $farmRoleVariables->getValues($dbFarmRole->GetRoleID(), $dbFarm->ID, $dbFarmRole->ID), 'running_servers' => $dbFarmRole->GetRunningInstancesCount(), 'security_groups' => $securityGroups);
     }
     $vpc = array();
     if ($dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_ID)) {
         $vpc = array('id' => $dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_ID), 'region' => $dbFarm->GetSetting(DBFarm::SETTING_EC2_VPC_REGION));
     }
     return array('farm' => array('name' => $dbFarm->Name, 'description' => $dbFarm->Comments, 'rolesLaunchOrder' => $dbFarm->RolesLaunchOrder, 'timezone' => $dbFarm->GetSetting(DBFarm::SETTING_TIMEZONE), 'variables' => $variables->getValues(0, $dbFarm->ID), 'vpc' => $vpc, 'status' => $dbFarm->Status), 'roles' => $farmRoles, 'lock' => $dbFarm->isLocked(false), 'changed' => $dbFarm->changedTime);
 }
开发者ID:recipe,项目名称:scalr,代码行数:81,代码来源:Builder.php

示例8: farmUpdateRoleSettings

 public static function farmUpdateRoleSettings(DBFarmRole $dbFarmRole, $oldSettings, $newSettings)
 {
     $db = \Scalr::getDb();
     $dbFarm = $dbFarmRole->GetFarmObject();
     $dbFarmRole->SetSetting(DBFarmRole::SETIING_CLOUDSTACK_STATIC_NAT_MAP, null, DBFarmRole::TYPE_LCL);
     $platform = PlatformFactory::NewPlatform($dbFarmRole->Platform);
     $cs = Scalr_Service_Cloud_Cloudstack::newCloudstack($platform->getConfigVariable(Modules_Platforms_Cloudstack::API_URL, $dbFarm->GetEnvironmentObject()), $platform->getConfigVariable(Modules_Platforms_Cloudstack::API_KEY, $dbFarm->GetEnvironmentObject()), $platform->getConfigVariable(Modules_Platforms_Cloudstack::SECRET_KEY, $dbFarm->GetEnvironmentObject()), $dbFarmRole->Platform);
     // Disassociate IP addresses if checkbox was unchecked
     if (!$newSettings[DBFarmRole::SETIING_CLOUDSTACK_USE_STATIC_NAT] && $oldSettings[DBFarmRole::SETIING_CLOUDSTACK_USE_STATIC_NAT]) {
         $eips = $db->Execute("\n                    SELECT * FROM elastic_ips WHERE farm_roleid = ?\n                ", array($dbFarmRole->ID));
         while ($eip = $eips->FetchRow()) {
             try {
                 $cs->disassociateIpAddress($eip['allocation_id']);
             } catch (Exception $e) {
             }
         }
         $db->Execute("DELETE FROM elastic_ips WHERE farm_roleid = ?", array($dbFarmRole->ID));
     }
     //TODO: Handle situation when tab was not opened, but max instances setting was changed.
     if ($newSettings[DBFarmRole::SETIING_CLOUDSTACK_STATIC_NAT_MAP] && $newSettings[DBFarmRole::SETIING_CLOUDSTACK_USE_STATIC_NAT]) {
         $map = explode(";", $newSettings[DBFarmRole::SETIING_CLOUDSTACK_STATIC_NAT_MAP]);
         foreach ($map as $ipconfig) {
             list($serverIndex, $ipAddress) = explode("=", $ipconfig);
             if (!$serverIndex) {
                 continue;
             }
             $dbServer = false;
             try {
                 $dbServer = DBServer::LoadByFarmRoleIDAndIndex($dbFarmRole->ID, $serverIndex);
                 if ($dbServer->remoteIp == $ipAddress) {
                     continue;
                 }
                 // Remove old association
                 $db->Execute("\n                            DELETE FROM elastic_ips WHERE farm_roleid = ? AND instance_index=?\n                        ", array($dbFarmRole->ID, $serverIndex));
             } catch (Exception $e) {
             }
             // Allocate new IP if needed
             if (!$ipAddress || $ipAddress == '0.0.0.0') {
                 if ($dbServer) {
                     $ipAddress = self::setStaticNatForServer($dbServer);
                 } else {
                     continue;
                 }
             } else {
                 //Remove old IP association
                 $db->Execute("\n                            DELETE FROM elastic_ips WHERE ipaddress=?\n                        ", array($ipAddress));
                 $info = $cs->listPublicIpAddresses(null, null, null, null, null, $ipAddress);
                 $info = $info->publicipaddress[0];
                 // Associate IP with server in our db
                 $db->Execute("INSERT INTO elastic_ips SET\n                            env_id=?,\n                            farmid=?,\n                            farm_roleid=?,\n                            ipaddress=?,\n                            state='0',\n                            instance_id='',\n                            clientid=?,\n                            instance_index=?,\n                            allocation_id=?\n                        ", array($dbFarm->EnvID, $dbFarmRole->FarmID, $dbFarmRole->ID, $ipAddress, $dbFarm->ClientID, $serverIndex, $info->id));
             }
             $ipInfo = $db->GetRow("SELECT allocation_id FROM elastic_ips WHERE ipaddress = ? LIMIT 1", $ipAddress);
             // Associate IP on AWS with running server
             if ($dbServer) {
                 try {
                     $db->Execute("UPDATE elastic_ips SET state='1', server_id = ? WHERE ipaddress = ?", array($dbServer->serverId, $ipAddress));
                     $update = false;
                     if ($dbServer->remoteIp != $ipAddress) {
                         if ($dbServer && $dbServer->status == SERVER_STATUS::RUNNING) {
                             $fireEvent = self::associateIpAddress($dbServer, $ipAddress, $ipInfo['allocation_id']);
                         }
                     }
                     if ($fireEvent) {
                         $event = new IPAddressChangedEvent($dbServer, $ipAddress, $dbServer->localIp);
                         Scalr::FireEvent($dbServer->farmId, $event);
                     }
                 } catch (Exception $e) {
                 }
             }
         }
     }
 }
开发者ID:recipe,项目名称:scalr,代码行数:72,代码来源:Cloudstack.php

示例9: xListAction

 public function xListAction()
 {
     $data = $this->db->GetAll('SELECT id, name, type, comments, target_id as targetId, target_server_index as targetServerIndex, target_type as targetType, start_time as startTime,
         end_time as endTime, last_start_time as lastStartTime, restart_every as restartEvery, config,
         status, timezone FROM `scheduler` WHERE `env_id` = ?', [$this->getEnvironmentId()]);
     foreach ($data as &$row) {
         switch ($row['targetType']) {
             case Scalr_SchedulerTask::TARGET_FARM:
                 try {
                     $DBFarm = DBFarm::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarm->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_ROLE:
                 try {
                     $DBFarmRole = DBFarmRole::LoadByID($row['targetId']);
                     $row['targetName'] = $DBFarmRole->GetRoleObject()->name;
                     $row['targetFarmId'] = $DBFarmRole->FarmID;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                 } catch (Exception $e) {
                 }
                 break;
             case Scalr_SchedulerTask::TARGET_INSTANCE:
                 try {
                     $DBServer = DBServer::LoadByFarmRoleIDAndIndex($row['targetId'], $row['targetServerIndex']);
                     $row['targetName'] = "({$DBServer->remoteIp})";
                     $DBFarmRole = $DBServer->GetFarmRoleObject();
                     $row['targetFarmId'] = $DBServer->farmId;
                     $row['targetFarmName'] = $DBFarmRole->GetFarmObject()->Name;
                     $row['targetRoleId'] = $DBServer->farmRoleId;
                     $row['targetRoleName'] = $DBFarmRole->GetRoleObject()->name;
                 } catch (Exception $e) {
                 }
                 break;
             default:
                 break;
         }
         //$row['type'] = Scalr_SchedulerTask::getTypeByName($row['type']);
         $row['startTime'] = $row['startTime'] ? Scalr_Util_DateTime::convertDateTime($row['startTime'], $row['timezone']) : 'Now';
         $row['endTime'] = $row['endTime'] ? Scalr_Util_DateTime::convertDateTime($row['endTime'], $row['timezone']) : 'Never';
         $row['lastStartTime'] = $row['lastStartTime'] ? Scalr_Util_DateTime::convertDateTime($row['lastStartTime'], $row['timezone']) : '';
         $row['config'] = unserialize($row['config']);
         $script = Script::findPk($row['config']['scriptId']);
         if ($script) {
             $row['config']['scriptName'] = $script->name;
         }
     }
     $this->response->data(['data' => $data]);
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:50,代码来源:Schedulertasks.php

示例10: Run

 function Run()
 {
     global $db;
     $time = microtime(true);
     $db->Execute("\r\n\t\t\t\tCREATE TABLE IF NOT EXISTS `scheduler` (\r\n\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t  `name` varchar(255) DEFAULT NULL,\r\n\t\t\t\t  `type` varchar(255) DEFAULT NULL,\r\n\t\t\t\t  `target_id` varchar(255) DEFAULT NULL COMMENT 'id of farm, farm_role or farm_role:index from other tables',\r\n\t\t\t\t  `target_type` varchar(255) DEFAULT NULL COMMENT 'farm, role or instance type',\r\n\t\t\t\t  `start_time` datetime DEFAULT NULL COMMENT 'start task''s time',\r\n\t\t\t\t  `end_time` datetime DEFAULT NULL COMMENT 'end task by this time',\r\n\t\t\t\t  `last_start_time` datetime DEFAULT NULL COMMENT 'the last time task was started',\r\n\t\t\t\t  `restart_every` int(11) DEFAULT '0' COMMENT 'restart task every N minutes',\r\n\t\t\t\t  `config` text COMMENT 'arguments for action',\r\n\t\t\t\t  `order_index` int(11) DEFAULT NULL COMMENT 'task order',\r\n\t\t\t\t  `timezone` varchar(100) DEFAULT NULL,\r\n\t\t\t\t  `status` varchar(11) DEFAULT NULL COMMENT 'active, suspended, finished',\r\n\t\t\t\t  `account_id` int(11) DEFAULT NULL COMMENT 'Task belongs to selected account',\r\n\t\t\t\t  `env_id` int(11) DEFAULT NULL,\r\n\t\t\t\t  PRIMARY KEY (`id`),\r\n\t\t\t\t  KEY `index` (`name`,`type`,`start_time`,`end_time`,`last_start_time`,`restart_every`,`order_index`,`status`,`account_id`,`env_id`)\r\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;\r\n\t\t\t");
     $cnt = 0;
     foreach ($db->GetAll('SELECT * FROM scheduler_tasks') as $taskOld) {
         $task = Scalr_SchedulerTask::init();
         $task->name = $taskOld['task_name'];
         $task->type = $taskOld['task_type'];
         $task->targetId = $taskOld['target_id'];
         $task->targetType = $taskOld['target_type'];
         $task->timezone = $taskOld['timezone'];
         $timezone = new DateTimeZone($taskOld['timezone']);
         $startTm = new DateTime($taskOld['start_time_date']);
         $endTm = new DateTime($taskOld['end_time_date']);
         $lastStartTm = new DateTime($taskOld['last_start_time']);
         // old time in timezone (from record) to server time (timezone leave for UI)
         Scalr_Util_DateTime::convertDateTime($startTm, null, $timezone);
         Scalr_Util_DateTime::convertDateTime($endTm, null, $timezone);
         Scalr_Util_DateTime::convertDateTime($lastStartTm, null, $timezone);
         $task->startTime = $startTm->format('Y-m-d H:i:s');
         $task->endTime = $endTm->format('Y-m-d H:i:s');
         $task->lastStartTime = $taskOld['last_start_time'] ? $lastStartTm->format('Y-m-d H:i:s') : NULL;
         switch ($taskOld['target_type']) {
             case SCRIPTING_TARGET::FARM:
                 try {
                     $DBFarm = DBFarm::LoadByID($taskOld['target_id']);
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
             case SCRIPTING_TARGET::ROLE:
                 try {
                     $DBFarmRole = DBFarmRole::LoadByID($taskOld['target_id']);
                     $a = $DBFarmRole->GetRoleObject()->name;
                     $a = $DBFarmRole->FarmID;
                     $a = $DBFarmRole->GetFarmObject()->Name;
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
             case SCRIPTING_TARGET::INSTANCE:
                 $serverArgs = explode(':', $taskOld['target_id']);
                 try {
                     $DBServer = DBServer::LoadByFarmRoleIDAndIndex($serverArgs[0], $serverArgs[1]);
                     $a = "({$DBServer->remoteIp})";
                     $DBFarmRole = $DBServer->GetFarmRoleObject();
                     $a = $DBServer->farmId;
                     $a = $DBFarmRole->GetFarmObject()->Name;
                     $a = $DBServer->farmRoleId;
                     $a = $DBFarmRole->GetRoleObject()->name;
                 } catch (Exception $e) {
                     continue 2;
                 }
                 break;
         }
         $config = unserialize($taskOld['task_config']);
         $r = array();
         switch ($task->type) {
             case Scalr_SchedulerTask::SCRIPT_EXEC:
                 $r['scriptId'] = (string) $config['script_id'];
                 unset($config['script_id']);
                 $r['scriptIsSync'] = (string) $config['issync'];
                 unset($config['issync']);
                 $r['scriptTimeout'] = (string) $config['timeout'];
                 unset($config['timeout']);
                 $r['scriptVersion'] = (string) $config['revision'];
                 unset($config['revision']);
                 $r['scriptOptions'] = $config;
                 break;
             case Scalr_SchedulerTask::LAUNCH_FARM:
                 break;
             case Scalr_SchedulerTask::TERMINATE_FARM:
                 $r['deleteDNSZones'] = $config['deleteDNS'];
                 $r['deleteCloudObjects'] = $config['keep_elastic_ips'] == '1' || $config['keep_ebs'] == '1' ? NULL : '1';
                 break;
         }
         $task->config = $r;
         $task->restartEvery = $taskOld['restart_every'];
         $task->orderIndex = $taskOld['order_index'];
         $task->status = $taskOld['status'];
         $task->accountId = $taskOld['client_id'];
         $task->envId = $taskOld['env_id'];
         $task->save();
     }
     print "Done.\n";
     $t = round(microtime(true) - $time, 2);
     print "Upgrade process took {$t} seconds\n\n\n";
 }
开发者ID:rakesh-mohanta,项目名称:scalr,代码行数:90,代码来源:upgrade_20120125.php


注:本文中的DBServer::LoadByFarmRoleIDAndIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。