hi,

I've done a patch to fix the best I could the mksimachine command so it can 
delete a host. Unfortunately, it's not yet finished. (but better than previous 
IMHO)

BUT: 
I've discovered that the list_adapter was using $ instead of @ leading to bugs 
(caller expect @result and receive $result instead)
olds parts of the code were using $result and were converting it.
The 2 patches aside mksimachine try to fix that in the hope I did not break 
every thing.
As for mksimachine, it has progressed even-though it still fails. Should be 
fixed tomorrow if I've progressed enought in perl.

THUS: PLEASE review carefully this patch.

My apologies for having indented the code. This indent pollute a little bit the 
code.

Olivier.


-- 
        Olivier LAHAYE
        CEA Saclay
        DRT-LIST-DETECS-SSTM
--- /usr/lib/systeminstaller/SystemInstaller/Machine.pm.orig	2009-11-23 17:59:47.000000000 +0100
+++ /usr/lib/systeminstaller/SystemInstaller/Machine.pm	2009-11-23 18:05:11.000000000 +0100
@@ -48,8 +48,8 @@
     
     foreach my $machine (@machines) {
         my %h = (client=>$machine->{name}, devname=>"eth0");
-        my $adapter = SIS::NewDB::list_adapter(\%h);
-        if (!defined $adapter) {
+        my @adapter = SIS::NewDB::list_adapter(\%h);
+        if (!scalar(@adapter)) {
             carp "ERROR: Impossible to get adapter data (".
                 $machine->{name}.")";
             return undef;
@@ -58,7 +58,7 @@
                                       HOST => $machine->{hostname},
                                       DOMAIN => $machine->{domainname},
                                       NUM_PROCS => $machine->{proccount},
-                                      IPADDR => @$adapter[0]->{ip}
+                                      IPADDR => $adapter[0]->{ip}
                                      };
     }
 
@@ -67,9 +67,9 @@
 
 sub adapter_devs {
     my %dev;
-    my $adapterlist = SIS::NewDB::list_adapter(undef);
+    my @adapterlist = SIS::NewDB::list_adapter(undef);
 
-    foreach my $adap (@$adapterlist) {
+    foreach my $adap (@adapterlist) {
         my $d = $adap->{devname};
         $dev{$d} = 1;
     }
@@ -112,13 +112,13 @@
 sub synchosts {
     my @delhos...@_;
     my @machinelist = list_client();
-    my $adapterlist = list_adapter(undef);
+    my @adapterlist = list_adapter(undef);
     my @devlist = adapter_devs();
     my %ADAPTERS;
     my %APPLIANCES;
 
     &verbose("Parsing adapters");
-    foreach my $adap (@$adapterlist) {
+    foreach my $adap (@adapterlist) {
         my $name = $adap->{client};
         $ADAPTERS{$adap->{devname}}{$name} = $adap->{ip};
         if ($name =~ /^__(.*)__$/) {
--- /usr/lib/systeminstaller/SystemInstaller/Tk/AddClients.pm.orig	2009-11-23 18:08:25.000000000 +0100
+++ /usr/lib/systeminstaller/SystemInstaller/Tk/AddClients.pm	2009-11-23 18:09:02.000000000 +0100
@@ -271,10 +271,10 @@
 
 sub nextip()
 {
-    my $ips = SIS::NewDB::list_adapter(undef);
+    my @ips = SIS::NewDB::list_adapter(undef);
     print "All IP: \n";
-    print Dumper $ips;
-    my @allip = map { $_->{ip} } @$ips;
+    print Dumper @ips;
+    my @allip = map { $_->{ip} } @ips;
     if (scalar (@allip)) {
         my $lastip = hex( (sort map { sprintf "%.2x%.2x%.2x%.2x", split /\./, $_ } @allip)[-1] );
         my $x;
--- /usr/bin/mksimachine.orig	2009-11-13 15:22:21.000000000 +0100
+++ /usr/bin/mksimachine	2009-11-23 18:42:25.000000000 +0100
@@ -48,49 +48,49 @@
 my ($junk,$DOM)  = split(/\./,$HOST,2);
 
 $config->define(
-        Add=>{ ARGCOUNT=> ARGCOUNT_NONE,
-                ALIAS => "a"},
-        Delete=>{ ARGCOUNT=> ARGCOUNT_NONE,
-                ALIAS => "d"},
-        List=>{ ARGCOUNT=> ARGCOUNT_NONE,
-                ALIAS=>"l"},
-        Update=>{ ARGCOUNT=> ARGCOUNT_NONE,
-                ALIAS=>"u"},
-        Sync=>{ ARGCOUNT=> ARGCOUNT_NONE,
-                ALIAS=>"s"},
-        Help=>{ ARGCOUNT=> ARGCOUNT_NONE},
-        name=> {ARGCOUNT=> ARGCOUNT_ONE},
-        ipaddress=>{ ARGCOUNT=> ARGCOUNT_ONE},
-        domain=>{ ARGCOUNT=> ARGCOUNT_ONE,
-                DEFAULT=> $DOM},
-        image=>{ ARGCOUNT=> ARGCOUNT_ONE},
-        all=> {ARGCOUNT=> ARGCOUNT_NONE},
-        gateway=>{ARGCOUNT=> ARGCOUNT_ONE},
-        MACaddress=>{ARGCOUNT=> ARGCOUNT_ONE},
-        version=>{ARGCOUNT=> ARGCOUNT_NONE},
-        netmask=>{ARGCOUNT=> ARGCOUNT_ONE,
-                DEFAULT=>"255.255.255.0"},
-        parse=>{ARGCOUNT=>ARGCOUNT_NONE},
-);
+		Add=>{ ARGCOUNT=> ARGCOUNT_NONE,
+		       ALIAS => "a"},
+		Delete=>{ ARGCOUNT=> ARGCOUNT_NONE,
+			  ALIAS => "d"},
+		List=>{ ARGCOUNT=> ARGCOUNT_NONE,
+			ALIAS=>"l"},
+		Update=>{ ARGCOUNT=> ARGCOUNT_NONE,
+			  ALIAS=>"u"},
+		Sync=>{ ARGCOUNT=> ARGCOUNT_NONE,
+			ALIAS=>"s"},
+		Help=>{ ARGCOUNT=> ARGCOUNT_NONE},
+		name=> {ARGCOUNT=> ARGCOUNT_ONE},
+		ipaddress=>{ ARGCOUNT=> ARGCOUNT_ONE},
+		domain=>{ ARGCOUNT=> ARGCOUNT_ONE,
+			  DEFAULT=> $DOM},
+		image=>{ ARGCOUNT=> ARGCOUNT_ONE},
+		all=> {ARGCOUNT=> ARGCOUNT_NONE},
+		gateway=>{ARGCOUNT=> ARGCOUNT_ONE},
+		MACaddress=>{ARGCOUNT=> ARGCOUNT_ONE},
+		version=>{ARGCOUNT=> ARGCOUNT_NONE},
+		netmask=>{ARGCOUNT=> ARGCOUNT_ONE,
+			  DEFAULT=>"255.255.255.0"},
+		parse=>{ARGCOUNT=>ARGCOUNT_NONE},
+		);
 
 unless ($config->getopt()){
-	&usage;
-	exit 1;
+    &usage;
+    exit 1;
 }
 
 if ($config->version){
-        &print_version($0,$VERSION);
-        exit 0;
+    &print_version($0,$VERSION);
+    exit 0;
 }
 
 unless (&check_args) {
-	&usage;
-	exit 1;
+    &usage;
+    exit 1;
 }
 
 if ($config->Help){
-	&usage;
-	exit 0;
+    &usage;
+    exit 0;
 }
 
 my @machinelist;
@@ -117,189 +117,204 @@
 }
 
 if ($config->Update) {
-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);
-        }
-        my $file1 = $config->image . ".master";
-        my $file2 = $config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->name . ".sh";
-        if (! symlink($file1, $file2)) {
-            carp("Unable to create new script link for machine ".$mach->name);
-        }
-    }
+    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});
+	    }
+	    my $file1 = $config->image . ".master";
+	    my $file2 = $config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->{name} . ".sh";
+	    if (! symlink($file1, $file2)) {
+		carp("Unable to create new script link for machine ".$mach->{name});
+	    }
+	}
 
-    if (($config->ipaddress) || ($config->netmask) || ($config->MACaddress)) {
-        &verbose("Updating adapter database");
-        my %h = (devname=>"eth0",client=>$mach->name);
-        my @adap=list_adapter(\%h);
-        if ($config->ipaddress) {
-            $adap[0]->ip($config->ipaddress);
-        }
-        if ($config->netmask) {
-            $adap[0]->netmask($config->netmask);
-        }
-        if ($config->MACaddress) {
-            $adap[0]->mac($config->MACaddress);
-        }
-        if (SIS::NewDB::set_adapter(@adap)) {
-            die "ERROR: Impossible to set adapters";
-        }
-    }
-    if (($config->domain) || ($config->gateway) || ($config->image))  {
-        &verbose("Updating machine database");
-        if ($config->domain) {
-            $mach->domainname($config->domain);
-            $mach->hostname($mach->name.".".$config->domain);
-        }
-        if ($config->gateway) {
-            $mach->route($config->gateway);
-        }
-        if ($config->image) {
-            $mach->imagename($config->image);
-        }
-                    set_client($mach);
+# $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= 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);
+	    }
+	    if ($config->MACaddress) {
+		$adap[0]->mac($config->MACaddress);
+	    }
+	    if (SIS::NewDB::set_adapter(@adap)) {
+		die "ERROR: Impossible to set adapters";
+	    }
+	}
+	if (($config->domain) || ($config->gateway) || ($config->image))  {
+	    &verbose("Updating machine database");
+	    if ($config->domain) {
+		$mach->domainname($config->domain);
+		$mach->hostname($mach->name.".".$config->domain);
+	    }
+	    if ($config->gateway) {
+		$mach->route($config->gateway);
+	    }
+	    if ($config->image) {
+		$mach->imagename($config->image);
+	    }
+	    set_client($mach);
+	}
     }
