Remote control plus générique
Multi mysql serveur compliant :)
This commit is contained in:
parent
c1d2971463
commit
c5357f6be2
|
@ -61,10 +61,13 @@ include_once("head.php");
|
|||
echo "<table class='tedit'>";
|
||||
echo "<tr><th>"._("Hostname")."</th><td>".$infos['serialized_object']['hostname']."</td></tr>";
|
||||
echo "<tr><th>"._("Start time")."</th><td>".$infos['date_start']."</td></tr>";
|
||||
echo "<tr><th>"._("Usefull command")."</th><td><pre>";
|
||||
echo "ssh ".$mem->user['login']."@".$infos['serialized_object']['hostname']."\n";
|
||||
echo "rsync ".$mem->user['login']."@".$infos['serialized_object']['hostname']."\n";
|
||||
echo "</pre></td></tr>";
|
||||
echo "<tr><td colspan='2'><a href='vm.php?action=stop'>"._("Click here to stop the machine")."</a></td></tr>";
|
||||
echo "</table>";
|
||||
|
||||
|
||||
} // empty infos ?>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ class m_lxc implements vm
|
|||
}
|
||||
|
||||
|
||||
private function sendMessage($action, $user = FALSE, $password=FALSE, $uid=FALSE)
|
||||
{
|
||||
private function sendMessage($params) {
|
||||
$fp = fsockopen($this->IP, $this->PORT, $errno, $errstr, $this->TIMEOUT);
|
||||
if (!$fp)
|
||||
{
|
||||
|
@ -47,7 +46,7 @@ class m_lxc implements vm
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$msg = sprintf("%s|%s|%s|%d\n", $action, $user, $password, $uid);
|
||||
$msg = sprintf("%s\n", serialize($params) );
|
||||
if (fwrite ($fp, $msg) < 0)
|
||||
{
|
||||
$this->error[] = 'Unable to send data';
|
||||
|
@ -58,7 +57,6 @@ class m_lxc implements vm
|
|||
$resp = fgets($fp, 4096);
|
||||
fclose ($fp);
|
||||
|
||||
|
||||
return $resp;
|
||||
|
||||
if (stripos($resp, 'error') > 0)
|
||||
|
@ -76,7 +74,7 @@ class m_lxc implements vm
|
|||
public function start($login = FALSE, $pass = FALSE, $uid = FALSE)
|
||||
{
|
||||
|
||||
global $mem, $db, $err;
|
||||
global $mem, $db, $err, $mysql;
|
||||
|
||||
if ($this->getvm() !== FALSE)
|
||||
{
|
||||
|
@ -84,11 +82,14 @@ class m_lxc implements vm
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
$user = $login ? $login : $mem->user['login'];
|
||||
$login = $login ? $login : $mem->user['login'];
|
||||
$pass = $pass ? $pass : $mem->user['pass'];
|
||||
$uid = $uid ? $uid : $mem->user['uid'];
|
||||
|
||||
$res = $this->sendMessage('start', $user, $pass, $uid);
|
||||
$msgg = array('action'=>'start', 'login'=>$login, 'pass' => $pass, 'uid'=> $uid);
|
||||
$msgg['mysql_host'] = $mysql->dbus->Host;
|
||||
|
||||
$res = $this->sendMessage($msgg);
|
||||
if ($res === FALSE)
|
||||
return $this->error;
|
||||
else
|
||||
|
@ -149,7 +150,7 @@ class m_lxc implements vm
|
|||
$uid = $mem->user['uid'];
|
||||
$vid = $vm['id'];
|
||||
|
||||
if ($this->sendMessage('stop', $vm_id, FALSE, FALSE) === FALSE)
|
||||
if ($this->sendMessage(array('action' => 'stop', 'vm' => $vm_id)) === FALSE)
|
||||
return FALSE;
|
||||
|
||||
return $db->query("UPDATE vm_history SET date_end = NOW() WHERE uid = '$uid' AND id = '$vid' LIMIT 1");
|
||||
|
|
Loading…
Reference in New Issue