I'd try your code, but it doesn't find the addHostname method, I think it
could be addFixedAddress method the correct one. Whatever I'd try whit
it and it doesn't work. This is my code:
#!/usr/bin/perl
use strict;
use warnings;
use EBox;
use EBox::Global;
EBox::init();
my $dhcpModule = EBox::Global->modInstance('dhcp');
my $iface = 'eth0';
my $ip;
my $mac;
my $name;
open(my $HOSTS,"lista");
while(my $line = <$HOSTS>) {
chomp ($line);
my ($ip,$mac,$name) = split(',',$line);
$dhcpModule->addFixedAddress($iface,$mac,$ip,$name);
}
close($HOSTS);
when I tried it whit this "lista" file:
/172.16.3.4,ff:aa:dd:ee:33:11,cdctest1,
172.16.2.1,aa:aa:aa:aa:aa:aa,natprobo2,/
I found this error : "/The number of parameters is odd. Some index
argument is missing. Remember the indexes are positional and the model
arguments are named/"
What are I doing bad? I'm using the correct method, I had browsed
trougth the ebox source code and I think it is, I'm callinf correctly
the method?
Thanks anyway,
Silvio
Jorge Salamero Sanz escribió:
On Friday 29 February 2008 13:28:45 silvio wrote:
Thanks, I'll study and try.
try this (at least it worked some time ago):
#!/usr/bin/perl -w
use strict;
use warnings;
use EBox;
use EBox::Global;
EBox::init();
my $dhcpModule = EBox::Global->modInstance('dhcp');
# parses a file: host,ip
open(my $FD,"dhcpd.conf");
while(my $line = <$FD>) {
chomp($line);
#my ($host,$ip) = split(',',$line);
$dhcpModule->addHostname($iface, $mac, $ip, $name);
}
close($FD);
1;
_______________________________________________
Ebox-user mailing list
[email protected]
https://lists.warp.es/mailman/listinfo/ebox-user