Hi,
I'm trying to make mksimachine work (delete and update functions), but I got
lost into its code.
Here is an attached patch (that resumes my attempts). This patch is certainly
wrong, but the
comment I've added should help a lot in understanding the problem.
So far, I've understood that functions working with Nics are sometimes
expecting a hash representing the database table Nics and sometimes they are
expecting a SIS::Adapter object which is really different. (netmask and client
fields that table Nics lacks while it misses id, node_id or network_id).
This BUG is typically visible in OSCAR::Network::set_network_adapter line 72
expected input: array of SIS::Adapter() objects
got input from SIS::NewDB::set_adapter : Hash representing the nic (from DB)
BUG: unexpected data type received.
This code looks like being in between a major rewrite, and thus at this point
I'm unable to determine which data model should be kept (SIS:Adapter or hash
from db).
In other words, should OSCAR::NewDB::list_adapters be rewritten to use
SIS:Adapter objects, or should OSCAR::NewDB::set_adapter be rewritten to use a
simple hash representing the Nics database table?
Although, another thing that seems strange is that updating a client triggers
the update nic, but the function used for that purpose seems to handle
associations between nics and clients and not Nics database fields updates.
So using simple words: HELP I can't go further, my perl knowledge and oscar
knowledge have been overflowed ;-)
Regards,
Olivier.
--
Olivier LAHAYE
CEA Saclay
DRT-LIST-DETECS-SSTM
--- /usr/bin/mksimachine.orig 2009-11-13 15:22:21.000000000 +0100
+++ /usr/bin/mksimachine 2009-11-17 16:51:54.000000000 +0100
@@ -120,23 +120,29 @@
foreach my $mach (@machinelist) {
if ($config->image) {
&verbose("Updating autoinstall script link.");
- if (! unlink($config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->name . ".sh")){
- carp("Unable to delete old script link for machine ".$mach->name);
+ if (! unlink($config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->{name} . ".sh")){
+ carp("Unable to delete old script link for machine ".$mach->{name});
}
my $file1 = $config->image . ".master";
- my $file2 = $config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->name . ".sh";
+ my $file2 = $config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->{name} . ".sh";
if (! symlink($file1, $file2)) {
- carp("Unable to create new script link for machine ".$mach->name);
+ carp("Unable to create new script link for machine ".$mach->{name});
}
}
+# $config->netmask always defined => condition below is always true.
if (($config->ipaddress) || ($config->netmask) || ($config->MACaddress)) {
&verbose("Updating adapter database");
- my %h = (devname=>"eth0",client=>$mach->name);
- my @adap=list_adapter(\%h);
+ my %h = (devname=>"eth0",client=>$mach->{name});
+ my @adap= SIS::NewDB::list_adapter(\%h);
if ($config->ipaddress) {
$adap[0]->ip($config->ipaddress);
}
+# adap[0] should be an SIS::Adapter() object, but it is not. thus the lines below fails.
+# table Nics contains: id, ip, mac, name, network_id, node_id.
+# adap[0] contains: id, ip, mac, name, network_id, node_id
+# SIS:Adapter() object contains: '_cache' => { '_primkey' },
+# '_vars' => { '_mac', '_netmask', '_ip', '_devname', '_client' }
if ($config->netmask) {
$adap[0]->netmask($config->netmask);
}
@@ -171,9 +177,9 @@
my %ADAPTERS;
&verbose("Getting adapters");
my @adaps = SIS::NewDB::list_adapter(undef);
- print "Toto: ".Dumper @adaps;
+ print "DEBUG: All adapters to delete: ".Dumper @adaps;
foreach my $a (@adaps) {
- print "titi: ".Dumper $a;
+ print "DEBUG: Adapter: ".Dumper $a;
my $...@$a[0]->{client};
push(@{$ADAPTERS{$c}},$a);
}
@@ -239,6 +245,7 @@
if (linkscript($clientdef)){
set_client($clientdef);
+# eth0 hard coded below?
my $adapdef = new SIS::Adapter("eth0");
$adapdef->client($config->name);
$adapdef->ip($config->ipaddress);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Oscar-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oscar-devel