Node class and test

feature/node-rewrite
Sven Slootweg 13 years ago
parent 9f77d025c6
commit 36bb121df9

@ -24,7 +24,8 @@ class Node extends CPHPDatabaseRecordClass
'Name' => "Name", 'Name' => "Name",
'Hostname' => "Hostname", 'Hostname' => "Hostname",
'PrivateKey' => "CustomPrivateKey", 'PrivateKey' => "CustomPrivateKey",
'PublicKey' => "CustomPublicKey" 'PublicKey' => "CustomPublicKey",
'User' => "User"
), ),
'numeric' => array( 'numeric' => array(
'Port' => "Port" 'Port' => "Port"
@ -36,7 +37,29 @@ class Node extends CPHPDatabaseRecordClass
public $ssh = null; public $ssh = null;
public function GetNodes() protected function EventConstructed()
{
global $settings;
$this->ssh = new SshConnector();
$this->ssh->host = $this->sHostname;
$this->ssh->port = $this->sPort;
$this->ssh->user = $this->sUser;
if($this->HasCustomKey === true)
{
$this->ssh->key = $this->sPrivateKey;
$this->ssh->pubkey = $this->sPublicKey;
}
else
{
$this->ssh->key = $settings['master_privkey'];
$this->ssh->pubkey = $settings['master_pubkey'];
}
}
public function GetContainers()
{ {
var_dump($this->ssh->RunCommand("vzlist -a")); var_dump($this->ssh->RunCommand("vzlist -a"));
} }

@ -398,5 +398,5 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
// Define events // Define events
public function EventConstructed() { } protected function EventConstructed() { }
} }

@ -2,10 +2,16 @@
$_CVM = true; $_CVM = true;
require("includes/include.base.php"); require("includes/include.base.php");
$ssh = new SshConnector(); /*$ssh = new SshConnector();
$ssh->host = "cvm-vz.cryto.net"; $ssh->host = "cvm-vz.cryto.net";
$ssh->key = "/etc/cvm/key"; $ssh->key = "/etc/cvm/key";
$ssh->pubkey = "/etc/cvm/key.pub"; $ssh->pubkey = "/etc/cvm/key.pub";
var_dump($ssh->RunCommand("df -h", true)); var_dump($ssh->RunCommand("df -h", true));*/
$settings['master_privkey'] = "/etc/cvm/key";
$settings['master_pubkey'] = "/etc/cvm/key.pub";
$sNode = new Node(1);
var_dump($sNode->GetContainers());
?> ?>

Loading…
Cancel
Save