Subversion Repositories DevTools

Rev

Rev 1289 | Rev 3846 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1289 Rev 3515
Line 43... Line 43...
43
#
43
#
44
my $logger = StdLogger->new();                  # Stdout logger. Only during config
44
my $logger = StdLogger->new();                  # Stdout logger. Only during config
45
my $name = basename( $ARGV[0]);
45
my $name = basename( $ARGV[0]);
46
   $name =~ s~.conf$~~;
46
   $name =~ s~.conf$~~;
47
my $now = 0;
47
my $now = 0;
-
 
48
my $tar = 'tar';
-
 
49
my $gzip = 'gzip';
48
my $tagDirTime = 0;
50
my $tagDirTime = 0;
49
my $lastDirScan = 0;
51
my $lastDirScan = 0;
50
my $lastReleaseScan = 0;
52
my $lastReleaseScan = 0;
51
my $releaseScanMode = 0;
53
my $releaseScanMode = 0;
52
my $lastTagListScan = 0;
54
my $lastTagListScan = 0;
Line 54... Line 56...
54
my $mtimeConfig = 0;
56
my $mtimeConfig = 0;
55
my $conf;
57
my $conf;
56
my $extraPkgs;
58
my $extraPkgs;
57
my $excludePkgs;
59
my $excludePkgs;
58
my %releaseData;
60
my %releaseData;
-
 
61
my $comError = 0;
59
 
62
 
60
#
63
#
61
#   Describe config uration parameters
64
#   Describe config uration parameters
62
#
65
#
63
my %cdata = (
66
my %cdata = (
Line 248... Line 251...
248
 
251
 
249
    #
252
    #
250
    #   Get list of packages from Remote site
253
    #   Get list of packages from Remote site
251
    #   Invoke a program on the remote site and parse the results
254
    #   Invoke a program on the remote site and parse the results
252
    #
255
    #
253
    #     ssh  -i ./ssh/id_rsa_pkg_admin  pkg_admin@10.247.28.57 "./get_plist.pl"
-
 
254
    #
-
 
255
    #   Returned data looks like:
256
    #   Returned data looks like:
256
    #   1141792602 GMT(Wed Mar  8 04:36:42 2006) [DL] ishieldmodules/11.5.0.cots
257
    #   1141792602 GMT(Wed Mar  8 04:36:42 2006) [DL] ishieldmodules/11.5.0.cots
257
    #   
258
    #   
258
    #
259
    #
259
    my $remotePkgList;
260
    my $remotePkgList;
260
    my $ph;
261
    my $ph;
261
    my $tgt_cmd = "$conf->{'bindir'}/get_plist.pl";
262
    my $tgt_cmd = "$conf->{'bindir'}/get_plist.pl";
262
    my $ssh_cmd = "ssh -n -o \"BatchMode yes\" -i $conf->{'identity'} $conf->{'user'}\@$conf->{'hostname'} \"$tgt_cmd\" 2>&1";
263
    my $ssh_cmd = sshCmd($tgt_cmd);
263
 
264
 
264
    $logger->verbose2("processReleaseList:ssh_cmd:$ssh_cmd");
265
    $logger->verbose2("processReleaseList:ssh_cmd:$ssh_cmd");
265
    open ($ph, "$ssh_cmd |");
266
    open ($ph, "$ssh_cmd |");
266
    while ( <$ph> )
267
    while ( <$ph> )
267
    {
268
    {
Line 275... Line 276...
275
            $logger->warn("processReleaseList:Bad Data: $_");
276
            $logger->warn("processReleaseList:Bad Data: $_");
276
        }
277
        }
277
    }
278
    }
278
    close ($ph);
279
    close ($ph);
279
    $logger->verbose("processReleaseList:End: $?");
280
    $logger->verbose("processReleaseList:End: $?");
-
 
281
    LogTxError ($?);
280
    if ( $? != 0 )
282
    if ( $? != 0 )
281
    {
283
    {
282
        $logger->warn("Cannot retrieve package list: $?");
284
        $logger->warn("Cannot retrieve package list: $?");
283
        return;
285
        return;
284
    }
286
    }
-
 
287
 
285
#Utils::DebugDumpData ("remotePkgList", $remotePkgList);
288
#Utils::DebugDumpData ("remotePkgList", $remotePkgList);
286
    
289
    
287
 
290
 
288
    #
291
    #
289
    #   Determine the set of packages in the releases to be transferred
292
    #   Determine the set of packages in the releases to be transferred
Line 641... Line 644...
641
 
644
 
642
    #
645
    #
643
    #   Transfer to target
646
    #   Transfer to target
644
    #   Create the process pipe to transfer the file
647
    #   Create the process pipe to transfer the file
645
    #   gzip the file and pipe the result through a ssh session to the target machine
648
    #   gzip the file and pipe the result through a ssh session to the target machine
646
    #   gzip -c filename |  ssh  -i $IDENTITY  pkg_admin@${TARGET_HOST} "./receive_file filename"
649
    #   gzip -c filename |  ssh  ... "./receive_file filename"
647
    #
650
    #
648
    my $ph;
