public function executeVncviewer(sfWebRequest $request) { if ($request->getParameter('sleep')) { $tsleep = $request->getParameter('sleep'); sleep($tsleep); } $etva_server = EtvaServerPeer::retrieveByPk($request->getParameter('id')); if (!$etva_server) { return sfView::NONE; } $etva_node = $etva_server->getEtvaNode(); $user = $this->getUser(); $tokens = $user->getGuardUser()->getEtvaVncTokens(); $this->username = $tokens[0]->getUsername(); $this->token = $tokens[0]->getToken(); $proxyhost1 = $request->getHost(); $proxyhost1_arr = split(':', $proxyhost1); $proxyhost1 = $proxyhost1_arr[0]; $proxyport1 = $request->isSecure() ? 443 : 80; //$proxyport1 = 80; if ($proxyhost1_arr[1]) { $proxyport1 = $proxyhost1_arr[1]; } $this->proxyhost1 = $proxyhost1; $this->proxyport1 = $proxyport1; $this->socketFactory = $request->isSecure() ? 'AuthHTTPSConnectSSLSocketFactory' : 'AuthHTTPConnectSocketFactory'; $this->host = $etva_node->getIp(); //if host is localhost address then is the same machine if ($this->host == '127.0.0.1') { $this->host = $proxyhost1; } $this->port = $etva_server->getVncPort(); $response = $this->getResponse(); $response->setTitle($etva_server->getName() . ' :: Console'); }
/** * check server state * uses checkState * * @return string json string representation */ public function executeJsonCheckState(sfWebRequest $request) { $etva_server = EtvaServerPeer::retrieveByPk($request->getParameter('id')); $dispatcher = $request->getParameter('dispatcher'); $response = $this->checkState($etva_server, $dispatcher); $success = $response['success']; if (!$success) { $response['data'] = $etva_server->toArray(BasePeer::TYPE_FIELDNAME); $error = $this->setJsonError($response); return $this->renderText($error); } else { $return = json_encode($response); $this->getResponse()->setHttpHeader('Content-type', 'application/json'); return $this->renderText($return); } }