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
|
if [ -f $DATABASE ]; then
|
||||||
sqlite3 -separator " " $DATABASE \
|
sqlite3 -separator " " $DATABASE \
|
||||||
"select * from client" | while read id hostname mac role; do
|
"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
|
MacAddress $mac Role $role
|
||||||
done
|
done
|
||||||
rm $DATABASE
|
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 $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) {
|
foreach my $item (@items) {
|
||||||
my $hostName = $item->key;
|
my $hostName = $item->key;
|
||||||
system("/usr/bin/sudo -u amgmt /usr/bin/ssh -o StrictHostKeyChecking=no amgmt\@$hostName /usr/bin/sudo /sbin/reboot &") == 0
|
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 $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) {
|
foreach my $item (@items) {
|
||||||
my $hostName = $item->key;
|
my $hostName = $item->key;
|
||||||
system("/usr/bin/sudo -u amgmt /usr/bin/ssh -o StrictHostKeyChecking=no amgmt\@$hostName /usr/bin/sudo /sbin/poweroff &") == 0
|
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 $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) {
|
foreach my $item (@items) {
|
||||||
my $hostName = $item->key;
|
my $hostName = $item->key;
|
||||||
my $mac = $item->prop('MacAddress');
|
my $mac = $item->prop('MacAddress');
|
||||||
|
@ -108,7 +108,7 @@ function newHostname($mac, $base, $role) {
|
|||||||
# }
|
# }
|
||||||
} while ($hosts_db->getKey($hostname));
|
} while ($hosts_db->getKey($hostname));
|
||||||
|
|
||||||
$hosts_db->setKey($hostname, 'remote', array(
|
$hosts_db->setKey($hostname, 'local', array(
|
||||||
'MacAddress' => $mac,
|
'MacAddress' => $mac,
|
||||||
'Role' => $role,
|
'Role' => $role,
|
||||||
'Description' => ''
|
'Description' => ''
|
||||||
@ -165,7 +165,7 @@ function ROUTE_hosts() {
|
|||||||
if (isset($get_params['role'])) {
|
if (isset($get_params['role'])) {
|
||||||
$items = $hosts_db->getAllByProp('Role', $get_params['role']);
|
$items = $hosts_db->getAllByProp('Role', $get_params['role']);
|
||||||
} else {
|
} else {
|
||||||
$items = $hosts_db->getAll('remote');
|
$items = $hosts_db->getAll('local');
|
||||||
}
|
}
|
||||||
$results=array();
|
$results=array();
|
||||||
foreach ($items as $name=>$item) {
|
foreach ($items as $name=>$item) {
|
||||||
|
@ -16,7 +16,7 @@ class Hosts extends \Nethgui\Controller\TableController
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this
|
$this
|
||||||
->setTableAdapter($this->getPlatform()->getTableAdapter('hosts', 'remote'))
|
->setTableAdapter($this->getPlatform()->getTableAdapter('hosts', 'local'))
|
||||||
->setColumns($columns)
|
->setColumns($columns)
|
||||||
->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('update'))
|
->addRowAction(new \NethServer\Module\Doraemon\Hosts\Modify('update'))
|
||||||
->addRowAction(new \NethServer\Module\Doraemon\Hosts\TogglePower('wake'))
|
->addRowAction(new \NethServer\Module\Doraemon\Hosts\TogglePower('wake'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user