651
    my $ph;
649
    my $gzip_cmd = "gzip --no-name -c \"$filename\"";
652
    my $gzip_cmd = "$gzip --no-name -c \"$filename\"";
650
    my $tgt_cmd = "$conf->{'bindir'}/receive_file \"ArchiveList\"";
653
    my $tgt_cmd = "$conf->{'bindir'}/receive_file \"ArchiveList\"";
651
    my $ssh_cmd = "ssh -o \"BatchMode yes\" -i $conf->{'identity'} $conf->{'user'}\@$conf->{'hostname'} \"$tgt_cmd\" 2>&1";
654
    my $ssh_cmd = sshCmd($tgt_cmd);
652
 
655
 
653
    $logger->verbose2("sendPackageList:gzip_cmd:$gzip_cmd");
656
    $logger->verbose2("sendPackageList:gzip_cmd:$gzip_cmd");
654
    $logger->verbose2("sendPackageList:tgt_cmd:$tgt_cmd");
657
    $logger->verbose2("sendPackageList:tgt_cmd:$tgt_cmd");
655
    $logger->verbose2("sendPackageList:ssh_cmd:$ssh_cmd");
658
    $logger->verbose2("sendPackageList:ssh_cmd:$ssh_cmd");
656
 
659
 
Line 659... Line 662...
659
    {
662
    {
660
        chomp;
663
        chomp;
661
        $logger->verbose2("sendPackageList:Data: $_");
664
        $logger->verbose2("sendPackageList:Data: $_");
662
    }
665
    }
663
    close ($ph);
666
    close ($ph);
664
    $logger->verbose("sendPackageList:End: $?");
-
 
665
    unlink $filename;
667
    unlink $filename;
-
 
668
    $logger->verbose("sendPackageList:End: $?");
-
 
669
    LogTxError ($?);
666
}
670
}
667
 
671
 
668
 
672
 
669
#-------------------------------------------------------------------------------
673
#-------------------------------------------------------------------------------
670
# Function        : getPkgList
674
# Function        : getPkgList
Line 1003... Line 1007...
1003
 
1007
 
1004
    #
1008
    #
1005
    #   Create the process piple to transfer the package
1009
    #   Create the process piple to transfer the package
1006
    #   Tar the directory and pipe the result through a ssh session to
1010
    #   Tar the directory and pipe the result through a ssh session to
1007
    #   the target machine
1011
    #   the target machine
1008
    #   gtar -czf - -C "$dpkg/${pname}/${pver}" . |  ssh  -i $IDENTITY  pkg_admin@${TARGET_HOST} "./receive_package ${rx_opts} \"$pname\" \"$pver\""
1012
    #   $tar -czf - -C "$dpkg/${pname}/${pver}" . |  ssh  ... "./receive_package pname pver"
1009
    #
1013
    #
1010
    my $ph;
1014
    my $ph;
1011
    my $tar_cmd = "gtar -czf - -C \"$sfile\" .";
1015
    my $tar_cmd = "$tar -czf - -C \"$sfile\" .";
1012
    my $tgt_opts = defined($plink) ? "\"-L$plink\"" : '';
1016
    my $tgt_opts = defined($plink) ? "\"-L$plink\"" : '';
1013
    my $tgt_cmd = "$conf->{'bindir'}/receive_package $tgt_opts \"$pname\" \"$pver\"";
1017
    my $tgt_cmd = "$conf->{'bindir'}/receive_package $tgt_opts \"$pname\" \"$pver\"";
1014
    my $ssh_cmd = "ssh -o \"BatchMode yes\" -i $conf->{'identity'} $conf->{'user'}\@$conf->{'hostname'} \"$tgt_cmd\" 2>&1";
1018
    my $ssh_cmd = sshCmd($tgt_cmd);
1015
 
1019
 
1016
    $logger->verbose2("transferPackage:tar_cmd:$tar_cmd");
1020
    $logger->verbose2("transferPackage:tar_cmd:$tar_cmd");
1017
    $logger->verbose2("transferPackage:tgt_cmd:$tgt_cmd");
1021
    $logger->verbose2("transferPackage:tgt_cmd:$tgt_cmd");
1018
    $logger->verbose2("transferPackage:ssh_cmd:$ssh_cmd");
1022
    $logger->verbose2("transferPackage:ssh_cmd:$ssh_cmd");
1019
 
1023
 
Line 1035... Line 1039...
1035
    }
1039
    }
1036
    else
1040
    else
1037
    {
1041
    {
1038
        $logger->warn("transferPackage:Transfer Error: $pname, $pver, $?");
1042
        $logger->warn("transferPackage:Transfer Error: $pname, $pver, $?");
1039
    }
1043
    }
-
 
1044
    LogTxError ($?);
1040
    return $rv;
1045
    return $rv;
1041
}
1046
}
1042
 
1047
 
1043
#-------------------------------------------------------------------------------
1048
#-------------------------------------------------------------------------------
1044
# Function        : deletePackage
1049
# Function        : deletePackage
Line 1058... Line 1063...
1058
    my $rv = 0;
