forked from LibreSchool/doraemon
fix: let's use the correct db for hosts
This commit is contained in:
parent
d425ad55a2
commit
e9f8e8a5f4
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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');
|
||||
|
@ -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) {
|
||||
|
@ -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'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user