root/gip/branches/1_0_0_release/vdt/setup/configure_gip

Revision 2191, 73.9 kB (checked in by burt, 1 year ago)

automatically convert the name of the batch system to lowercase in the GIP

  • Property svn:executable set to *
Line 
1 #!/usr/bin/env perl
2
3 =head1 configure_gip
4
5 configure_gip - Generic Information Provider configuration script
6
7 =head2 Synopsis
8
9     configure_gip --vdt-install <VDT installation root>
10                   --usage
11                   --help
12
13 =head2 Description
14
15 =over 4
16
17
18 =item B<--vdt-install> <VDT installation root>
19
20 B<configure_gip> will look for the root of the VDT installation at
21 $VDT_LOCATION.  If you do not have that set you can specify it
22 with --vdt-install instead.
23
24 =item B<--help>, B<--usage>
25
26 Print a usage message.
27
28 =back
29
30 The following changes will be made:
31
32 =over 4
33
34 =item $VDT_LOCATION/globus/etc/grid-info-slapd.conf is edited to
35     include the GLUE Schema.
36
37 =item $VDT_LOCATION/gip/etc/osg-info-generic.conf is created with some
38     default values.
39
40 =item grid-info-resource-ldif.conf is configured to use the generic
41     information provider and disable the Globus information providers.
42
43 =back
44
45 After it is done, you will need to:
46
47 =over 4
48
49 =item Edit $VDT_LOCATION/gip/etc/osg-info-generic.conf to have correct
50     default values for your site.
51
52 =item Run the following command to create the generic information provider:
53
54 $VDT_LOCATION/sbin/osg-info-generic-config $VDT_LOCATION//gip/osg-info-generic.conf
55
56 =cut
57
58 # This script was originally written by Alain Roy of the VDT team
59 # It was heavily modified by Shaowen Wang <shaowen-wang@uiowa.edu>
60 # and Anand Padmanabhan <anand-padmanabhan-1@uiowa.edu> to work
61 # better in an OSG environment.
62
63
64 use strict;
65 use Getopt::Long;
66 use VDTConfigure "Generic-Information-Provider";
67 use File::Path;
68 use Text::Wrap;
69 use FileHandle;
70 #-----------------------------------------------------------------------
71 #
72 # Global Variables
73 #
74 #-----------------------------------------------------------------------
75 my $vdt_location = $ENV{VDT_LOCATION};
76 my $globus_location;
77 my $gip_location;
78 my $condor_bin_location;
79 my $lsf_bin_location;
80 my $pbs_bin_location;
81 my $pbs_qstat;
82 #my $batchHost;
83 my $batch;
84 my $install = 0;
85 # Read Monalisa properties file to provide pre-entered information
86 my $ml_prop_exists;
87 my $grid3_info_conf_exists;
88 my $grid3_user_vo_map_exists;
89 my $grid3;
90 #my $ml_farmname;
91 my $ml_contact_email;
92 my $ml_city;
93 my $ml_country;
94 my $ml_lat;
95 my $ml_long;
96 my $osg_sponsor;
97 #my $ml_monitor_group;
98 # Other Monitoring data
99 my $app;
100 my $data;
101 my $tmp;
102 my $wn_tmp;
103 my $site_read;
104 my $site_write;
105 my $osg_grid;
106 my $osg_site_name;
107 my $osg_site_policy;
108 my $default_se;
109 my $service_contents = '';
110 my $vo;
111 my @vo_list;
112 my %vo_access_roots; ############
113 my $se_data;
114 my $disk=1;
115 my $srm=0;
116 my $dynamic_dcache=0;
117 my $gums=1;
118 my %se_access;
119 my $sa_path;
120 my $se_host='srmhost';
121 my $se_name; ##########
122 my @gridftp_doors;
123 #my $se_version;
124 my $srm_implementation_name = "UNDEFINED";
125 my $srm_implementation_version = "UNDEFINED";
126 my $se_access_number = 0;
127 my $se_access_version = "UNDEFINED";
128 my $se_control_version = "UNDEFINED";
129 my $fullhost;
130 my %user_vo_map;
131 my %pbsQueues;
132 my @lsfQueues;
133 my $have_warnings = 0;
134 my $se_disk;
135 my $simplified_srm;
136 my $simplified_srm_path;
137 my $testbed;
138 my $bdii_hostname;
139 my $bdii_port = 2170;
140 my $bdii_base = 'mds-vo-name=local,o=grid';
141 my $bdii_contact;
142 my %scinfo;
143
144 parse_command_line();
145 initialize();
146
147 # The -install flag is undocumented and is only used
148 # during the installation process. It dumps a bit of information
149 # into the post-install/README file.
150 if ($install) {
151     installation_remarks();
152     exit(0);
153 }
154 if (defined $ENV{GLOBUS_HOSTNAME} && $ENV{GLOBUS_HOSTNAME} ne "") {
155     $fullhost = $ENV{GLOBUS_HOSTNAME};
156 } else {
157     $fullhost = get_hostname();
158 }
159 read_osg_attributes_info();
160 create_directories();
161 if ($batch =~ /pbs/i) {
162     fix_for_pbs_queues();
163 } elsif ($batch =~/lsf/i) {
164     fix_for_lsf_queues();
165 }
166 create_config_file();
167
168 # CEMonitor Configuration
169 # This will check to see if CEMon is even installed
170 setup_cemon();
171
172 vdt_install_log("########## Configured Generic-Information-Provider correctly");
173
174 exit(0);
175
176 ###########################################################################
177 #
178 # Function: parse_command_line
179 # Note:     This function exits if it detects any problem.
180 #
181 ###########################################################################
182 sub parse_command_line
183 {
184     GetOptions("vdt-install=s" => \$vdt_location,
185                "install"       => \$install,
186                "help|usage"    => \&usage);
187     usage() unless $vdt_location;
188
189 }
190
191 ###########################################################################
192 #
193 # Function: usage
194 # Purpose:  Print a usage message. Used when command-line parsing detects
195 #           a problem. Exits.
196 #
197 ###########################################################################
198 sub usage
199 {
200     print "Usage: $0 --vdt-install <vdt install root>\n";
201
202     exit 1;
203 }
204
205
206 ###########################################################################
207 #
208 # Function: initialize
209 # Purpose:  Figure out our base directories and make sure they are there.
210 #
211 ###########################################################################
212 sub initialize
213 {
214     my $date = `date`;
215     chomp($date);
216     # Trim a trailing slash so we have nice pathnames.
217     if ($vdt_location =~ /^(.*)\/$/) {
218         $vdt_location = $1;
219     }
220
221     $globus_location = $vdt_location . "/globus";
222     $gip_location = $vdt_location . "/gip";
223
224     vdt_install_log("##########");
225     vdt_install_log("# Configuring Generic-Information-Provider at $date");
226     vdt_install_log("##########");
227
228     vdt_install_log("The Globus location is $globus_location");
229     vdt_install_log("The GIP location is $gip_location");
230
231     stat($vdt_location) or die "Error can't access $vdt_location\n";
232     stat($globus_location) or die "Error can't access $globus_location\n";
233     stat($gip_location) or die "Error can't access $gip_location\n";
234
235     my $tmp_testbed = `$vdt_location/osg-version`;
236     if ($tmp_testbed =~ /^OSG-(I|V)TB-\d+\.\d+\.\d+/) {
237         $testbed = 'Integration';
238         $bdii_hostname = 'is-itb.grid.iu.edu';
239
240     } elsif ($tmp_testbed =~ /^OSG-\d+\.\d+\.\d+/) {
241         $testbed = 'Production';
242         $bdii_hostname = 'is.grid.iu.edu';
243     }
244
245     return;
246 }
247
248
249
250
251 ###########################################################################
252 #
253 # Function: remove_quotes
254 # Purpose:  Utility function to remove quotes
255 #
256 ###########################################################################
257 sub remove_quotes
258 {
259     my $tmp = $_[0];
260     $tmp  =~ s/^"(.*)"$/$1/;
261     return $tmp;
262 }
263
264 ###########################################################################
265 #
266 # Function: read_osg_attributes_info
267 # Purpose:  Sources the $vdt_locaton/monitoring/osg-attributes.conf and reads
268 #           information about $app, $data and $tmp locations
269 #
270 ###########################################################################
271 sub read_osg_attributes_info
272 {
273     my $conf = "$vdt_location/monitoring/osg-attributes.conf";
274
275     if (-e $conf){
276         my $output = `echo $conf; . $conf; echo \$OSG_APP; echo \$OSG_DATA; echo \$OSG_WN_TMP; echo \$OSG_SITE_READ; echo \$OSG_SITE_WRITE; echo \$OSG_DEFAULT_SE; echo \$OSG_GRID; echo \$OSG_SITE_NAME; echo \$OSG_SITE_INFO; echo \$OSG_CONTACT_EMAIL; echo \$OSG_SITE_CITY; echo \$OSG_SITE_COUNTRY; echo \$OSG_SITE_LATITUDE; echo \$OSG_SITE_LONGITUDE; echo \$OSG_CONDOR_LOCATION; echo \$OSG_SPONSOR`;
277         my @outList = split /\n/, $output;
278         $app = &remove_quotes($outList[1]);
279         $data = &remove_quotes($outList[2]);
280         $wn_tmp = &remove_quotes($outList[3]);
281         $site_read = &remove_quotes($outList[4]);
282         $site_write = &remove_quotes($outList[5]);
283         $default_se = &remove_quotes($outList[6]);
284         $osg_grid = &remove_quotes($outList[7]);
285         $osg_site_name = &remove_quotes($outList[8]);
286         $osg_site_policy = &remove_quotes($outList[9]);
287         $ml_contact_email=&remove_quotes($outList[10]);
288         $ml_city=&remove_quotes($outList[11]);
289         $ml_country=&remove_quotes($outList[12]);
290         $ml_lat=&remove_quotes($outList[13]);
291         $ml_long=&remove_quotes($outList[14]);
292         $condor_bin_location=&remove_quotes($outList[15]);
293         $osg_sponsor=&remove_quotes($outList[16]);
294         $condor_bin_location.="/bin";
295         $grid3_info_conf_exists=1;
296     } else {
297         $grid3_info_conf_exists=0;
298         $app = "UNDEFINED";
299         $data = "UNDEFINED";
300         $wn_tmp = "UNDEFINED";
301         $site_read = "UNDEFINED";
302         $site_write = "UNDEFINED";
303         $default_se = "UNDEFINED";
304         $osg_grid = "UNDEFINED";
305         $osg_site_name = $fullhost;
306         my @host = split /\./, $osg_site_name;
307         $osg_site_name = uc $host[0];
308
309         $osg_site_policy = "UNDEFINED";
310         $ml_contact_email= "UNDEFINED";
311         $ml_city= "UNDEFINED";
312         $ml_country= "US";
313         $ml_lat=0;
314         $ml_long=0;
315         $condor_bin_location="";
316         $osg_sponsor="UNDEFINED";
317
318
319         print wrap("", "", "WARNING: Could not locate $conf.\n");
320         $have_warnings=1;
321
322         }
323
324
325     if ($default_se =~ /^UNDEFINED$/i || $default_se =~ /^UNAVAILABLE$/i || $default_se eq "") {
326         $default_se=$fullhost;
327     }
328
329     my $vo_file     = "$vdt_location/monitoring/osg-user-vo-map.txt";
330
331     # left voi to voc code for transition to voc after testing interoperability, bugs, etc.
332     if (-e $vo_file) {
333         #my $vo_file_content = slurp($vo_file);
334         #my @vo_list = split /\n/, $vo_file_content;
335         #my %voi_to_voc = ();
336         #my @voi = ();
337         #my @voc = ();
338         open(VOFILE,"<$vo_file");
339         while (<VOFILE>){
340            if (m/^\#/ || m/^\s*$/) {
341                 #if (m/^\#voi (.*)$/) {
342                 #        @voi = split(/\s+/, $1);
343                 #} elsif (m/^\#VOc (.*)$/) {
344                 #        @voc = split(/\s+/, $1);
345                 #}
346            } else {
347                 chomp;
348                 my ($user_nm, $user_vo) = split /\ /;
349
350                 my $user_tmp;
351                 #($user_tmp, $user_vo,)= $user_vo =~ /(us)?(\w)/;
352                 ($user_tmp, $user_vo,)= $user_vo =~ /^(us)?(.*)/;
353                 $user_vo_map{$user_nm} = $user_vo;
354
355                 my $found= grep {m/^$user_vo$/} @vo_list;
356                 #foreach $user_tmp (@vo_list) {
357                 #    if ($user_vo eq $user_tmp) {
358                 #        $found=1;
359                 #    }
360                 #}
361                 if ($found == 0) {
362                     push @vo_list, $user_vo;
363                 }
364             }
365         }
366
367         #for (my $tmpi=0; $tmpi<=$#voi; $tmpi++) {
368         #        $voi_to_voc{$voi[$tmpi]} = $voc[$tmpi];
369         #}
370
371         #for (my $tmpi=0; $tmpi<=$#vo_list; $tmpi++) {
372         #        if (defined($voi_to_voc{$vo_list[$tmpi]})) {
373         #                $vo_list[$tmpi] = $voi_to_voc{$vo_list[$tmpi]};
374         #        }
375         #}
376
377         $grid3_user_vo_map_exists=1;
378     } else {
379         print wrap("", "", "WARNING: VO list file $vo_file not found.\n");
380         $have_warnings=1;
381         $grid3_user_vo_map_exists=0;
382         @vo_list =('osg');
383     }
384
385
386
387
388 ##########################################################
389 ## READ GIP CONFIG #######################################
390 ##########################################################
391 #this is only temporary, contents of this conf file will
392 #be added to osg_attributes.conf in future
393
394
395     my $gip_conf = "$vdt_location/monitoring/gip-attributes.conf";
396
397     if (-e $gip_conf){
398         my $output = `echo $gip_conf; . $gip_conf; echo \$OSG_GIP_BATCH; echo \$OSG_GIP_SRM; echo \$OSG_GIP_DISK; echo \$OSG_GIP_SE_NAME; echo \$OSG_GIP_SE_HOST; echo \$OSG_GIP_SA_PATH; echo \$OSG_GIP_SE_DISK; echo \$OSG_GIP_DATA; echo \$OSG_GIP_GUMS; echo \$OSG_GIP_SIMPLIFIED_SRM; echo \$OSG_GIP_SIMPLIFIED_SRM_PATH; echo \$OSG_GIP_SRM_IMPLEMENTATION_NAME; echo \$OSG_GIP_SRM_IMPLEMENTATION_VERSION; echo \$OSG_GIP_SE_ACCESS_VERSION; echo \$OSG_GIP_SE_CONTROL_VERSION; echo \$OSG_GIP_SE_ACCESS_NUMBER; echo \$OSG_GIP_DYNAMIC_DCACHE`;
399         my @outList = split /\n/, $output;
400         $batch   = lc(&remove_quotes($outList[1]));
401         $srm     = &remove_quotes($outList[2]);
402         $disk    = &remove_quotes($outList[3]);
403         $se_name = &remove_quotes($outList[4]);
404         $se_host = &remove_quotes($outList[5]);
405         $sa_path = &remove_quotes($outList[6]);
406         $se_disk = &remove_quotes($outList[7]);
407         $se_data = &remove_quotes($outList[8]);
408         $gums = &remove_quotes($outList[9]);
409         $simplified_srm = &remove_quotes($outList[10]);
410         $simplified_srm_path = &remove_quotes($outList[11]);
411  #       $se_version = &remove_quotes($outList[12]);
412         $srm_implementation_name =  &remove_quotes($outList[12]);
413         $srm_implementation_version =  &remove_quotes($outList[13]);
414         $se_access_version =  &remove_quotes($outList[14]);
415         $se_control_version =  &remove_quotes($outList[15]);
416         $se_access_number =  &remove_quotes($outList[16]);
417         $dynamic_dcache = &remove_quotes($outList[17]);
418
419         $scinfo{sc_number}=`. $gip_conf; echo \$OSG_GIP_SC_NUMBER;`;
420                   for(my $i=1; $i<=$scinfo{sc_number};$i++) {
421             my ($scname,$scvendor,$scmodel,$scclock,$scnumpcpus,$scnumlcpus,$scramsize,$scinbound,$scoutbound,$scnodes)=`. $gip_conf; echo \$SC_NAME; echo \$SC_VENDOR; echo \$SC_MODEL; echo \$SC_CLOCK; echo \$SC_NUMPCPUS; echo \$SC_NUMLCPUS; echo \$SC_RAMSIZE; echo \$SC_INBOUND; echo \$SC_OUTBOUND; echo \$SC_NODES`;
422
423             ($scinfo{$i}{scname},$scinfo{$i}{scvendor},$scinfo{$i}{scmodel},$scinfo{$i}{scclock},$scinfo{$i}{scnumpcpus},$scinfo{$i}{scnumlcpus},$scinfo{$i}{scramsize},$scinfo{$i}{scinbound},$scinfo{$i}{scoutbound},$scinfo{$i}{scnodes})=`. $gip_conf; echo \${OSG_GIP_SC_ARR[$i$scname]}; echo \${OSG_GIP_SC_ARR[$i$scvendor]}; echo \${OSG_GIP_SC_ARR[$i$scmodel]}; echo \${OSG_GIP_SC_ARR[$i$scclock]}; echo \${OSG_GIP_SC_ARR[$i$scnumpcpus]}; echo \${OSG_GIP_SC_ARR[$i$scnumlcpus]}; echo \${OSG_GIP_SC_ARR[$i$scramsize]}; echo \${OSG_GIP_SC_ARR[$i$scinbound]}; echo \${OSG_GIP_SC_ARR[$i$scoutbound]}; echo \${OSG_GIP_SC_ARR[$i$scnodes]};`;
424
425             foreach my $val (keys %{$scinfo{$i}}) {
426                      chomp($scinfo{$i}{$val});
427             }
428         }
429
430         if ($srm) {
431             #Collecting all gridftp access points stored in grp-attributes.conf
432             my $gridftp_doors_all =  `cat $gip_conf | grep ^OSG_GIP_SE_ACCESS_ARR`;
433             for (my $i=0; $i<$se_access_number; $i++){
434                if ( $gridftp_doors_all =~ m/OSG_GIP_SE_ACCESS_ARR\[$i]="(.*)"/i){
435                    my $door = $1;
436                    chomp($door);
437                    $gridftp_doors[$i]=$door;
438                }
439             }
440
441             if ($simplified_srm eq "y") {
442                     foreach $vo (@vo_list) {
443                             $vo_access_roots{$vo} = $simplified_srm_path;
444                     }
445             } else {
446
447                 my $vo_dir_var;
448                 my $vo_path;
449                 my $vo_path_conf_str = `cat $gip_conf | grep ^OSG_GIP_VO_DIR`;
450
451                 foreach $vo (@vo_list){
452
453                     #$vo_dir_var = "OSG_GIP_VO_".$vo."_DIR";
454
455                     # insensitive since osg-gip-configure.sh doesn't do conversion
456                     #if ($vo_path_conf_str =~ m/$vo_dir_var.*="(.*)"\n/i){
457                     if ($vo_path_conf_str =~ m/OSG_GIP_VO_DIR\[\d+\]="$vo,(.*)"/i){
458                         $vo_path = $1;
459                         chomp($vo_path);
460                         $vo_access_roots{$vo} = $vo_path;
461                     } else {
462                         print "WARNING - configure_gip: SRM Path for $vo has not been set, rerun configure-osg-gip.sh\n";
463                     }
464                 }
465             }
466         }
467
468     } else {
469         $batch   = "condor";
470         $srm     = 0;
471         $disk    = 1;
472         $se_name = "UNDEFINED";
473         $se_host = "UNDEFINED";
474         $sa_path = "UNDEFINED";
475         $se_disk = $default_se;
476         $se_data = "UNDEFINED";
477         $gums    = 1;
478
479         foreach $vo (@vo_list){
480                 $vo_access_roots{$vo} = "UNDEFINED";
481         }
482
483         print wrap("", "", "WARNING: Could not locate $gip_conf.\n");
484         $have_warnings=1;
485         }
486
487
488     # We figure out what Condor is being used by this installation,
489     # if the person wants Condor.
490     if ($batch =~ /condor/i) {
491         if($condor_bin_location == "") {
492             my $condor_setup = "$vdt_location/vdt/etc/condor-env.sh";
493             if (-e $condor_setup) {
494                 # We've installed Condor, which installed the Condor
495                 # environment setup file. This points to either the
496                 # VDT Condor, or the pre-existing Condor indicated by
497                 # the user. We parse this file to figure out the Condor
498                 # bin path
499                 my $contents = slurp($condor_setup);
500                 if ($contents =~ /^CONDOR_LOCATION=(.+)$/m) {
501                     $condor_bin_location = $1;
502                     $condor_bin_location .= "/bin";
503                 }
504             }
505             if ($condor_bin_location eq "") {
506                 open WHICH, "which condor_q 2>/dev/null |";
507                 $tmp = <WHICH>;
508                 chomp($tmp);
509                 $condor_bin_location = substr("$tmp",0,length($tmp)-9);
510             }
511
512             if ($condor_bin_location eq "") {
513                 $condor_bin_location = "$vdt_location/condor/bin";
514             }
515             stat($condor_bin_location) or die "Can't find Condor location.\n";
516         }
517     }
518     # Locate lsf binaries
519     if ($batch =~ /lsf/i) {
520          if ($lsf_bin_location eq "") {
521             open WHICH, "which lsid 2>/dev/null |";
522             $lsf_bin_location = <WHICH>;
523             chomp($lsf_bin_location);
524             $lsf_bin_location = substr("$lsf_bin_location",0,length($lsf_bin_location)-5);
525         }
526         stat($lsf_bin_location) or die "Can't find lsid location, make sure that lsf binaries are in path.\n";
527
528     }
529     # Locate pbs binaries
530     if ($batch =~ /pbs/i) {
531          if ($pbs_qstat eq "") {
532             open WHICH, "which qstat 2>/dev/null |";
533             $pbs_qstat = <WHICH>;
534             chomp($pbs_qstat);
535             $pbs_bin_location = substr("$pbs_qstat",0,length($pbs_qstat)-6);
536         }
537         stat($pbs_qstat) or die "Can't find PBS-qstat location, make sure that qstat is in path.\n";
538     }
539
540     $bdii_contact = "ldap://$bdii_hostname:$bdii_port/mds-vo-name=$osg_site_name,$bdii_base";
541
542     return;
543 }
544
545
546 ###########################################################################
547 #
548 # Function: installation_remarks
549 # Purpose:  It's installation time. Let people know what they should do
550 #           later.
551 #
552 ###########################################################################
553 sub installation_remarks
554 {
555     post_install_log("The Generic Information Provider (GIP) has been installed but not configured.  If you" .
556                      "wish to use it then you should run $vdt_location/vdt/setup/configure_gip. If" .
557                      "you are installing as part of the OSG software stack, the configure_osg.sh program will" .
558                      "do this on your behalf.\n\n");
559 }
560
561 ###########################################################################
562 #
563 # Function: create_directories
564 # Purpose:  Create GIP directories.
565 #
566 ###########################################################################
567 sub create_directories()
568 {
569     my $tmp_dir = "$gip_location/var/tmp";
570     if (!-d $tmp_dir) {
571         # This will probably create both gip and tmp.
572         vdt_install_log("Creating temporary directory for GIP: $tmp_dir");
573         system("mkdir -p $gip_location/var/tmp");
574     }
575     if ($< == 0) {
576         system("chown daemon $gip_location/var/tmp");
577     }
578
579     my $log_dir = "$gip_location/var/logs";
580     if (!-d $tmp_dir) {
581         vdt_install_log("Creating var directory for GIP: $log_dir");
582         system("mkdir -p $log_dir");
583     }
584     if ($< == 0) {
585         if (!-d "$log_dir/gip.log") {
586             system("touch $log_dir/gip.log");
587             system("chmod 666 $log_dir/gip.log");
588         }
589         if (!-d "$log_dir/modules.log") {
590             system("touch $log_dir/modules.log");
591             system("chmod 666 $log_dir/modules.log");
592         }
593     }
594
595
596     #my $plugin_dir  = "$gip_location/var/gip/plugin";
597     #if (!-d $plugin_dir) {
598     #    # This will probably create plugin.
599     #    vdt_install_log("Creating plugin directory for GIP: $plugin_dir");
600     #    system("mkdir -p $plugin_dir");
601     #}
602
603     #my $provider_dir  = "$gip_location/var/gip/provider";
604     #if (!-d $provider_dir) {
605     #    vdt_install_log("Creating provider directory for GIP: $provider_dir");
606     #    system("mkdir -p $provider_dir");
607     #}
608
609     my $ldif_dir  = "$gip_location/var/ldif";
610     if (!-d $ldif_dir) {
611         vdt_install_log("Creating static ldif directory for GIP: $ldif_dir");
612         system("mkdir -p $ldif_dir");
613     }else{
614         #Clear the existing ldif files - otherwise the information will be duplicated
615         vdt_install_log("Clear the existing files in $ldif_dir otherwise the information will be duplicated");
616         system("rm -rf $ldif_dir/*");
617     }
618
619     if (!-d "$gip_location/etc/osg-info-gip-config"){
620         vdt_install_log("Creating directory for GIP: $gip_location/etc/osg-info-gip-config");
621         system("mkdir -p $gip_location/etc/osg-info-gip-config");
622     }else{
623         #Clear the existing config files - otherwise the information will be duplicated
624         vdt_install_log("Clear the existing files in $gip_location/etc/osg-info-gip-config otherwise the information will be duplicated");
625         system("rm -rf $gip_location/etc/osg-info-gip-config/*");
626     }
627
628     foreach $vo (@vo_list){
629         vdt_install_log("Creating directory for GIP: $gip_location/var/info/$vo");
630         `mkdir -p $gip_location/var/info/$vo`;
631         vdt_install_log("Creating file for GIP: $gip_location/var/info/$vo/$vo.list");
632         `touch -a $gip_location/var/info/$vo/$vo.list`;
633     }
634
635     return;
636 }
637
638
639 ###########################################################################
640 #
641 # Function: create_site_config_file
642 # Purpose:  We create the static conf file gip-info-static-site.conf
643 #
644 ###########################################################################
645 sub create_site_config_file
646 {
647     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-site.conf";
648     my $contents ="";
649
650    $contents = $contents."dn: GlueSiteUniqueID=$osg_site_name\n"
651                         ."GlueSiteName: $osg_site_name\n"
652                         ."GlueSiteDescription: OSG Site\n"
653                         ."GlueSiteUserSupportContact: mailto: $ml_contact_email\n"
654                         ."GlueSiteSysAdminContact: mailto: $ml_contact_email\n"
655                         ."GlueSiteSecurityContact: mailto: $ml_contact_email\n"
656                         ."GlueSiteEmailContact: mailto: $ml_contact_email\n"
657                         ."GlueSiteLocation: $ml_city,$ml_country\n"
658                         ."GlueSiteLatitude: $ml_lat\n"
659                         ."GlueSiteLongitude: $ml_long\n"
660                         ."GlueSiteSponsor: $osg_sponsor\n"
661                         ."GlueSiteOtherInfo: UNDEFINED\n"
662                         ."GlueForeignKey: GlueSiteUniqueID=$osg_site_name\n"
663                         ."GlueSiteWeb: $osg_site_policy\n";
664
665     safe_write($config_file, $contents);
666
667     vdt_install_log("===== BEGIN osg-info-static-site.conf =====\n");
668     vdt_install_log($contents);
669     vdt_install_log("===== END osg-info-static-site.conf =====\n");
670
671     return;
672 }
673 ###########################################################################
674 #
675 # Function: add_to_pbs_queues
676 # Purpose:  Helper function for fix_for_pbs_queues
677 #
678 ###########################################################################
679 sub add_to_pbs_queues
680 {
681     my ($gp_ptr,$tmp_ptr,$is_user_list) = @_;
682     my $tmp_grep;
683     my $is_vo;
684     my $tmp_vo;
685
686     for my $gp (@$gp_ptr){
687        $tmp_vo=$gp;
688        if($is_user_list==1){
689           if (defined $user_vo_map{$gp}){
690              $tmp_vo= $user_vo_map{$gp};
691           }else{
692              next;
693           }
694        }
695        $is_vo = grep {m/^$tmp_vo$/} @vo_list;
696        if ($is_vo!=0) {
697           $tmp_grep = grep {m/^$tmp_vo$/} @$tmp_ptr;
698           if($tmp_grep == 0){
699              push  @$tmp_ptr, $tmp_vo;
700           }
701        }else{ #Special case for usatlas and uscms (since they may match with atlas and cms)
702           my($tmp) = $tmp_vo =~ /(?:us)?([a-zA-Z_]+)\d*/;
703           $is_vo = grep {m/^$tmp$/} @vo_list;
704           if ($is_vo!=0) {
705              $tmp_grep = grep {m/^$gp$/} @$tmp_ptr;
706              if($tmp_grep == 0){
707                 push  @$tmp_ptr, $gp;
708              }
709           }
710        }
711     }
712 }
713
714 ###########################################################################
715 #
716 # Function: fix_for_pbs_queues
717 # Purpose:  Here we create groups for each queue in pbs rather than each VO.
718 #           We track that VOs that are allowed to submit the job to queue
719 #
720 ###########################################################################
721
722 sub fix_for_pbs_queues{
723     my $queue;
724     my $group_enable = 0;
725     my $user_enable = 0;
726     my $host_enable = 0;
727     my @pbs_users;
728     my @pbs_groups;
729     my @pbs_hosts;
730     my $use_queue=0;
731     my $lastline=''; # added to fix multi-line acl_{users,groups,hosts}
732
733 #    open QSTAT, "$pbs_qstat -Q -f 2>&1 |" or die "Error running qstat ---.\n" ;
734     my @qstat_dump=`$pbs_qstat -Q -f 2>&1`or die "Error running qstat ---.\n" ;
735     my $line_num;
736     my $qstat_len=$#qstat_dump;
737
738     for($line_num=0;$line_num<=$qstat_len;$line_num++){
739         if($line_num<$qstat_len){
740             $_=$qstat_dump[$line_num];
741         }else{
742             $_='';
743         }
744         if(m/Queue:\s*(\S+)\s*/ || $line_num==$qstat_len){
745             # Condense and remove undef and make sure it works
746             # inititate variables at beginning of Queue (empty array and strings)
747             my $tmp_queue=$1;
748             my @tmp_groups;
749             if($use_queue==1) {
750                if($host_enable==1){
751                    my $is_valid_host = grep {m/^\s*$fullhost\s*$/} @pbs_hosts;
752                    if ($is_valid_host==0){
753                        my ($tmp_name,$tmp_aliases,$tmp_addrtype,$tmp_length,@address) = gethostbyname($fullhost);
754                        my ($tmpa,$tmpb,$tmpc,$tmpd) = unpack('C4',$address[0]);
755                        my $ip = "$tmpa.$tmpb.$tmpc.$tmpd";
756                        $is_valid_host = grep {m/^$ip$/} @pbs_hosts;
757                        if ($is_valid_host==0){
758                            $use_queue=0;
759                        }
760                    }
761                }
762                if($use_queue==1) {
763                   if($group_enable==1){
764                       add_to_pbs_queues(\@pbs_groups,\@tmp_groups,0);
765                   }
766                   if($user_enable==1){
767                       add_to_pbs_queues(\@pbs_users,\@tmp_groups,1);
768                   }
769                   if($user_enable==0 && $group_enable==0){
770                       @tmp_groups=@vo_list;
771                   }
772                   if($#tmp_groups>=0){
773                       @{$pbsQueues{$queue}}=@tmp_groups;
774                   }
775                }
776             }
777             undef @pbs_groups;
778             undef @pbs_users;
779             undef @pbs_hosts;
780             undef @tmp_groups;
781             undef $queue;
782             $lastline='';
783             $host_enable=0;
784             $group_enable = 0;
785             $user_enable = 0;
786             $use_queue=0;
787             $queue = $tmp_queue;
788         }
789         elsif(m/queue_type\s*=\s*(\S+)\s*/){
790             my $queue_type = $1;
791             if($queue_type eq "Execution"){
792                 $use_queue=1;
793             }else{
794                 $use_queue=0;
795             }
796         }
797         elsif(m/\s*acl_host_enable\s*=\s*True\s*/i){
798             $host_enable=1;
799         }
800         elsif(m/\s*acl_group_enable\s*=\s*True\s*/i){
801             $group_enable=1;
802         }
803         elsif(m/\s*acl_user_enable\s*=\s*True\s*/i){
804             $user_enable=1;
805         }
806         elsif(m/\s*acl_groups\s*=\s*(.+)\s*/i){
807             @pbs_groups = split /,/, $1;
808             $lastline='groups';
809         }
810         elsif(m/\s*acl_users\s*=\s*(.+)\s*/i){
811             @pbs_users = split /,/, $1;
812             $lastline='users';
813         }
814         elsif(m/\s*acl_hosts\s*=\s*(.+)\s*/i){
815             @pbs_hosts = split /,/, $1;
816             $lastline='hosts';
817         }
818         elsif($lastline ne '') { # line did not match anything else so double-check its not a multi-line wrap
819             if(!(m/\s*=\s*/i)) { # if its not a attr = value statement, then it should be a multi-line wrap
820                my @tmparr=split /,/, $_;
821                push(@pbs_users,@tmparr)  if $lastline=='users';
822                push(@pbs_groups,@tmparr) if $lastline=='groups';
823                push(@pbs_hosts,@tmparr)  if $lastline=='hosts';
824             }else{ #obviously not a multi-line wrap because we already ran into a attr = value statement
825                $lastline='';
826             }
827         }
828
829     }
830
831
832 }
833 ###########################################################################
834 #
835 # Function: fix_for_lsf_queues
836 # Purpose:  Here we create groups for each queue in pbs rather than each VO.
837 #           We track that VOs that are allowed to submit the job to queue
838 #
839 ###########################################################################
840 sub fix_for_lsf_queues(){
841 my @bqueues;
842
843 @bqueues=split(' ',`sed -n '/Attribute: queue/{n;p;}' \$VDT_LOCATION/globus/share/globus_gram_job_manager/lsf.rvf`);
844 foreach my $item (@bqueues) {
845    chomp($item);
846    if($item ne 'Values:' and $item ne '') {
847       print " ... Adding queue $item \n";
848       push(@lsfQueues,$item);
849    }
850 }
851
852 }
853
854
855
856 ###########################################################################
857 #
858 # Function: get_os_release
859 # Purpose:  Get the current OS release
860 #
861 ###########################################################################
862 sub get_os_release(){
863 my $arch;
864 my $rel;
865 my $ver;
866
867 $arch=`lsb_release -i 2>/dev/null | cut -f2`;
868 $rel=`lsb_release -r 2>/dev/null | cut -f2`;
869 $ver=`lsb_release -c 2>/dev/null | cut -f2`;
870
871 if(!defined $arch || !$arch){ #If one of the lsb_release doesnot return correct value then all of them should return correct value
872     if (-e "/etc/debian_version"){
873         my $fh = new FileHandle "/etc/debian_version";
874         chomp(my $version = <$fh>);
875         $arch = "linux-debian-$version";
876         $rel = "Debian Linux";
877         $ver=$version;
878     }elsif (-e "/etc/rocks-release"){
879         my $fh = new FileHandle "/etc/rocks-release";
880         chomp(my $version_str = <$fh>);
881         my ($version) = $version_str =~ /(\d+\.\d+)/;
882         $arch = "linux-rocks-$version";
883         $ver = $version;
884         $rel = "Rocks Linux";
885     }elsif (-e "/etc/redhat-release"){
886         my $fh = new FileHandle "/etc/redhat-release";
887         chomp(my $version_str = <$fh>);
888         if ($version_str =~ /Red Hat Linux (?:release )?([\d\.]+)/){
889             $arch = "linux-redhat-$1";
890             $ver = $1;
891             $rel = "RedHat Linux";
892         }elsif ($version_str =~ /Enterprise Linux AS release ([\d\.]+)/){
893             $arch = "linux-rhel-$1";
894             $ver = $1;
895             $rel = "RedHat Enterprise Linux";
896         }elsif ($version_str =~ /Fedora Core release ([\d\.]+)/){
897             $arch = "linux-fedora-$1";
898             $ver = $1;
899             $rel = "Fedora Core"
900         }elsif ($version_str =~ /Scientific Linux Release (\d\.?\d)(?:\.\d|\d) \(Fermi\)/) {
901             my $version = $1;
902             $version =~ s/(\d)(\d)/$1.$2/;
903             $arch = "linux-sl-fermi-$version";
904             $ver = $version;
905             $rel = "Scientific Linux";
906         }elsif ($version_str =~ /Scientific Linux SL release (\d\.?\d) \(\w+\)/){
907             my $version = $1;
908             $rel = $3;
909             $version =~ s/(\d)(\d)/$1.$2/;
910             $arch = "linux-sl-fermi-$version";
911             $ver = $version;
912         }else{
913             $arch="RedHat Generic";
914             $rel="RedHat Unknown";
915             $ver="Unknown";
916         }
917     }elsif (-e "/usr/bin/sw_vers"){
918         chomp(my $version = `/usr/bin/sw_vers -productVersion`);
919         $arch = "darwin-$version";
920         $ver = $version;
921         $rel = "Darwin";
922     }
923 }
924     if(!defined $arch || !$arch){
925         $arch = "linux-Unknown";
926     }
927     if(!defined $ver || !$ver){
928         $ver = "Unknown";
929     }
930      if(!defined $rel || !$rel){
931         $rel = "Linux";
932     }
933 chomp($arch);
934 chomp($ver);
935 chomp($rel);
936 return ("$arch", "$ver", "$rel");
937 }
938 ###########################################################################
939 #
940 # Function: get_cpu_info
941 # Purpose:  Get cpu info from /proc/cpuinfo (DEPRECATED)
942 #
943 ###########################################################################
944 sub get_cpu_info(){
945     my $model="Pentium IV";
946     my $vendor = "Intel";
947     my $line;
948     if (-e "/proc/cpuinfo"){
949         my $file = "/proc/cpuinfo";
950         my $contents = slurp($file);
951         my @lines = split /\n/, $contents;
952         foreach $line (@lines){
953             if($line =~ m/^model\s*name\s*\:\s*(.*)$/){
954                 $model=$1;
955                 chomp($model);
956             }
957             if($line=~ m/^vendor_id\s*\:\s*(.*)$/){
958                 $vendor = $1;
959                 chomp($vendor);
960             }
961         }
962     }
963     return ("$model", "$vendor");
964 }
965 ###########################################################################
966 #
967 # Function: create_cluster_config_file
968 # Purpose:  We create the static conf file osg-info-static-cluster.conf
969 #
970 ###########################################################################
971 sub create_cluster_config_file
972 {
973     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-cluster.conf";
974     my $contents    = "";
975     $contents = $contents."\ndn: GlueClusterUniqueID=$fullhost\n"
976              ."GlueClusterName: $fullhost\n"
977              ."GlueClusterService: $fullhost\n"
978              ."GlueClusterTmpDir: $data\n"
979              ."GlueClusterWNTmpDir: $wn_tmp\n";
980
981     if ($batch =~ /^pbs$/i) {
982         foreach my $queue (keys %pbsQueues){
983             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
984         }
985     } elsif ($batch =~/lsf/i) {
986         foreach my $queue (@lsfQueues){
987             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
988         }
989     }else{
990         foreach $vo (@vo_list){
991             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
992         }
993     }
994     $contents = $contents."GlueForeignKey: GlueSiteUniqueID=$osg_site_name\n";
995     $contents = $contents."GlueInformationServiceURL: $bdii_contact\n";
996
997
998     #Change the OSG Version
999     my $osg_ver = `$vdt_location/osg-version`;
1000     chomp($osg_ver);
1001     my @os = &get_os_release();
1002     #my @cpu = &get_cpu_info();
1003
1004     for(my $sc_count=1;$sc_count<=$scinfo{sc_number};$sc_count++) {
1005         my $pcpus=$scinfo{$sc_count}{scnumpcpus}*$scinfo{$sc_count}{scnodes};
1006         my $lcpus=$scinfo{$sc_count}{scnumlcpus}*$scinfo{$sc_count}{scnodes};
1007         $contents = $contents."\ndn: GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1008                  ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n"
1009                  ."GlueSubClusterName: $scinfo{$sc_count}{scname}\n"
1010                  ."GlueHostApplicationSoftwareRunTimeEnvironment: $osg_ver\n"
1011                  ."GlueHostArchitectureSMPSize: $scinfo{$sc_count}{scnumpcpus}\n"
1012                  ."GlueHostBenchmarkSF00: 380\n"
1013                  ."GlueHostBenchmarkSI00: 400\n"
1014                  ."GlueHostMainMemoryRAMSize: $scinfo{$sc_count}{scramsize}\n"
1015                  ."GlueHostMainMemoryVirtualSize: $scinfo{$sc_count}{scramsize}\n"
1016                  ."GlueHostNetworkAdapterInboundIP: " . uc($scinfo{$sc_count}{scinbound}) . "\n"
1017                  ."GlueHostNetworkAdapterOutboundIP: " . uc($scinfo{$sc_count}{scoutbound}) . "\n"
1018                  ."GlueHostOperatingSystemName: $os[0]\n"
1019                  ."GlueHostOperatingSystemRelease: $os[2]\n"
1020                  ."GlueHostOperatingSystemVersion: $os[1]\n"
1021                  ."GlueHostProcessorClockSpeed: $scinfo{$sc_count}{scclock}\n"
1022                  ."GlueHostProcessorModel: $scinfo{$sc_count}{scmodel}\n"
1023                  ."GlueHostProcessorVendor: $scinfo{$sc_count}{scvendor}\n"
1024                  ."GlueSubClusterPhysicalCPUs: $pcpus\n"
1025                  ."GlueSubClusterLogicalCPUs: $lcpus\n"
1026                  ."GlueSubClusterTmpDir: $data\n"
1027                  ."GlueSubClusterWNTmpDir: $wn_tmp\n"
1028                  ."GlueInformationServiceURL: $bdii_contact";
1029
1030
1031         # Add local stograge requirement information
1032         $contents = $contents."\ndn: GlueLocationLocalID=OSG_SITE_READ, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1033                              ."GlueLocationName: OSG_SITE_READ\n"
1034                              ."GlueLocationVersion: UNDEFINED\n"
1035                              ."GlueLocationPath: $site_read\n"
1036                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1037
1038         $contents = $contents."\ndn: GlueLocationLocalID=OSG_SITE_WRITE, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1039                              ."GlueLocationName: OSG_SITE_WRITE\n"
1040                              ."GlueLocationVersion: UNDEFINED\n"
1041                              ."GlueLocationPath: $site_write\n"
1042                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1043
1044         $contents = $contents."\ndn: GlueLocationLocalID=OSG_GRID, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1045                              ."GlueLocationName: OSG_GRID\n"
1046                              ."GlueLocationVersion: UNDEFINED\n"
1047                              ."GlueLocationPath: $osg_grid\n"
1048                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1049     }
1050     safe_write($config_file, $contents);
1051
1052     vdt_install_log("===== BEGIN osg-info-static-cluster.conf =====\n");
1053     vdt_install_log($contents);
1054     vdt_install_log("===== END osg-info-static-cluster.conf =====\n");
1055
1056     return;
1057 }
1058
1059 ###########################################################################
1060 #
1061 # Function: create_ce_config_file
1062 # Purpose:  We create the static conf file osg-info-static-ce.conf
1063 #
1064 ###########################################################################
1065 sub create_ce_config_file
1066 {
1067
1068     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-ce.conf";
1069     my $contents    = "";
1070
1071     $contents = $contents."\nGlueCEHostingCluster: $fullhost\n"
1072                          ."GlueCEInfoGatekeeperPort: 2119\n"
1073                          ."GlueCEInfoHostName: $fullhost\n"
1074                          ."GlueCEInfoLRMSType: $batch\n"
1075                          ."GlueCEInfoLRMSVersion: not defined\n"
1076                          ."GlueCEInfoTotalCPUs: 0\n"
1077                          ."GlueCEPolicyMaxCPUTime: 6000\n"
1078                          ."GlueCEPolicyMaxRunningJobs: 0\n"
1079                          ."GlueCEPolicyMaxTotalJobs: 0\n"
1080                          ."GlueCEPolicyMaxWallClockTime: 6000\n"
1081                          ."GlueCEPolicyPriority: 1\n"
1082                          ."GlueCEPolicyMaxObtainableWallClockTime: 0\n"
1083                          ."GlueCEPolicyMaxObtainableCPUTime: 0\n"
1084                          ."GlueCEPolicyMaxWaitingJobs: 0\n"
1085                          ."GlueCEPolicyMaxSlotsPerJob: 0\n"
1086                          ."GlueCEPolicyPreemption: 0\n"
1087                          ."GlueCEStateEstimatedResponseTime: 14400\n"
1088                          ."GlueCEStateFreeCPUs: 0\n"
1089                          ."GlueCEStateRunningJobs: 0\n"
1090                          ."GlueCEStateStatus: Production\n"
1091                          ."GlueCEStateTotalJobs: 0\n"
1092                          ."GlueCEStateWaitingJobs: 0\n"
1093                          ."GlueCEStateWorstResponseTime: 0\n"
1094                          ."GlueCEInfoJobManager: $batch\n"
1095                          ."GlueCEStateFreeJobSlots: 0\n"
1096                          ."GlueInformationServiceURL: $bdii_contact\n"
1097                          ."GlueCEPolicyAssignedJobSlots: 0\n"
1098                          ."GlueCEImplementationName: UNDEFINED\n"
1099                          ."GlueCEImplementationVersion: UNDEFINED\n"
1100                          ."GlueCECapability: UNDEFINED\n";
1101
1102     if ($batch =~ /^pbs$/i) {
1103         foreach my $queue (keys %pbsQueues){
1104             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1105                                  ."GlueCEName: $queue\n"
1106                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1107                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$queue\n"
1108                                  ."GlueCEInfoApplicationDir:  $app\n"
1109                                  ."GlueCEInfoDataDir: $data\n";
1110             foreach $vo (@{$pbsQueues{$queue}}){
1111                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1112             }
1113
1114             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1115                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1116             } else {
1117                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1118             }
1119         }
1120     }
1121     elsif ($batch =~ /^lsf$/i) {
1122         foreach my $queue (@lsfQueues){
1123             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1124                                  ."GlueCEName: $queue\n"
1125                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1126                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$queue\n"
1127                                  ."GlueCEInfoApplicationDir:  $app\n"
1128                                  ."GlueCEInfoDataDir: $data\n";
1129             foreach $vo (@vo_list){
1130                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1131             }
1132
1133             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1134                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1135             } else {
1136                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1137             }
1138         }
1139     }
1140     else{
1141         foreach $vo (@vo_list){
1142             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1143                                  ."GlueCEName: $vo\n"
1144                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1145                                  ."GlueCEAccessControlBaseRule: VO:$vo\n"
1146                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$vo\n"
1147                                  ."GlueCEInfoApplicationDir:  $app\n"
1148                                  ."GlueCEInfoDataDir: $data\n";
1149
1150             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1151                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1152             } else {
1153                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1154             }
1155         }
1156     }
1157
1158     if ($batch =~ /^pbs$/i) {
1159         foreach my $queue (keys %pbsQueues){
1160
1161             foreach $vo (@{$pbsQueues{$queue}}){
1162                 $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1163                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1164
1165                 if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1166                     $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1167                 } else {
1168                     $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1169                 }
1170
1171                 $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1172                                      ."GlueCEInfoDataDir: $data\n"
1173                                      ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1174             }
1175         }
1176     } elsif ($batch =~ /^lsf$/i) {
1177         foreach my $queue (@lsfQueues){
1178             foreach $vo (@vo_list){
1179                 $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1180                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1181
1182                 if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1183                     $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1184                 } else {
1185                     $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1186                 }
1187
1188                 $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1189                                      ."GlueCEInfoDataDir: $data\n"
1190                                      ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1191             }
1192         }
1193     }else{
1194         foreach $vo (@vo_list){
1195             $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1196                                  ."GlueCEAccessControlBaseRule: VO:$vo\n";
1197
1198             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1199                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1200             } else {
1201                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1202             }
1203
1204             $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1205                                  ."GlueCEInfoDataDir: $data\n"
1206                                  ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
1207         }
1208     }
1209
1210     if ($batch !~ /^pbs$/i) {
1211         safe_write($config_file, $contents);
1212     }
1213
1214     vdt_install_log("===== BEGIN osg-info-static-ce.conf =====\n");
1215     vdt_install_log($contents);
1216     vdt_install_log("===== END osg-info-static-ce.conf =====\n");
1217
1218     return;
1219 }
1220
1221 ###########################################################################
1222 #
1223 # Function: create_se_config_file
1224 # Purpose:  We create the static conf file osg-info-static-se.conf
1225 #
1226 ###########################################################################
1227 sub create_se_config_file
1228 {
1229     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-se.conf";
1230     my $contents    = "";
1231
1232     # Write SE part of configuration. A site could publish both srm and gsiftp information through GIP simultaneously.
1233      my ($major_ver, $minor_ver) = split(/\./, $se_control_version);
1234
1235     my $se_version=$major_ver;
1236     #print "$se_control_version, $major_ver , $minor_ver \n\n";
1237
1238     if ($srm && $dynamic_dcache!=1) {
1239         $contents=$contents."\ndn: GlueSEUniqueID=$se_host\n"
1240                            ."GlueSEName: $se_name:srm_v$se_version\n"
1241                            ."GlueSEPort: 8443\n"
1242                            ."GlueSESizeTotal: 0\n"
1243                            ."GlueSESizeFree: 0\n"
1244                            ."GlueSEArchitecture: other\n"
1245                            ."GlueSEImplementationName: $srm_implementation_name\n"
1246                            ."GlueSEImplementationVersion: $srm_implementation_version\n"
1247                            ."GlueSEStatus: Production\n"
1248                            ."GlueSETotalOnlineSize: 0\n"
1249                            ."GlueSEUsedOnlineSize: 0\n"
1250                            ."GlueSETotalNearlineSize: 0\n"
1251                            ."GlueSEUsedNearlineSize: 0\n"
1252                            ."GlueForeignKey: GlueSiteUniqueID=$osg_site_name\n"
1253                            ."GlueInformationServiceURL: $bdii_contact\n";
1254
1255
1256         $contents=$contents."\ndn: GlueSEAccessProtocolLocalID=gsiftp,GlueSEUniqueID=$se_host\n"
1257                            ."GlueSEAccessProtocolType: gsiftp\n"
1258                            ."GlueSEAccessProtocolPort: 2811\n"
1259                            ."GlueSEAccessProtocolVersion: $se_access_version\n"
1260                            ."GlueSEAccessProtocolSupportedSecurity: gsi\n"
1261                            ."GlueSEAccessProtocolMaxStreams: 1\n";
1262
1263         for(my $i=0; $i<$se_access_number; $i++){
1264             $contents=$contents."GlueSEAccessProtocolEndpoint: $gridftp_doors[$i]\n";
1265         }
1266
1267         $contents=$contents."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1268
1269
1270         if($se_version eq '2') {
1271            $contents=$contents."\ndn: GlueSEControlProtocolLocalID=srm_v2,GlueSEUniqueID=$se_host\n"
1272                               ."GlueSEControlProtocolType: SRM\n"
1273                               ."GlueSEControlProtocolEndpoint: httpg://$se_host:8443/srm/managerv2\n"
1274                               ."GlueSEControlProtocolVersion: 2.2.0\n"
1275                               ."GlueSEControlProtocolCapability: control\n"
1276                               ."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1277         }
1278
1279         $contents=$contents."\ndn: GlueSEControlProtocolLocalID=srm_v1,GlueSEUniqueID=$se_host\n"
1280                            ."GlueSEControlProtocolType: SRM\n"
1281                            ."GlueSEControlProtocolEndpoint: httpg://$se_host:8443/srm/managerv1\n"
1282                            ."GlueSEControlProtocolVersion: 1.1.0\n"
1283                            ."GlueSEControlProtocolCapability: control\n"
1284                            ."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1285
1286
1287
1288         $service_contents="\ndn: GlueServiceUniqueID=httpg://$se_host:8443/srm/managerv$se_version\n"
1289             ."GlueServiceUniqueID: httpg://$se_host:8443/srm/managerv$se_version\n"
1290             ."GlueServiceName: $se_host\n"
1291             ."GlueServiceType: SRM\n"
1292             ."GlueServiceVersion: $se_control_version\n"
1293             ."GlueServiceEndpoint: httpg://$se_host:8443/srm/managerv$se_version\n"
1294             ."GlueServiceURI: httpg://$se_host:8443/srm/managerv$se_version\n"
1295             ."GlueServiceAccessPointURL: httpg://$se_host:8443/srm/managerv$se_version\n"
1296             ."GlueServiceStatus: OK\n"
1297             ."GlueServiceStatusInfo: Production\n"
1298             ."GlueServiceWSDL: UNDEFINED\n"
1299             ."GlueServiceSemantics: UNDEFINED\n"
1300             ."GlueServiceStartTime: 1970-01-01T00:00:00Z\n"
1301             ."GlueServiceOwner:OSG\n";
1302         foreach $vo (@vo_list) {
1303                                 $service_contents=$service_contents."GlueServiceAccessControlRule: $vo\n";
1304         }
1305         $service_contents=$service_contents."\n";
1306         $service_contents=$service_contents."GlueForeignKey: GlueSiteUniqueID=$osg_site_name\n";
1307
1308
1309         foreach $vo (@vo_list){
1310
1311             my $se_access_root = $vo_access_roots{$vo};
1312             if ($se_access_root!~/^$/) {
1313                 $se_access{$vo} = $se_access_root;
1314                 $contents=$contents."\ndn: GlueSALocalID=$vo,GlueSEUniqueID=$se_host\n"
1315                                    ."GlueSARoot: $vo:$se_access_root\n"
1316                                    ."GlueSAPath: $se_access_root\n"
1317                                    ."GlueSAAccessControlBaseRule: $vo\n"
1318                                    ."GlueChunkKey: GlueSEUniqueID=$se_host\n"
1319                                    ."GlueSAType: permanent\n"
1320                                    ."GlueSAPolicyFileLifeTime: Permanent\n"
1321                                    ."GlueSAName: $vo\n"
1322                                    ."GlueSATotalOnlineSize: 0\n"
1323                                    ."GlueSAUsedOnlineSize: 0\n"
1324                                    ."GlueSAFreeOnlineSize: 0\n"
1325                                    ."GlueSAReservedOnlineSize: 0\n"
1326                                    ."GlueSATotalNearlineSize: 0\n"
1327                                    ."GlueSAUsedNearlineSize: 0\n"
1328                                    ."GlueSAFreeNearlineSize: 0\n"
1329                                    ."GlueSAReservedNearlineSize: 0\n"
1330                                    ."GlueSARetentionPolicy: replica\n"
1331                                    ."GlueSAAccessLatency: online\n"
1332                                    ."GlueSAExpirationMode: neverExpire\n"
1333                                    ."GlueSACapability: file transfer\n"
1334                                    ."GlueSAPolicyMaxFileSize: 10000\n"
1335                                    ."GlueSAPolicyMinFileSize: 1\n"
1336                                    ."GlueSAPolicyMaxData: 100\n"
1337                                    ."GlueSAPolicyMaxNumFiles: 10\n"
1338                                    ."GlueSAPolicyMaxPinDuration: 10\n"
1339                                    ."GlueSAPolicyQuota: 0\n"
1340                                    ."GlueSAStateAvailableSpace: 0\n"
1341                                    ."GlueSAStateUsedSpace: 0\n\n";
1342
1343                 $contents=$contents."dn: GlueVOInfoLocalID=$vo,GlueSALocalID=$vo,GlueSEUniqueID=$se_host\n"
1344                                    ."GlueChunkKey: GlueSALocalID=$vo\n"
1345                                    ."GlueChunkKey: GlueSEUniqueID=$se_host\n"
1346                                    ."GlueVOInfoLocalID: $vo\n"
1347                                    ."GlueVOInfoName: $vo\n"
1348                                    ."GlueVOInfoPath: $se_access_root\n"
1349                                    ."GlueVOInfoAccessControlBaseRule: $vo\n"
1350                                    ."GlueVOInfoTag: UNAVAILABLE\n\n";
1351
1352
1353             }
1354         }
1355
1356     }
1357
1358     # BUGFIX: se_access is not filled in if you are using dynamic_dcache, but
1359     # this global variable must be populated for the CESE bind to work right
1360     # later on
1361     if ($srm && $dynamic_dcache==1) {
1362        
1363         foreach $vo (@vo_list){
1364             my $se_access_root = $vo_access_roots{$vo};
1365             if ($se_access_root!~/^$/) {
1366                 $se_access{$vo} = $se_access_root;
1367             }             
1368         }                 
1369     }                     
1370
1371     my $service_config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-service.conf";
1372     safe_write($service_config_file, $service_contents);
1373     vdt_install_log("===== BEGIN osg-info-static-service.conf =====\n");
1374     vdt_install_log($service_contents);
1375     vdt_install_log("===== END osg-info-static-service.conf =====\n");
1376
1377     if ($disk) {
1378         $contents=$contents."\ndn: GlueSEUniqueID=$se_disk\n"
1379                            ."GlueSEName: $osg_site_name:disk\n"
1380                            ."GlueSEType: disk\n"
1381                            ."GlueSEPort: 2811\n"
1382                            ."GlueSESizeTotal: 0\n"
1383                            ."GlueSESizeFree: 0\n"
1384                            ."GlueSEArchitecture: disk\n"
1385                            ."GlueSEImplementationName: local disk\n"
1386                            ."GlueSEImplementationVersion: UNDEFINED\n"
1387                            ."GlueSEStatus: Production\n"
1388                            ."GlueSETotalOnlineSize: 0\n"
1389                            ."GlueSEUsedOnlineSize: 0\n"
1390                            ."GlueSETotalNearlineSize: 0\n"
1391                            ."GlueSEUsedNearlineSize: 0\n"
1392                            ."GlueForeignKey: GlueSiteUniqueID=$osg_site_name\n"
1393                            ."GlueInformationServiceURL: $bdii_contact\n";
1394
1395
1396
1397         $contents=$contents."\ndn: GlueSEAccessProtocolLocalID=gsiftp,GlueSEUniqueID=$se_disk\n"
1398                            ."GlueSEAccessProtocolType: gsiftp\n"
1399                            ."GlueSEAccessProtocolPort: 2811\n"
1400                            ."GlueSEAccessProtocolVersion: 1.0.0\n"
1401                            ."GlueSEAccessProtocolMaxStreams: 1\n"
1402                            ."GlueSEAccessProtocolSupportedSecurity: gsi\n"
1403                            ."GlueChunkKey: GlueSEUniqueID=$se_disk\n\n";
1404
1405
1406
1407         $contents=$contents."\ndn: GlueSALocalID=$se_disk,GlueSEUniqueID=$se_disk\n"
1408                            ."GlueSARoot: $se_data\n"
1409                            ."GlueSAPath: $se_data\n";
1410         foreach $vo (@vo_list){
1411             $contents=$contents."GlueSAAccessControlBaseRule: $vo\n"
1412         }
1413         $contents=$contents."GlueChunkKey: GlueSEUniqueID=$se_disk\n"
1414                            ."GlueSAType: permanent\n"
1415                            ."GlueSAPolicyFileLifeTime: Permanent\n"
1416                            ."GlueSAName: $se_disk\n"
1417                            ."GlueSATotalOnlineSize: 0\n"
1418                            ."GlueSAUsedOnlineSize: 0\n"
1419                            ."GlueSAFreeOnlineSize: 0\n"
1420                            ."GlueSAReservedOnlineSize: 0\n"
1421                            ."GlueSATotalNearlineSize: 0\n"
1422                            ."GlueSAUsedNearlineSize: 0\n"
1423                            ."GlueSAFreeNearlineSize: 0\n"
1424                            ."GlueSAReservedNearlineSize: 0\n"
1425                            ."GlueSARetentionPolicy: replica\n"
1426                            ."GlueSAAccessLatency: online\n"
1427                            ."GlueSAExpirationMode: neverExpire\n"
1428                            ."GlueSACapability: file transfer\n"
1429                            ."GlueSAPolicyMaxFileSize: 10000\n"
1430                            ."GlueSAPolicyMinFileSize: 1\n"
1431                            ."GlueSAPolicyMaxData: 100\n"
1432                            ."GlueSAPolicyMaxNumFiles: 10\n"
1433                            ."GlueSAPolicyMaxPinDuration: 10\n"
1434                            ."GlueSAPolicyQuota: 0\n"
1435                            ."GlueSAStateAvailableSpace: 1\n"
1436                            ."GlueSAStateUsedSpace: 1\n\n";
1437
1438         $contents=$contents."dn: GlueVOInfoLocalID=$se_disk,GlueSALocalID=$se_disk\n"
1439                            ."GlueChunkKey: GlueSALocalID=$se_disk\n"
1440                            ."GlueVOInfoLocalID: $se_disk\n"
1441                            ."GlueVOInfoName: $se_disk\n"
1442                            ."GlueVOInfoPath: $se_data\n";
1443         foreach $vo (@vo_list){
1444                            $contents=$contents."GlueVOInfoAccessControlBaseRule: $vo\n";
1445         }
1446                            $contents=$contents."GlueVOInfoTag: UNAVAILABLE\n\n";
1447
1448         foreach $vo (@vo_list){
1449             $contents=$contents."\ndn: GlueSALocalID=$vo,GlueSEUniqueID=$se_disk\n"
1450                                ."GlueSARoot: $vo:$vo\n"
1451                                ."GlueSAPath: $se_data\n"
1452                                ."GlueSAAccessControlBaseRule: $vo\n"
1453                                ."GlueChunkKey: GlueSEUniqueID=$se_disk\n"
1454                                ."GlueSAType: permanent\n"
1455                                ."GlueSAPolicyFileLifeTime: Permanent\n"
1456                                ."GlueSAName: $vo\n"
1457                                ."GlueSATotalOnlineSize: 0\n"
1458                                ."GlueSAUsedOnlineSize: 0\n"
1459                                ."GlueSAFreeOnlineSize: 0\n"
1460                                ."GlueSAReservedOnlineSize: 0\n"
1461                                ."GlueSATotalNearlineSize: 0\n"
1462                                ."GlueSAUsedNearlineSize: 0\n"
1463                                ."GlueSAFreeNearlineSize: 0\n"
1464                                ."GlueSAReservedNearlineSize: 0\n"
1465                                ."GlueSARetentionPolicy: replica`\n"
1466                                ."GlueSAAccessLatency: online\n"
1467                                ."GlueSAExpirationMode: neverExpire\n"
1468                                ."GlueSACapability: file transfer\n"`
1469                                ."GlueSAPolicyMaxFileSize: 10000\n"
1470                                ."GlueSAPolicyMinFileSize: 1\n"
1471                                ."GlueSAPolicyMaxData: 100\n"
1472                                ."GlueSAPolicyMaxNumFiles: 10\n"
1473                                ."GlueSAPolicyMaxPinDuration: 10\n"
1474                                ."GlueSAPolicyQuota: 0\n"
1475                                ."GlueSAStateAvailableSpace: 1\n"
1476                                ."GlueSAStateUsedSpace: 1\n\n";
1477
1478             $contents=$contents."dn: GlueVOInfoLocalID=$vo,GlueSALocalID=$vo\n"
1479                                ."GlueChunkKey: GlueSALocalID=$vo\n"
1480                                ."GlueVOInfoLocalID: $vo\n"
1481                                ."GlueVOInfoName: $vo\n"
1482                                ."GlueVOInfoPath: $se_data\n"
1483                                ."GlueVOInfoAccessControlBaseRule: $vo\n"
1484                                ."GlueVOInfoTag: UNAVAILABLE\n\n";
1485         }
1486     }
1487
1488     safe_write($config_file, $contents);
1489
1490     vdt_install_log("===== BEGIN osg-info-static-se.conf =====\n");
1491     vdt_install_log($contents);
1492     vdt_install_log("===== END osg-info-static-se.conf =====\n");
1493
1494     return;
1495 }
1496
1497 ###########################################################################
1498 #
1499 # Function: create_cesebind_config_file
1500 # Purpose:  We create the static conf file osg-info-static-cesebind.conf
1501 #
1502 ###########################################################################
1503 sub create_cesebind_config_file
1504 {
1505
1506     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-cesebind.conf";
1507     my $contents    = "";
1508
1509     if ($batch =~ /^pbs$/i) {
1510         foreach my $queue (keys %pbsQueues){
1511             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1512             if ($disk) {
1513                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1514             }
1515             if ($srm) {
1516                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1517             }
1518
1519             if ($disk) {
1520                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1521                                      ."GlueCESEBindCEAccesspoint: $data\n"
1522                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1523             }
1524
1525             if ($srm && defined $sa_path) {
1526                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1527                                      ."GlueCESEBindCEAccesspoint: $sa_path\n"
1528                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1529             }
1530         }
1531     } elsif ($batch =~ /^lsf$/i) {
1532         foreach my $queue (@lsfQueues){
1533             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1534             if ($disk) {
1535                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1536             }
1537             if ($srm) {
1538                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1539             }
1540
1541             if ($disk) {
1542                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1543                                      ."GlueCESEBindCEAccesspoint: $data\n"
1544                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1545             }
1546
1547             if ($srm && defined $sa_path) {
1548                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1549                                      ."GlueCESEBindCEAccesspoint: $sa_path\n"
1550                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1551             }
1552         }
1553     }else{
1554         foreach $vo (@vo_list){
1555             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
1556             if ($disk) {
1557                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1558             }
1559             if ($srm) {
1560                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1561             }
1562
1563             if ($disk) {
1564                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1565                                      ."GlueCESEBindCEAccesspoint: $data\n"
1566                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$vo\n";
1567             }
1568
1569             if ($srm && exists $se_access{$vo} && defined $sa_path) {
1570                 # BUGFIX: use $se_access{$vo} instead of $sa_path/$se_access{$vo}.
1571                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1572                                      ."GlueCESEBindCEAccesspoint: $se_access{$vo}\n"
1573                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$vo\n";
1574             }
1575         }
1576     }
1577
1578     if ($batch !~ /^pbs$/i) {
1579         safe_write($config_file, $contents);
1580
1581         vdt_install_log("===== BEGIN osg-info-static-cesebind.conf =====\n");
1582         vdt_install_log($contents);
1583         vdt_install_log("===== END osg-info-static-cesebind.conf =====\n");
1584     }
1585
1586     return;
1587 }
1588 #
1589 ###########################################################################
1590 #
1591 # Function: create_service_config_file
1592 # Purpose:  We create the static conf file osg-info-static-service.conf
1593 #
1594 ###########################################################################
1595 sub create_service_config_file
1596 {
1597
1598     my $config_file = "$gip_location/etc/osg-info-gip-config/osg-info-static-service.conf";
1599     my $contents    = "\n";
1600
1601     if(-e $config_file) {
1602         my $tmp;
1603         open(FILE,$config_file) || die "Could not open the config_file\n";
1604         while($tmp=<FILE>) {
1605             $contents.=$tmp;
1606         }
1607         close(FILE);
1608     }
1609
1610     safe_write($config_file, $contents);
1611
1612     vdt_install_log("===== BEGIN osg-info-static-service.conf =====\n");
1613     vdt_install_log($contents);
1614     vdt_install_log("===== END osg-info-static-service.conf =====\n");
1615
1616     return;
1617 }
1618
1619 ###########################################################################
1620 #
1621 # Function: create_generic_config_file
1622 # Purpose:  We create the static conf file osg-info-generic.conf
1623 #
1624 ###########################################################################
1625 sub create_generic_config_file
1626 {
1627     my $config_file = "$gip_location/etc/osg-info-generic.conf";
1628     if (-e $config_file){
1629         vdt_install_log("Warning: osg-info-generic.conf left unchanged since it already exists")
1630     }else{
1631         my $contents    = "";
1632
1633         $contents = $contents."temp_dir = $gip_location/var/tmp\n"
1634                              ."plugin_dir = $gip_location/plugins\n"
1635                              ."static_dir = $gip_location/var/ldif\n"
1636                              ."provider_dir = $gip_location/providers\n"
1637                              ."freshness = 300\n"
1638                              ."cache_ttl = 600\n"
1639                              ."response = 60\n"
1640                              ."timeout = 150\n";
1641
1642         safe_write($config_file, $contents);
1643
1644         vdt_install_log("===== BEGIN osg-info-generic.conf =====\n");
1645         vdt_install_log($contents);
1646         vdt_install_log("===== END osg-info-generic.conf =====\n");
1647     }
1648     return;
1649 }
1650
1651 ###########################################################################
1652 #
1653 # Function: create_config_file
1654 # Purpose:  We copy the example GIP configuration file and edit it as best
1655 #           we can on behalf of the sysadmin. Note that there is still a lot of
1656 #           editing to be done. For example, we change things like
1657 #           jobmanager-pbs to jobmanager-condor, but they also have
1658 #           jobmanager-pbs-{short|medium|long}, which will probably never
1659 #           exist on a Condor pool. It will just require hand-editing by
1660 #           the system administrator.
1661 #
1662 ###########################################################################
1663 sub create_config_file
1664 {
1665     create_site_config_file
1666     create_cluster_config_file();
1667     create_ce_config_file();
1668     create_se_config_file();
1669     create_cesebind_config_file();
1670     create_service_config_file();
1671     create_generic_config_file();
1672     create_wrapper_files();
1673     create_static_ldif_files();
1674     return;
1675 }
1676
1677 ###########################################################################
1678 #
1679 # Function: create_wrapper_files
1680 # Purpose:  We create the necessary wrapper files
1681 #
1682 ###########################################################################
1683 sub create_wrapper_files
1684 {
1685
1686     #Create provider wrapper when necessary (Currently used for gums-monitoring)
1687     my $wrapper_file = "$gip_location/providers/osg-info-dynamic-providers";
1688     my $contents='#!/bin/sh';
1689     $contents=$contents."\n"."$gip_location/libexec/osg-info-software-provider.py \n";
1690     if ($gums == 1){
1691         $contents=$contents."\n"."$gip_location/libexec/osg-info-gums-status-probe $vdt_location\n";
1692     }
1693     if ($batch =~ /^pbs$/i) {
1694         $contents=$contents."\n"."$gip_location/libexec/osg-info-provider-pbs.py\n";
1695         $contents=$contents."\n"."$gip_location/libexec/osg_info_cesebind.py\n";
1696     }
1697     if ($dynamic_dcache == 1) {
1698         $contents = $contents."\n$gip_location/libexec/services_info_provider.py\n";
1699         $contents = $contents."\n$gip_location/libexec/token_info_provider.py\n";
1700     }
1701
1702     $contents = $contents."\nif [ -f \"$gip_location/etc/add-attributes.conf\" ]; then\n    cat $gip_location/etc/add-attributes.conf\nfi\n";
1703
1704         #We remove the existing wrapper file because it will cause duplication of information
1705     system("rm -f $wrapper_file");
1706     safe_write($wrapper_file, $contents);
1707     system("chmod +x $wrapper_file");
1708     vdt_install_log("===== BEGIN osg-info-wrapper =====\n");
1709     vdt_install_log($contents);
1710     vdt_install_log("===== END osg-info-wrapper =====\n");
1711
1712     #Create plugin wrappers here
1713
1714     $wrapper_file = "$gip_location/plugins/osg-info-dynamic-plugins";
1715
1716     # Create appropriate lcg-info-dynamic-ce-plugin wrapper script in plugin dir
1717     my $ldif_file = "$gip_location/var/ldif/osg-info-static-ce.ldif";
1718     $contents = '#!/bin/sh'."\n";
1719     if ($batch =~ /^condor$/i) {
1720         # The condor script is different--it requires the path to the binaries as an argument.
1721         $contents = $contents."$gip_location/libexec/osg-info-dynamic-condor $condor_bin_location $ldif_file \n";
1722     }
1723     elsif ($batch =~ /^lsf$/i) {
1724         # The lsf script is also different--it requires the path to the binaries as an argument.
1725         $contents = $contents."$gip_location/libexec/osg-info-dynamic-lsf $lsf_bin_location $ldif_file \n";
1726     }
1727     elsif ($batch =~ /pbs/i) {
1728         # The pbs script is also different--it requires the path to the binaries as an argument.
1729         # $contents = $contents."$gip_location/libexec/osg-info-dynamic-pbs.py \n";
1730     }
1731     else {
1732         $contents = $contents."$gip_location/libexec/osg-info-dynamic-$batch $ldif_file \n";
1733     }
1734
1735     # Create appropriate lcg-info-dynamic-software-plugin wrapper script in plugin dir. Not used by osg uses osg-info-dynamic-location plugin and osg-info-software-provider
1736     #$ldif_file = "$gip_location/var/gip/ldif/osg-info-static-cluster.ldif";
1737     #$contents = $contents."\n$gip_location/libexec/osg-info-dynamic-software $ldif_file $gip_location/var/info\n";
1738
1739
1740     # Create appropriate lcg-info-dynamic-location-plugin wrapper script in plugin dir
1741     $ldif_file = "$gip_location/var/ldif/osg-info-static-cluster.ldif";
1742     $contents = $contents."\n$gip_location/libexec/osg-info-dynamic-location $ldif_file $app/etc\n";
1743
1744     # Create appropriate lcg-info-dynamic-se-plugin wrapper script in plugin dir
1745     $ldif_file = "$gip_location/var/ldif/osg-info-static-se.ldif";
1746     if($disk){
1747         $contents = $contents."\n$gip_location/libexec/osg-info-dynamic-classicSE $ldif_file $app/etc\n";
1748     }
1749     # This script has been deprecated (newer versions of dcache have disabled this functionality)
1750     # if($srm){
1751     #     $contents = $contents."\n$gip_location/libexec/osg-info-dynamic-dcache $ldif_file $vdt_location\n";
1752     # }
1753
1754     $contents = $contents."\nif [ -f \"$gip_location/etc/alter-attributes.conf\" ]; then\n    cat $gip_location/etc/alter-attributes.conf\nfi\n";
1755
1756     #We remove the existing wrapper file because it will cause duplication of information
1757     system("rm -f $wrapper_file");
1758
1759     safe_write($wrapper_file, $contents);
1760     system("chmod +x $wrapper_file");
1761     vdt_install_log("===== BEGIN osg-info-dynamic-plugins =====\n");
1762     vdt_install_log($contents);
1763     vdt_install_log("===== END osg-info-dynamic-plugins =====\n");
1764 }
1765
1766 ###########################################################################
1767 #
1768 # Function: create_static_ldif_files
1769 # Purpose:  We create the following static ldif files
1770 #           1. osg-info-static-site.ldif
1771 #           2. osg-info-static-cluster.ldif
1772 #           3. osg-info-static-ce.ldif
1773 #           4. osg-info-static-se.ldif
1774 #           5. osg-info-static-cesebind.ldif
1775 #           6. osg-info-static-service.ldif
1776 #
1777 ###########################################################################
1778 sub create_static_ldif_files
1779 {
1780
1781     my $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-site.conf -t $gip_location/templates/compat/GlueSite.template`;
1782
1783     safe_write("$gip_location/var/ldif/osg-info-static-site.ldif", $contents);
1784
1785     vdt_install_log("===== BEGIN osg-info-static-site.ldif =====\n");
1786     vdt_install_log($contents);
1787     vdt_install_log("===== END osg-info-static-site.ldif =====\n");
1788
1789     $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-cluster.conf -t $gip_location/templates/compat/GlueCluster.template`;
1790
1791     safe_write("$gip_location/var/ldif/osg-info-static-cluster.ldif", $contents);
1792
1793     vdt_install_log("===== BEGIN osg-info-static-cluster.ldif =====\n");
1794     vdt_install_log($contents);
1795     vdt_install_log("===== END osg-info-static-cluster.ldif =====\n");
1796
1797     $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-ce.conf -t $gip_location/templates/compat/GlueCE.template`;
1798
1799     safe_write("$gip_location/var/ldif/osg-info-static-ce.ldif", $contents);
1800
1801     vdt_install_log("===== BEGIN osg-info-static-ce.ldif =====\n");
1802     vdt_install_log($contents);
1803     vdt_install_log("===== END osg-info-static-ce.ldif =====\n");
1804
1805     $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-se.conf -t $gip_location/templates/compat/GlueSE.template`;
1806
1807     safe_write("$gip_location/var/ldif/osg-info-static-se.ldif", $contents);
1808
1809     vdt_install_log("===== BEGIN osg-info-static-se.ldif =====\n");
1810     vdt_install_log($contents);
1811     vdt_install_log("===== END osg-info-static-se.ldif =====\n");
1812
1813     $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-cesebind.conf -t $gip_location/templates/compat/GlueCESEBind.template`;
1814
1815     safe_write("$gip_location/var/ldif/osg-info-static-cesebind.ldif", $contents);
1816
1817     vdt_install_log("===== BEGIN osg-info-static-cesebind.ldif =====\n");
1818     vdt_install_log($contents);
1819     vdt_install_log("===== END osg-info-static-cesebind.ldif =====\n");
1820
1821     $contents = `$gip_location/libexec/gip-static-create -c $gip_location/etc/osg-info-gip-config/osg-info-static-service.conf -t $gip_location/templates/compat/GlueService.template`;
1822
1823     safe_write("$gip_location/var/ldif/osg-info-static-service.ldif", $contents);
1824
1825     vdt_install_log("===== BEGIN osg-info-static-service.ldif =====\n");
1826     vdt_install_log($contents);
1827     vdt_install_log("===== END osg-info-static-service.ldif =====\n");
1828
1829 }
1830
1831 ###########################################################################
1832 #
1833 # Function: setup_cemon
1834 # Purpose:  Links CEmonitor with the GIP
1835 #
1836 ###########################################################################
1837 sub setup_cemon
1838 {
1839    ##
1840    ## Check to make sure CEMon is installed
1841    ##
1842       return unless(-d "${vdt_location}/glite/etc/glite-ce-ce-plugin");
1843
1844    ##
1845    ## Create our plugin script
1846    ##
1847    my $glite_plugin = "${vdt_location}/glite/etc/glite-ce-ce-plugin/glite-ce-info";
1848    my $contents = "#!/bin/sh\n".
1849                   "${vdt_location}/gip/libexec/osg-info-wrapper";
1850    safe_write($glite_plugin, $contents);
1851    system("chmod 0755 $glite_plugin");
1852 }
1853
1854
Note: See TracBrowser for help on using the browser.