1063
    my $rv = 0;
1059
    $logger->logmsg("deletePackage: $pname, $pver");
1064
    $logger->logmsg("deletePackage: $pname, $pver");
1060
 
1065
 
1061
    #
1066
    #
1062
    #   Create the process pipe to delete the package
1067
    #   Create the process pipe to delete the package
1063
    #   Tar the directory and pipe the result through a ssh session to
1068
    #   ssh  ... "./delete_package ${rx_opts} \"$pname\" \"$pver\""
1064
    #   the target machine
-
 
1065
    #   gtar -czf - -C "$dpkg/${pname}/${pver}" . |  ssh  -i $IDENTITY  pkg_admin@${TARGET_HOST} "./receive_package ${rx_opts} \"$pname\" \"$pver\""
-
 
1066
    #
1069
    #
1067
    my $ph;
1070
    my $ph;
1068
    my $flags = $pdata->{FORCEDELETE}  ? '' : ' -T';
1071
    my $flags = $pdata->{FORCEDELETE}  ? '' : ' -T';
1069
    my $tgt_cmd = "$conf->{'bindir'}/delete_package $flags \"$pname\" \"$pver\"";
1072
    my $tgt_cmd = "$conf->{'bindir'}/delete_package $flags \"$pname\" \"$pver\"";
1070
    my $ssh_cmd = "ssh -o \"BatchMode yes\" -i $conf->{'identity'} $conf->{'user'}\@$conf->{'hostname'} \"$tgt_cmd\" 2>&1";
1073
    my $ssh_cmd = sshCmd($tgt_cmd);
1071
 
1074
 
1072
    $logger->verbose2("deletePackage:tgt_cmd:$tgt_cmd");
1075
    $logger->verbose2("deletePackage:tgt_cmd:$tgt_cmd");
1073
    $logger->verbose2("deletePackage:ssh_cmd:$ssh_cmd");
1076
    $logger->verbose2("deletePackage:ssh_cmd:$ssh_cmd");
1074
 
1077
 
1075
    open ($ph, "$ssh_cmd |");
1078
    open ($ph, "$ssh_cmd |");
Line 1086... Line 1089...
1086
    }
1089
    }
1087
    else
1090
    else
1088
    {
1091
    {
1089
        $logger->warn("deletePackage:Error: $pname, $pver, $?");
1092
        $logger->warn("deletePackage:Error: $pname, $pver, $?");
1090
    }
1093
    }
-
 
1094
    LogTxError ($?);
1091
    return $rv;
1095
    return $rv;
1092
}
1096
}
1093
 
1097
 
-
 
1098
#-------------------------------------------------------------------------------
-
 
1099
# Function        : sshCmd
-
 
1100
#
-
 
1101
# Description     : Generate a ssh based command
-
 
1102
#
-
 
1103
# Inputs          : Target command
-
 
1104
#
-
 
1105
# Returns         : An shh command string
-
 
1106
#
-
 
1107
sub sshCmd
-
 
1108
{
-
 
1109
    my ($tgt_cmd) = @_;
-
 
1110
    return "ssh -o \"BatchMode yes\" -i $conf->{'identity'} $conf->{'user'}\@$conf->{'hostname'} \"$tgt_cmd\" 2>&1";
-
 
1111
}
-
 
1112
 
1094
 
1113
 
1095
#-------------------------------------------------------------------------------
1114
#-------------------------------------------------------------------------------
1096
# Function        : parsePkgList
1115
# Function        : parsePkgList
1097
#
1116
#
1098
# Description     : Parse one line from a pkgList
1117
# Description     : Parse one line from a pkgList
Line 1167... Line 1186...
1167
    
1186
    
1168
 
1187
 
1169
}
1188
}
1170
 
1189
 
1171
#-------------------------------------------------------------------------------
1190
#-------------------------------------------------------------------------------
-
 
1191
# Function        : LogTxError
-
 
1192
#
-
 
1193
# Description     : Detect restoration of communication and log such
-
 
1194
#                   Don't log failures as the user will do that
-
 
1195
#
-
 
1196
# Inputs          : $state                  - 0 - All is well
-
 
1197
#                                           !0  - Error
-
 
1198
#
-
 
1199
# Returns         : Nothing
-
 
1200
#
-
 
1201
sub LogTxError
-
 
1202
{
-
 
1203
    my ($state) = $@;
-
 
1204
    if ( $state )
-
 
1205
    {
-
 
1206
        $comError++;
-
 
1207
    }
-
 
1208
    elsif ( $comError )
-
 
1209
    {
-
 
1210
        $logger->warn("Communication Restored");
-
 
1211
        $comError = 0;
-
 
1212
    }
-
 
1213
}
-
 
1214
 
-
 
1215
 
-
 
1216
#-------------------------------------------------------------------------------
1172
# Function        : Error, Verbose, Warning
1217
# Function        : Error, Verbose, Warning
1173
#
1218
#
1174
# Description     : Support for JatsRmApi
1219
# Description     : Support for JatsRmApi
1175
#
1220
#
1176
# Inputs          : Message
1221
# Inputs          : Message