fix: let's use the correct db for hosts

This commit is contained in:
Paolo Asperti 2016-09-27 17:51:58 +02:00
parent d425ad55a2
commit e9f8e8a5f4
6 changed files with 7 additions and 7 deletions

View File

@ -79,7 +79,7 @@ if [ "$1" = 2 ]; then
if [ -f $DATABASE ]; then
sqlite3 -separator " " $DATABASE \
"select * from client" | while read id hostname mac role; do
/sbin/e-smith/db hosts set $hostname remote \
/sbin/e-smith/db hosts set $hostname local \
MacAddress $mac Role $role
done
rm $DATABASE

View File

@ -10,7 +10,7 @@ use English;
my $db_hosts = esmith::DB::db->open('hosts') || die("Could not open e-smith db (" . esmith::DB::db->error . ")\n");
my @items = $db_hosts->get_all('remote');
my @items = $db_hosts->get_all('local');
foreach my $item (@items) {
my $hostName = $item->key;
system("/usr/bin/sudo -u amgmt /usr/bin/ssh -o StrictHostKeyChecking=no amgmt\@$hostName /usr/bin/sudo /sbin/reboot &") == 0

View File

@ -10,7 +10,7 @@ use English;
my $db_hosts = esmith::DB::db->open('hosts') || die("Could not open e-smith db (" . esmith::DB::db->error . ")\n");
my @items = $db_hosts->get_all('remote');
my @items = $db_hosts->get_all('local');
foreach my $item (@items) {
my $hostName = $item->key;
system("/usr/bin/sudo -u amgmt /usr/bin/ssh -o StrictHostKeyChecking=no amgmt\@$hostName /usr/bin/sudo /sbin/poweroff &") == 0

View File

@ -10,7 +10,7 @@ use English;
my $db_hosts = esmith::DB::db->open('hosts') || die("Could not open e-smith db (" . esmith::DB::db->error . ")\n");
my @items = $db_hosts->get_all('remote');
my @items = $db_hosts->get_all('local');
foreach my $item (@items) {
my $hostName = $item->key;
my $mac = $item->prop('MacAddress');

View File

@ -108,7 +108,7 @@ function newHostname($mac, $base, $role) {
# }
} while ($hosts_db->getKey($hostname));
$hosts_db->setKey($hostname, 'remote', array(
$hosts_db->setKey($hostname, 'local', array(
'MacAddress' => $mac,
'Role' => $role,
'Description' => ''
@ -165,7 +165,7 @@ function ROUTE_hosts() {
if (isset($get_params['role'])) {
$items = $hosts_db->getAllByProp('Role', $get_params['role']);
} else {
$items = $hosts_db->getAll('remote');
$items = $hosts_db->getAll('local');
}
$results=array();
foreach ($items as $name=>$item) {

View File

@ -16,7 +16,7 @@ class Hosts extends \Nethgui\Controller\TableController
);
$this
->setTableAdapter($this->getPlatform()->getTableAdapter('hosts', 'remote'))
->setTableAdapter($this->getPlatform()->getTableAdapter('hosts', 'local'))
->setColumns($columns)
->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('update'))
->addRowAction(new \NethServer\Module\Doraemon\Hosts\TogglePower('wake'))