-}
 # Re-sync the /etc/hosts file
-&synchosts;
+    &synchosts;
 
 } elsif ($config->Delete) {
     my @delhosts;
     my @deladaps;
     my %ADAPTERS;
     &verbose("Getting adapters");
-    my @adaps = SIS::NewDB::list_adapter(undef);
-    print "Toto: ".Dumper @adaps;
+    my @adaps;
+    @adaps = SIS::NewDB::list_adapter(undef);
     foreach my $a (@adaps) {
-        print "titi: ".Dumper $a;
-        my $...@$a[0]->{client};
-        push(@{$ADAPTERS{$c}},$a);
+        print "DEBUG: Checking Adapter: ".Dumper $a;
+#        my $...@$a[0]->{client};
+        my $c=$a->{client};
+#        push(@{$ADAPTERS{$c}},$a);
+        $ADAPTERS{$c}=$a;
     }
     my $file;
-	foreach my $mach (@machinelist) {
+    foreach my $mach (@machinelist) {
         $file = $config->AUTOINSTALL_SCRIPT_DIR ."/". $mach->{name} . ".sh";
-		if  (-f $file && ! unlink($file)){
-			carp("WARNING: Unable to delete old script link for machine "
+	if  (-f $file && ! unlink($file)){
+	    carp("WARNING: Unable to delete old script link for machine "
                  .$mach->{name}."($file), continuing...");
-		}
-	        push @delhosts,$mach->{name};
-			
-                if ($ADAPTERS{$mach->{name}}) {
-                        my @adapte...@{$adapters{$mach->{name}}};
-                        push(@deladaps,@adapters);
-                }
-	}
-	&verbose("Deleting machines...");
-        my @keys = map{$_->{primkey}} @machinelist;
-        if (SIS::NewDB::del_client(@keys) == 0) {
-            carp "ERROR: Impossible to delete a client";
-            exit 1;
-        }
-	&verbose("Deleting adapters...");
-        @keys=map{$_->{primkey}} @deladaps;
-        if (SIS::NewDB::del_adapter(@keys) == 0) {
-            carp "ERROR: Impossible to delete an adapter";
-            exit 1;
-        }
-	# Resync the /etc/hosts file.
-	&verbose("Syncing /etc/hosts");
-        &synchosts(@delhosts);
+	}
+	push @delhosts,$mach->{name};
+	
+	if ($ADAPTERS{$mach->{name}}) {
+	    #my @adapte...@{$adapters{$mach->{name}}};
+	    #push(@deladaps,@adapters);
+	    push(@deladaps,$ADAPTERS{$mach->{name}});
+	}
+    }
+    &verbose("Deleting machines...");
+#        my @keys = map{$_->{primkey}} @machinelist;
+# Line above does not work as primkey is not a field od @machinelist. @machine list is not a table of SIS::Client objects (OL)
+    my @keys = map{(name=>$_->{name})} @machinelist;
+
+#        if (SIS::NewDB::del_client(name=>@keys) == 0) {
+    if (SIS::NewDB::del_client(@keys) == 0) {
+	carp "ERROR: Impossible to delete a client";
+	exit 1;
+    }
+    &verbose("Deleting adapters...");
+    #...@keys=map{$_->{primkey}} @deladaps;
+    @keys=map{(client=>$_->{client})} @deladaps;
+    if (SIS::NewDB::del_adapter(@keys) == 0) {
+	carp "ERROR: Impossible to delete an adapter";
+	exit 1;
+    }
+    # Resync the /etc/hosts file.
+    &verbose("Syncing /etc/hosts");
+    &synchosts(@delhosts);
 
 } elsif ($config->Sync) {
-	# Just sync up the /etc/hosts file.
-	&synchosts;
+    # Just sync up the /etc/hosts file.
+    &synchosts;
 } elsif ($config->Add) {
-        if (exists_client($config->name)) {
-                carp("Client " . $config->name ." already exists.\n");
-                exit 1;
-        }
-        if ($config->name=~/ /) {
-                carp("Client name is malformed.\n");
-                exit 1;
-        }
-        my %h = (ip=>$config->ipaddress);
-        if (my @C = list_adapter(\%h)) {
-                carp("IP address " . $config->ipaddress ." is assigned to another client.\n");
-                exit 1;
-        }
-        my %h2 = (mac=>$config->MACaddress);
-        if (($config->MACaddress) && (my @C = list_adapter(\%h2)) ) {
-                carp("MAC address " . $config->MACaddress ." is assigned to another client.\n");
-                exit 1;
-        }
+    if (exists_client($config->name)) {
+	carp("Client " . $config->name ." already exists.\n");
+	exit 1;
+    }
+    if ($config->name=~/ /) {
+	carp("Client name is malformed.\n");
+	exit 1;
+    }
+    my %h = (ip=>$config->ipaddress);
+    if (my @C = list_adapter(\%h)) {
+	carp("IP address " . $config->ipaddress ." is assigned to another client.\n");
+	exit 1;
+    }
+    my %h2 = (mac=>$config->MACaddress);
+    if (($config->MACaddress) && (my @C = list_adapter(\%h2)) ) {
+	carp("MAC address " . $config->MACaddress ." is assigned to another client.\n");
+	exit 1;
+    }
 
-        &verbose("Defining objects.");
-        my $clientdef = new SIS::Client($config->name);
-        $clientdef->hostname($config->name.".".$config->domain);
-        $clientdef->domainname($config->domain);
-        $clientdef->imagename($config->image);
-        $clientdef->route($config->gateway);
-                
-        if (linkscript($clientdef)){
-                set_client($clientdef);
-                my $adapdef = new SIS::Adapter("eth0");
-                $adapdef->client($config->name);
-                $adapdef->ip($config->ipaddress);
-                $adapdef->netmask($config->netmask);
-                $adapdef->mac($config->MACaddress);
-                set_adapter($adapdef);
-	        &verbose("Syncing /etc/hosts");
-                synchosts();
-        } else {
-                carp("Client " . $config->name ." definition failed.\n");
-                exit 1;
-        }
+    &verbose("Defining objects.");
+    my $clientdef = new SIS::Client($config->name);
+    $clientdef->hostname($config->name.".".$config->domain);
+    $clientdef->domainname($config->domain);
+    $clientdef->imagename($config->image);
+    $clientdef->route($config->gateway);
+    
+    if (linkscript($clientdef)){
+	set_client($clientdef);
+# eth0 hard coded below?
+	my $adapdef = new SIS::Adapter("eth0");
+	$adapdef->client($config->name);
+	$adapdef->ip($config->ipaddress);
+	$adapdef->netmask($config->netmask);
+	$adapdef->mac($config->MACaddress);
+	set_adapter($adapdef);
+	&verbose("Syncing /etc/hosts");
+	synchosts();
+    } else {
+	carp("Client " . $config->name ." definition failed.\n");
+	exit 1;
+    }
 
 }else { #Must be list
-	&verbose("Listing machine data.");
-	my @machines = SIS::NewDB::list_client();
-	my $mach;
-	if (@machines) {
-                if ($config->parse){
-		        print "#Machine definitions\n";
-		        print "#Name:Hostname:Gateway:Image\n";
-                } else {
-		        print "Machine definitions.....\n";
-        		printf ("%-15.15s %-20.20s %-15.15s %-15.15s\n","Name","Hostname","Gateway","Image");
-        		print "------------------------------------------------------------------------\n";
-                }
-	}
-	foreach $mach (@machines) {
-                if ($config->parse){
-		        print $mach->{name}.":".$mach->{hostname}.":".$mach->{route}.":".$mach->{imagename}."\n";
-                } else {
-		        printf ("%-15.15s %-20.20s %-15.15s %-15.15s\n",$mach->{name},$mach->{hostname},$mach->{route},$mach->{imagename});
-                }
-	}
-	my $adapters_ref = SIS::NewDB::list_adapter(undef);
-    print Dumper $adapters_ref;
-	if (defined $adapters_ref) {
-                if ($config->parse){
-		        print "#Adapter definitions\n";
-		        print "#Machine:Adap:IP address:Netmask:MAC\n";
-                } else {
-		        print "\nAdapter definitions.....\n";
-		        printf ("%-15.15s %-5.5s %-15.15s %-15.15s %-20.20s\n","Machine","Adap","IP address","Netmask","MAC");
-		        print "------------------------------------------------------------------------\n";
-                }
+    &verbose("Listing machine data.");
+    my @machines = SIS::NewDB::list_client();
+    my $mach;
+    if (@machines) {
+	if ($config->parse){
+	    print "#Machine definitions\n";
+	    print "#Name:Hostname:Gateway:Image\n";
+	} else {
+	    print "Machine definitions.....\n";
+	    printf ("%-15.15s %-20.20s %-15.15s %-15.15s\n","Name","Hostname","Gateway","Image");
+	    print "------------------------------------------------------------------------\n";
+	}
+    }
+    foreach $mach (@machines) {
+	if ($config->parse){
+	    print $mach->{name}.":".$mach->{hostname}.":".$mach->{route}.":".$mach->{imagename}."\n";
+	} else {
+	    printf ("%-15.15s %-20.20s %-15.15s %-15.15s\n",$mach->{name},$mach->{hostname},$mach->{route},$mach->{imagename});
+	}
+    }
+    my @adapters_ref = SIS::NewDB::list_adapter(undef);
+    print Dumper @adapters_ref;
+    if (defined @adapters_ref) {
+	if ($config->parse){
+	    print "#Adapter definitions\n";
+	    print "#Machine:Adap:IP address:Netmask:MAC\n";
+	} else {
+	    print "\nAdapter definitions.....\n";
+	    printf ("%-15.15s %-5.5s %-15.15s %-15.15s %-20.20s\n","Machine","Adap","IP address","Netmask","MAC");
+	    print "------------------------------------------------------------------------\n";
 	}
-	foreach my $adap (@$adapters_ref) {
+    }
+    foreach my $adap (@adapters_ref) {
         next if !defined ($adap);
-                if ($config->parse){
-                        my $cmac=$adap->{mac};
-                        $cmac=~s/://g;
-		        print $adap->{client}.":".$adap->{devname}.":".$adap->{ip}.":".$adap->{netmask}.":".$cmac."\n";
-                } else {
-		        printf ("%-15.15s %-5.5s %-15.15s %-15.15s %-20.20s\n",
-                        $adap->{client},
-                        $adap->{devname},
-                        $adap->{ip},
-                        $adap->{netmask},
-                        $adap->{mac});
-                }
+	if ($config->parse){
+	    my $cmac=$adap->{mac};
+	    $cmac=~s/://g;
+	    print $adap->{client}.":".$adap->{devname}.":".$adap->{ip}.":".$adap->{netmask}.":".$cmac."\n";
+	} else {
+	    printf ("%-15.15s %-5.5s %-15.15s %-15.15s %-20.20s\n",
+		    $adap->{client},
+		    $adap->{devname},
+		    $adap->{ip},
+		    $adap->{netmask},
+		    $adap->{mac});
 	}
+    }
 }
 
 exit 0; 
@@ -307,79 +322,79 @@
 
 sub check_args {
 
-	# Get verbose option
-	if ($config->verbose){
-		start_verbose;
-		logger_file(*STDOUT);
-	}
-	# Default to list
-	&verbose("Checking arguments.");
-	$config->List(1) unless
-                $config->Sync or $config->Delete or $config->Update or $config->Add;
-
-	foreach ( qw(Delete Update List Sync Add) ) {
-		$operation++ if $config->$_;
-		}
-	if ($operation != 1) {
-		carp("--Add, --List, --Update, --Sync and --Delete, are mutually exclusive.");
-		return 0;
+    # Get verbose option
+    if ($config->verbose){
+	start_verbose;
+	logger_file(*STDOUT);
+    }
+    # Default to list
+    &verbose("Checking arguments.");
+    $config->List(1) unless
+	$config->Sync or $config->Delete or $config->Update or $config->Add;
+
+    foreach ( qw(Delete Update List Sync Add) ) {
+	$operation++ if $config->$_;
+    }
+    if ($operation != 1) {
+	carp("--Add, --List, --Update, --Sync and --Delete, are mutually exclusive.");
+	return 0;
+    }
+    if ($config->image) {
+	unless (exists_image($config->image)){
+	    carp("Image ". $config->image . " does not exist.");
+	    return 0;
 	}
-	if ($config->image) {
-		unless (exists_image($config->image)){
-			carp("Image ". $config->image . " does not exist.");
-			return 0;
-		}
-	}
-	if ($config->Update) {
-		&verbose("Checking --Update options.");
-		if ((! $config->name) && (!$config->all)) {
-			carp("You must specify --name or --all with --Update.");
-			return 0;
-		}
-	} elsif ($config->Delete) {
-		&verbose("Checking --Delete options.");
-		if (! $config->all && ! $config->name) {
-			carp("The --Delete flag requires either --all or --name <name>");
-			return 0;
-		}
-	} elsif ($config->Sync) {
-		my $opt=0;
-		foreach ( qw(name all ipaddress MACaddress domain gateway netmask image) ) {
-			$opt++ if $config->$_;
-		}
-		unless ($opt) {
-			carp("Only --verbose is valid with --Sync.");
-			return 0;
-		}
-	} elsif ($config->Add) {
-		&verbose("Checking --Add options.");
-                unless (($config->name) && ($config->ipaddress) && ($config->image)) { 
-                        carp("You must specify --name, --ipaddress, & --image with --Add.");
-                        return 0;
-                }
-                if ($config->name=~/,/) {
-                        carp("When used with --Add, --name must be a single name, not a list.");
-                        return 0;
-                }
-        }
+    }
+    if ($config->Update) {
+	&verbose("Checking --Update options.");
+	if ((! $config->name) && (!$config->all)) {
+	    carp("You must specify --name or --all with --Update.");
+	    return 0;
+	}
+    } elsif ($config->Delete) {
+	&verbose("Checking --Delete options.");
+	if (! $config->all && ! $config->name) {
+	    carp("The --Delete flag requires either --all or --name <name>");
+	    return 0;
+	}
+    } elsif ($config->Sync) {
+	my $opt=0;
+	foreach ( qw(name all ipaddress MACaddress domain gateway netmask image) ) {
+	    $opt++ if $config->$_;
+	}
+	unless ($opt) {
+	    carp("Only --verbose is valid with --Sync.");
+	    return 0;
+	}
+    } elsif ($config->Add) {
+	&verbose("Checking --Add options.");
+	unless (($config->name) && ($config->ipaddress) && ($config->image)) { 
+	    carp("You must specify --name, --ipaddress, & --image with --Add.");
+	    return 0;
+	}
+	if ($config->name=~/,/) {
+	    carp("When used with --Add, --name must be a single name, not a list.");
+	    return 0;
+	}
+    }
 
-        if  ($config->parse) {
-                if (not $config->List) {
-                        carp("--List must be specified with --parse\n");
-                        return 0;
-                }
-        }
+    if  ($config->parse) {
+	if (not $config->List) {
+	    carp("--List must be specified with --parse\n");
+	    return 0;
+	}
+    }
 
-	return 1;
+    return 1;
 
 }# check_args
 
-sub usage {
-    my $progname = $0;
-    if ($progname =~ m/(.+\/)(\w+)/) {
-	$progname = $2;
-    }
-    print <<USAGE;
+    sub usage {
+	my $progname = $0;
+	if ($progname =~ m/(.+\/)(\w+)/) {
+	    $progname = $2;
+	}
+	print <<USAGE;
 usage: $progname [ operation ] <options>
   operation
     -A, --Add               add machine
------------------------------------------------------------------------------
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

Reply via email to