Container.Start() and constants

feature/node-rewrite
Sven Slootweg 13 years ago
parent 027f20c53d
commit 515232442c

@ -112,6 +112,21 @@ class Container extends CPHPDatabaseRecordClass
// TODO: throw exception for failed container creation
}
}
public function Start()
{
$command = "vzctl start {$this->sInternalId}";
$result = $this->sNode->ssh->RunCommand($command, false);
if($result->returncode == 0)
{
return true;
}
else
{
// TODO: throw exception for failed container start
}
}
}
?>

@ -14,6 +14,7 @@
$_CPHP = true;
require("cphp/base.php");
require("include.exceptions.php");
require("include.constants.php");
require("include.parsing.php");
require("classes/class.controller.php");
require("classes/class.container.php");

@ -0,0 +1,26 @@
<?php
/*
* CVM is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_CVM)) { die("Unauthorized."); }
define("CVM_VIRTUALIZATION_OPENVZ", 1 );
define("CVM_STATUS_BLANK", 1 );
define("CVM_STATUS_CREATED", 2 );
define("CVM_STATUS_CONFIGURED", 3 );
define("CVM_STATUS_STARTED", 4 );
define("CVM_STATUS_STOPPED", 5 );
define("CVM_STATUS_SUSPENDED", 6 );
define("CVM_STATUS_TERMINATED", 7 );
?>

@ -16,8 +16,13 @@ $settings['master_pubkey'] = "/etc/cvm/key.pub";
var_dump($sNode->sDiskFree, $sNode->sDiskUsed, $sNode->sRealHostname);*/
$sContainer = new Container(1);
$sContainer->Deploy();
// $sContainer->Deploy();
// returncode 127 = failed (CT ID missing?)
pretty_dump($sContainer);
$sContainer->Start();
echo("Done!");
//pretty_dump($sContainer);
?>

Loading…
Cancel
Save