It works, the method was incorrectly name, but your parameters was in
an incorrect order. This was the correct 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 => $mac,ip =>
$ip,name => $name);
}
close($HOSTS);
1;
PD: I have to post this code in the forum to help anyone who needs.
Enrique José Hernández Blasco escribió:
El vie, 29-02-2008 a las 18:34 +0100, silvio escribió:
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?
You're right. It's the correct method. However, the parameters are named
not positional. The correct method call is as follows:
$dhcpModule->addFixedAddress($iface, name =>$name, mac => $mac, ip =>
$ip);
I hope this works correctly.
Best regards,
_______________________________________________
Ebox-user mailing list
[email protected]
https://lists.warp.es/mailman/listinfo/ebox-user
|