#!/usr/bin/perl
# mighosts.cgi
# ...  Servicios de Tarantella.
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo  --- license GNU GPL 

 require './stta-lib.pl';
do "ldap-lib.pl";

&headerstta("HOSTS --- MIGRATION", "", "",undef,1,1,$text{headpage_rigth} );
print "<hr><p>\n"; 
&ReadParse();

 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>Hosts Migration</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<center>\n";

 $grp_name="";
 $dn_hosts="";
 %h_hosts=&list_hosts();
 
 foreach $item (keys (%h_hosts)) {   
    $dn_hosts=$h_hosts{$item}->{obj};
    $host_name=$h_hosts{$item}->{name};

    if ( $config{'is_ldapcache'} eq "true" ) { 
            $dnldap = "default";
            $dn_cache=$dn_hosts;
            &connect_cache ();
            $ldapcache_server=1;
            $default_obj="cn=$config{ldapcache_defaultobj}";
#            @tta3tier=&set_tta3tier($default_obj,$dn_cache,$dnldap,"add","host");
   $tta3tier->{origin} = $default_obj;
   $tta3tier->{target} = $dn_cache;
   $tta3tier->{oudn} = $dnldap;
   $tta3tier->{action} = "add";
   $tta3tier->{objetype} = "hosts";
   $tta3tier->{login} = "rima";
   $tta3tier->{password} = "tde2001";
   $tta3tier->{title} = "Login para ".$host_name;
   $tta3tier->{stringcmd} = "";
   $tta3tier->{domain} = "ttarima";
   $tta3tier->{appkey1} = "";
   $tta3tier->{appkey2} = "";
   $tta3tier->{appkey3} = "";
   $tta3tier->{appkey4} = "";
   $tta3tier->{appkey5} = "";
   $tta3tier->{appkey6} = "";
            &cache_obj(\%tta3tier);
            if ( $config{ldapcache2_server}.length gt 0 ) {
                 $ldapcache_server=2;
                 &connect_cache ();
                 &cache_obj(\%tta3tier);
            }
    }
    print "<p> Making .... $host_name ($dn_hosts) </p>\n";
 }
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;

