예제 #1
0
 /**
  * Saves/Edits an account
  *
  */
 public function postEdit($id = false)
 {
     if ($id !== false) {
         $account = CloudAccount::where('user_id', Auth::id())->findOrFail($id);
     }
     try {
         if (empty($account)) {
             $account = new CloudAccount();
         } else {
             if ($account->user_id !== Auth::id()) {
                 throw new Exception('general.access_denied');
             }
         }
         $account->name = Input::get('name');
         $account->cloudProvider = Input::get('cloudProvider');
         $account->credentials = json_encode(Input::get('credentials'));
         $account->user_id = Auth::id();
         // logged in user id
         $conStatus = CloudProvider::authenticate($account);
         if ($conStatus == 1) {
             Log::info('Credentials are encrypted before saving to DB.');
             CloudAccountHelper::save($account);
             return Redirect::intended('account')->with('success', Lang::get('account/account.account_updated'));
         } else {
             return Redirect::to('account')->with('error', Lang::get('account/account.account_auth_failed') . ' for ' . $account->cloudProvider);
         }
     } catch (Exception $e) {
         Log::error($e);
         return Redirect::to('account')->with('error', $e->getMessage());
     }
 }
예제 #2
0
 private static function AWSAuth($account)
 {
     $credentials = json_decode($account->credentials);
     $config['key'] = $credentials->apiKey;
     $config['secret'] = $credentials->secretKey;
     $config['region'] = empty($credentials->instanceRegion) ? 'us-east-1' : $credentials->instanceRegion;
     $conStatus = FALSE;
     try {
         $ec2Client = \Aws\Ec2\Ec2Client::factory($config);
         self::$ec2Compute = $ec2Client;
         $result = $ec2Client->DescribeInstances(array('Filters' => array(array('Name' => 'instance-type', 'Values' => array('m1.small')))));
         $reservations = $result->toArray();
         if (isset($reservations['requestId'])) {
             $conStatus = TRUE;
         } else {
             $conStatus = FALSE;
         }
     } catch (Exception $ex) {
         $conStatus = FALSE;
         Log::error($ex);
     }
     return $conStatus;
 }
예제 #3
0
 private function executeAction($instanceAction, $account, $deployment, $instanceID)
 {
     $param = json_decode($deployment->parameters);
     $account->instanceRegion = $param->instanceRegion;
     return CloudProvider::executeAction($instanceAction, $account, $instanceID);
 }
예제 #4
0
						        <span class="glyphicon glyphicon-trash"></span>
					            </button>


								<!-- <button alt="Terminates the Instance from your AWS account." title="Terminates the Instance from your AWS account." type="submit" class="btn btn-warning pull-right" role="button"><span class="glyphicon glyphicon-trash"></span></button> -->
			                  </form>
							 <div class="media-body">
								
								<h4 class="media-heading">{{ String::title($deployment->name) }} </h4>
								<p>
									<?php 
$url = URL::to('deployment/' . $deployment->id . '/instanceAction');
$downloadUrl = URL::to('deployment/' . $deployment->id . '/downloadKey');
$logUrl = URL::to('deployment/' . $deployment->id . '/log');
if (in_array($deployment->status, array('Completed', 'start', 'stop'))) {
    $instanceState = CloudProvider::getState($deployment->cloudAccountId, $result->instance_id);
    $anchor = '<a target="_blank" href="' . xDockerEngine::getProtocol($deployment->docker_name) . $result->public_dns . xDockerEngine::urlAppend($deployment->docker_name) . '">' . xDockerEngine::getDisplayName($deployment->docker_name) . '</a>';
    echo $result->instance_id . ' ' . $instanceState . ' | ' . xDockerEngine::getDockerUrl($deployment->docker_name) . ' | ' . $anchor . ' | ' . xDockerEngine::documentationUrl($deployment->docker_name) . ' | <a title="Support" alt="Support" class="glyphicon glyphicon-envelope" href="mailto:support@xervmon.com"></a>' . ' | <a title="Contact Xervmon to manage this" alt="Contact Xervmon to manage this" href="mailto:support@xervmon.com"><img src="' . asset('assets/ico/favicon.ico') . '"/></a>' . ' | <a title="Download" href="#" onclick="downloadKey(\'' . $downloadUrl . '\',\'' . $result->instance_id . '\', \'' . csrf_token() . '\')"><span class="glyphicon glyphicon-cloud-download"> </span> Pem </a>' . ' | <a title="ViewLog" href="' . $logUrl . '" ><span class="glyphicon glyphicon-th-list"> </span>  </a>';
} else {
    echo xDockerEngine::getDockerUrl($deployment->docker_name) . ' | ' . xDockerEngine::getDisplayName($deployment->docker_name) . ' | ' . xDockerEngine::documentationUrl($deployment->docker_name) . ' | <a title="Support" alt="Support" class="glyphicon glyphicon-envelope" href="mailto:support@xervmon.com"></a>' . ' | <a title="Contact Xervmon to manage this" alt="Contact Xervmon to manage this" href="mailto:support@xervmon.com"><img src="' . asset('assets/ico/favicon.ico') . '"/></a>' . ' | <a title="Download" href="#" onclick="downloadKey(\'' . $downloadUrl . '\',\'' . $result->instance_id . '\', \'' . csrf_token() . '\')"><span class="glyphicon glyphicon-cloud-download"> </span> Pem </a>' . ' | <a title="ViewLog" href="' . $logUrl . '" ><span class="glyphicon glyphicon-th-list"> </span>  </a>';
}
?>

									@if($deployment->status == 'Completed' && isset($result->public_dns))
										@if (strpos($instanceState, 'running') !== false) 
											<span title="Created At"><a href="{{{URL::to('deployment/docker/'.$deployment->id.'/Containers')}}}">{{ ' | '}}<span class="fa fa-info"></span></a> </span>
										@endif
									@endif
									
								</p>
								<p>