Beispiel #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());
     }
 }
Beispiel #2
0
 public function exportByAccount()
 {
     $id = Input::get('id');
     $accountId = Input::get('accountId');
     $account = CloudAccountHelper::findAndDecrypt($accountId);
     Log::info('Logs for ' . $account->name);
     $result = json_decode($account->credentials);
     $ret = RemoteAPI::export($id, $result->host, $result->port);
     Log::info('Logs for Container ');
     echo '<pre>';
     print_r($ret);
 }
Beispiel #3
0
 public function postTerminate($id)
 {
     $this->check();
     $deployment = Deployment::where('user_id', Auth::id())->find($id);
     $account = CloudAccountHelper::findAndDecrypt($deployment->cloudAccountId);
     $instanceId = Input::get('instanceID');
     Log::error('Terminating Instance :' . $instanceId);
     $response = $this->executeAction(Input::get('instanceAction'), $account, $deployment, $instanceId);
     if ($response['status'] == 'OK') {
         return Redirect::to('/')->with('success', 'Instance Terminated Successfully!');
     } else {
         return Redirect::to('/')->with('error', 'Error while terminating the instance!');
     }
 }
Beispiel #4
0
 public static function getState($cloudAccountId, $instanceID)
 {
     $account = CloudAccountHelper::findAndDecrypt($cloudAccountId);
     $data = self::executeAction('describeInstances', $account, $instanceID);
     if ($data['status'] == 'OK') {
         if (!empty($data['message']['Reservations'][0]['Instances'][0]['State']['Name'])) {
             return UIHelper::getLabel($data['message']['Reservations'][0]['Instances'][0]['State']['Name']);
         } else {
             return UIHelper::getLabel('NA');
         }
     } else {
         if ($data['status'] == 'error') {
             return UIHelper::getLabel($data['status']);
         } else {
             return UIHelper::getLabel('NA');
         }
     }
 }