Some fixes

feature/node-rewrite
Sven Slootweg 12 years ago
parent f2db8c25c2
commit e44a0d4645

@ -134,10 +134,10 @@ class Container extends CPHPDatabaseRecordClass
--ostemplate {$this->sTemplate->sTemplateName}
");
//$result = $this->sNode->ssh->RunCommand($command, false);
$result = $this->sNode->ssh->RunCommand($command, false);
$result->returncode = 0;
if($result->returncode == 0)
if($result->returncode == 0 && strpos($result->stderr, "ERROR") === false)
{
// TODO: set sensible defaults depending on container resource configuration
// http://wiki.openvz.org/UBC_consistency_check
@ -148,18 +148,18 @@ class Container extends CPHPDatabaseRecordClass
$this->uStatus = CVM_STATUS_CREATED;
$this->InsertIntoDatabase();
$sKMemSize = (isset($conf['sKMemSize'])) ? $conf['sKMemSize'] : $this->sGuaranteedRam * 250;
$sKMemSize = (isset($conf['sKMemSize'])) ? $conf['sKMemSize'] : $this->sGuaranteedRam * 65000;
$sKMemSizeLimit = (isset($conf['sKMemSizeLimit'])) ? $conf['sKMemSizeLimit'] : (int)($sKMemSize * 1.1);
$sLockedPages = (isset($conf['sLockedPages'])) ? $conf['sLockedPages'] : (int)($this->sGuaranteedRam * 1.5);
$sShmPages = (isset($conf['sShmPages'])) ? $conf['sShmPages'] : $sLockedPages * 64;
$sOomGuarPages = (isset($conf['sOomGuarPages'])) ? $conf['sOomGuarPages'] : $this->sGuaranteedRam * 400;
$sOomGuarPages = (isset($conf['sOomGuarPages'])) ? $conf['sOomGuarPages'] : $this->sGuaranteedRam * 140;
$sTcpSock = (isset($conf['sTcpSock'])) ? $conf['sTcpSock'] : $this->sGuaranteedRam * 3;
$sOtherSock = (isset($conf['sOtherSock'])) ? $conf['sOtherSock'] : $this->sGuaranteedRam * 3;
$sFLock = (isset($conf['sFLock'])) ? $conf['sFLock'] : (int)($this->sGuaranteedRam * 0.6);
$sFLockLimit = (isset($conf['sFLockLimit'])) ? $conf['sFLockLimit'] : (int)($sFLock * 1.1);
$sTcpSndBuf = (isset($conf['sTcpSndBuf'])) ? $conf['sTcpSndBuf'] : (int)($this->sGuaranteedRam * 20000);
$sTcpRcvBuf = (isset($conf['sTcpRcvBuf'])) ? $conf['sTcpRcvBuf'] : (int)($this->sGuaranteedRam * 20000);
$sOtherBuf = (isset($conf['sOtherBuf'])) ? $conf['sOtherBuf'] : (int)($this->sGuaranteedRam * 20000);
$sTcpSndBuf = (isset($conf['sTcpSndBuf'])) ? $conf['sTcpSndBuf'] : (int)($this->sGuaranteedRam * 10000);
$sTcpRcvBuf = (isset($conf['sTcpRcvBuf'])) ? $conf['sTcpRcvBuf'] : (int)($this->sGuaranteedRam * 10000);
$sOtherBuf = (isset($conf['sOtherBuf'])) ? $conf['sOtherBuf'] : (int)($this->sGuaranteedRam * 10000);
$sOtherBufLimit = (isset($conf['sOtherBufLimit'])) ? $conf['sOtherBufLimit'] : (int)($sTcpSndBuf * 2);
$sTcpSndBufLimit = (isset($conf['sTcpSndBufLimit'])) ? $conf['sTcpSndBufLimit'] : (int)($sTcpSndBuf * 2);
$sTcpRcvBufLimit = (isset($conf['sTcpRcvBufLimit'])) ? $conf['sTcpRcvBufLimit'] : (int)($sTcpRcvBuf * 2);
@ -167,7 +167,7 @@ class Container extends CPHPDatabaseRecordClass
$sNumFile = (isset($conf['sNumFile'])) ? $conf['sNumFile'] : $this->sGuaranteedRam * 32;
$sDCache = (isset($conf['sDCache'])) ? $conf['sDCache'] : $this->sGuaranteedRam * 16000;
$sDCacheLimit = (isset($conf['sDCacheLimit'])) ? $conf['sDCacheLimit'] : (int)($sDCache * 1.1);
$sAvgProc = (isset($conf['sAvgProc'])) ? $conf['sAvgProc'] : (int)($this->sGuaranteedRam * 1.5);
$sAvgProc = (isset($conf['sAvgProc'])) ? $conf['sAvgProc'] : (int)($this->sGuaranteedRam);
$command = shrink_command("vzctl set {$this->sInternalId}
--onboot yes
@ -235,9 +235,7 @@ class Container extends CPHPDatabaseRecordClass
--save
");*/
pretty_dump($command);
//$result = $this->sNode->ssh->RunCommand($command, false);
$result = $this->sNode->ssh->RunCommand($command, false);
if($result->returncode == 0)
{
@ -339,7 +337,7 @@ class Container extends CPHPDatabaseRecordClass
if($result->returncode == 0)
{
$lines = split_lines($result->stdout);
$values = split_whitespace($lines[0]);
$values = split_whitespace(str_replace(":", " ", $lines[0]));
$uIncoming = $values[1];
$uOutgoing = $values[9];

@ -345,6 +345,8 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
$this->sId = mysql_insert_id();
}
$this->PurgeCache();
return $result;
}
else

@ -11,4 +11,28 @@
* licensing text.
*/
$_CVM = true;
require("includes/include.base.php");
if($result = mysql_query_cached("SELECT * FROM containers"))
{
foreach($result->data as $row)
{
$sContainer = new Container($row);
//try
//{
$sContainer->UpdateTraffic();
//}
//catch (ContainerTrafficRetrieveException $e)
/*{
if($sContainer->sCurrentStatus == CVM_STATUS_STARTED)
{
// This is not supposed to fail, as the container is running.
// Something shady going on.
// TODO: Log exception
}
}*/
}
}
?>

@ -8,13 +8,13 @@ $settings['salt'] = "kAU0qM";
if($_GET['action'] == "deploy")
{
$sContainer = new Container(2);
$sContainer = new Container(3);
$sContainer->Deploy();
}
else
{
$sContainer = new Container(1);
$sContainer = new Container(3);
if($_GET['action'] == "start")
{

Loading…
Cancel
Save