root/gip/branches/original/vdt/setup/configure_gip

Revision 1763, 81.5 kB (checked in by burt, 2 years ago)

Reverting the GlueForeignKey?=GlueSiteUniqueID change

  • 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/lcg/var/gip/lcg-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/lcg/var/gip/lcg-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/lcg/sbin/lcg-info-generic-config $VDT_LOCATION/lcg/var/gip/lcg-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 "GenericInformationProvider";
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 $lcg_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 $vo;
110 my @vo_list;
111 my %vo_access_roots; ############
112 my $se_data;
113 my $disk=1;
114 my $srm=0;
115 my $dynamic_dcache=0;
116 my $gums=1;
117 my %se_access;
118 my $sa_path;
119 my $se_host='srmhost';
120 my $se_name; ##########
121 my $se_version;
122 my $se_control_version = "UNDEFINED";
123 my $service_contents = '';
124 my $fullhost;
125 my %user_vo_map;
126 my %pbsQueues;
127 my @lsfQueues;
128 my $have_warnings = 0;
129 my $se_disk;
130 my $simplified_srm;
131 my $simplified_srm_path;
132 my $testbed;
133 my $bdii_hostname;
134 my $bdii_port = 2170;
135 my $bdii_base = 'mds-vo-name=local,o=grid';
136 my $bdii_contact;
137 my %scinfo;
138
139 parse_command_line();
140 initialize();
141
142 # The -install flag is undocumented and is only used
143 # during the installation process. It dumps a bit of information
144 # into the post-install/README file.
145 if ($install) {
146     installation_remarks();
147     exit(0);
148 }
149 if (defined $ENV{GLOBUS_HOSTNAME} && $ENV{GLOBUS_HOSTNAME} ne "") {
150     $fullhost = $ENV{GLOBUS_HOSTNAME};
151 } else {
152     $fullhost = get_hostname();
153 }
154 read_osg_attributes_info();
155 create_directories();
156 if ($batch =~ /pbs/i) {
157     fix_for_pbs_queues();
158 } elsif ($batch =~/lsf/i) {
159     fix_for_lsf_queues();
160 }
161 create_config_file();
162 edit_slapd_conf();
163 edit_resource_ldif_conf();
164 edit_resource_register_conf();
165
166 # CEMonitor Configuration
167 # This will check to see if CEMon is even installed
168 setup_cemon();
169
170 describe_postinstall();
171 #system("$lcg_location/sbin/lcg-info-generic-config $lcg_location/var/gip/lcg-info-generic.conf");
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     $lcg_location = $vdt_location . "/lcg";
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 LCG location is $lcg_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 $lcg_location\n";
233     stat($lcg_location) or die "Error can't access $lcg_location\n";
234
235     my $tmp_testbed = `$vdt_location/osg-version`;
236     if ($tmp_testbed =~ /^OSG-ITB-\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 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_SE_VERSION; echo \$OSG_GIP_DYNAMIC_DCACHE; echo \$OSG_GIP_SE_CONTROL_VERSION`;
399         my @outList = split /\n/, $output;
400         $batch   = &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         $dynamic_dcache = &remove_quotes($outList[13]);
413         $se_control_version = &remove_quotes($outList[14]);
414         $scinfo{sc_number}=`. $gip_conf; echo \$OSG_GIP_SC_NUMBER;`;
415                   for(my $i=1; $i<=$scinfo{sc_number};$i++) {
416             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`;
417                
418             ($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]};`;
419
420             foreach my $val (keys %{$scinfo{$i}}) {
421                      chomp($scinfo{$i}{$val});
422             }
423         }
424         #open(OSGATTR, "$vdt_location/monitoring/gip-attributes.conf");
425         #my $valid_variable_chars = 'A-Za-z0-9_.-';
426         #my $variable_name;
427         #my $variable_value;
428         #my %variable_hash = ();
429         #while (<OSGATTR>) {
430         #       my $attrline = $_;
431         #       if ($attrline =~ /^#/ || $attrline =~ /^\s*$/ || $attrline =~ /^export /) {
432                         # ignore comments and blank and export lines
433         #               next;
434         #       } elsif ($attrline =~ /([$valid_variable_chars]+)=(.*)$/) {
435         #               $variable_hash{$1} = &remove_quotes($2);
436         #       } else {
437         #               print "Ransom: Add test case $attrline\n"; # shouldn't get here
438         #       }
439         #}
440         #close(OSGATTR);
441         #$batch   = $variable_hash{'OSG_GIP_BATCH'};
442         #$srm     = $variable_hash{'OSG_GIP_SRM'};
443         #$disk    = $variable_hash{'OSG_GIP_DISK'};
444         #$se_name = $variable_hash{'OSG_GIP_SE_NAME'};
445         #$se_host = $variable_hash{'OSG_GIP_SE_HOST'};
446         #$sa_path = $variable_hash{'OSG_GIP_SA_PATH'};
447         #$se_disk = $variable_hash{'OSG_GIP_SE_DISK'};
448         #$se_data = $variable_hash{'OSG_GIP_DATA'};
449         #$gums = $variable_hash{'OSG_GIP_GUMS'};
450         #$simplified_srm = $variable_hash{'OSG_GIP_SIMPLIFIED_SRM'};
451         #$simplified_srm_path = $variable_hash{'OSG_GIP_SIMPLIFIED_SRM_PATH'};
452
453         if ($srm) {
454             if ($simplified_srm eq "y") {
455                     foreach $vo (@vo_list) {
456                             $vo_access_roots{$vo} = $simplified_srm_path;
457                     }
458             } else {
459    
460                 my $vo_dir_var;
461                 my $vo_path;
462                 my $vo_path_conf_str = `cat $gip_conf | grep ^OSG_GIP_VO_DIR`;
463
464                 foreach $vo (@vo_list){
465                    
466                     #$vo_dir_var = "OSG_GIP_VO_".$vo."_DIR";
467    
468                     # insensitive since osg-gip-configure.sh doesn't do conversion
469                     #if ($vo_path_conf_str =~ m/$vo_dir_var.*="(.*)"\n/i){
470                     if ($vo_path_conf_str =~ m/OSG_GIP_VO_DIR\[\d+\]="$vo,(.*)"/i){
471                         $vo_path = $1;
472                         chomp($vo_path);
473                         $vo_access_roots{$vo} = $vo_path;
474                     } else {
475                         print "WARNING - configure_gip: SRM Path for $vo has not been set, rerun configure-osg-gip.sh\n";
476                     }
477                 }
478             }
479         }
480
481     } else {
482         $batch   = "condor";
483         $srm     = 0;
484         $disk    = 1;
485         $se_name = "UNDEFINED";
486         $se_host = "UNDEFINED";
487         $sa_path = "UNDEFINED";
488         $se_disk = $default_se;
489         $se_data = "UNDEFINED";
490         $gums    = 1;
491
492         foreach $vo (@vo_list){
493                 $vo_access_roots{$vo} = "UNDEFINED";
494         }
495
496         print wrap("", "", "WARNING: Could not locate $gip_conf.\n");
497         $have_warnings=1;
498         }
499
500
501     # We figure out what Condor is being used by this installation,
502     # if the person wants Condor.
503     if ($batch =~ /condor/i) {
504         if($condor_bin_location == "") {
505             my $condor_setup = "$vdt_location/vdt/etc/condor-env.sh";
506             if (-e $condor_setup) {
507                 # We've installed Condor, which installed the Condor
508                 # environment setup file. This points to either the
509                 # VDT Condor, or the pre-existing Condor indicated by
510                 # the user. We parse this file to figure out the Condor
511                 # bin path
512                 my $contents = slurp($condor_setup);
513                 if ($contents =~ /^CONDOR_LOCATION=(.+)$/m) {
514                     $condor_bin_location = $1;
515                     $condor_bin_location .= "/bin";
516                 }
517             }
518             if ($condor_bin_location eq "") {
519                 open WHICH, "which condor_q 2>/dev/null |";
520                 $tmp = <WHICH>;
521                 chomp($tmp);
522                 $condor_bin_location = substr("$tmp",0,length($tmp)-9);
523             }
524
525             if ($condor_bin_location eq "") {
526                 $condor_bin_location = "$vdt_location/condor/bin";
527             }
528             stat($condor_bin_location) or die "Can't find Condor location.\n";
529         }
530     }
531     # Locate lsf binaries
532     if ($batch =~ /lsf/i) {
533          if ($lsf_bin_location eq "") {
534             open WHICH, "which lsid 2>/dev/null |";
535             $lsf_bin_location = <WHICH>;
536             chomp($lsf_bin_location);
537             $lsf_bin_location = substr("$lsf_bin_location",0,length($lsf_bin_location)-5);
538         }
539         stat($lsf_bin_location) or die "Can't find lsid location, make sure that lsf binaries are in path.\n";
540
541     }
542     # Locate pbs binaries
543     if ($batch =~ /pbs/i) {
544          if ($pbs_qstat eq "") {
545             open WHICH, "which qstat 2>/dev/null |";
546             $pbs_qstat = <WHICH>;
547             chomp($pbs_qstat);
548             $pbs_bin_location = substr("$pbs_qstat",0,length($pbs_qstat)-6);
549         }
550         stat($pbs_qstat) or die "Can't find PBS-qstat location, make sure that qstat is in path.\n";
551     }
552
553     $bdii_contact = "ldap://$bdii_hostname:$bdii_port/mds-vo-name=$osg_site_name,$bdii_base";
554
555     return;
556 }
557
558
559 ###########################################################################
560 #
561 # Function: installation_remarks
562 # Purpose:  It's installation time. Let people know what they should do
563 #           later.
564 #
565 ###########################################################################
566 sub installation_remarks
567 {
568     post_install_log("The Generic Information Provider (GIP) has been installed but not configured.  If you" .
569                      "wish to use it then you should run $vdt_location/vdt/setup/configure_gip. If" .
570                      "you are installing as part of the OSG software stack, the configure_osg.sh program will" .
571                      "do this on your behalf.\n\n");
572 }
573
574 ###########################################################################
575 #
576 # Function: create_directories
577 # Purpose:  Create GIP directories.
578 #
579 ###########################################################################
580 sub create_directories()
581 {
582     my $tmp_dir = "$lcg_location/var/gip/tmp";
583     if (!-d $tmp_dir) {
584         # This will probably create both gip and tmp.
585         vdt_install_log("Creating temporary directory for GIP: $tmp_dir");
586         system("mkdir -p $lcg_location/var/gip/tmp");
587     }
588     if ($< == 0) {
589         system("chown daemon $lcg_location/var/gip/tmp");
590     }
591
592     my $plugin_dir  = "$lcg_location/var/gip/plugin";
593     if (!-d $plugin_dir) {
594         # This will probably create plugin.
595         vdt_install_log("Creating plugin directory for GIP: $plugin_dir");
596         system("mkdir -p $plugin_dir");
597     }
598
599     my $provider_dir  = "$lcg_location/var/gip/provider";
600     if (!-d $provider_dir) {
601         vdt_install_log("Creating provider directory for GIP: $provider_dir");
602         system("mkdir -p $provider_dir");
603     }
604
605     my $ldif_dir  = "$lcg_location/var/gip/ldif";
606     if (!-d $ldif_dir) {
607         vdt_install_log("Creating static ldif directory for GIP: $ldif_dir");
608         system("mkdir -p $ldif_dir");
609     }else{
610         #Clear the existing ldif files - otherwise the information will be duiplicated
611         vdt_install_log("Clear the existing files in $ldif_dir otherwise the information will be duiplicated");
612         system("rm -rf $ldif_dir/*");
613     }
614
615     if (!-d "$lcg_location/share/doc/osg-info-gip-config"){
616         vdt_install_log("Creating directory for GIP: $lcg_location/share/doc/osg-info-gip-config");
617         system("mkdir -p $lcg_location/share/doc/osg-info-gip-config");
618     }
619
620     foreach $vo (@vo_list){
621         vdt_install_log("Creating directory for GIP: $lcg_location/var/info/$vo");
622         `mkdir -p $lcg_location/var/info/$vo`;
623         vdt_install_log("Creating file for GIP: $lcg_location/var/info/$vo/$vo.list");
624         `touch -a $lcg_location/var/info/$vo/$vo.list`;
625     }
626
627     return;
628 }
629
630
631 ###########################################################################
632 #
633 # Function: create_site_config_file
634 # Purpose:  We create the static conf file lcg-info-static-site.conf
635 #
636 ###########################################################################
637 sub create_site_config_file
638 {
639     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-site.conf";
640     my $contents ="";
641
642    $contents = $contents."dn: GlueSiteUniqueID=$fullhost\n"
643                         ."GlueSiteName: $osg_site_name\n"
644                         ."GlueSiteDescription: OSG Site\n"
645                         ."GlueSiteUserSupportContact: mailto: $ml_contact_email\n"
646                         ."GlueSiteSysAdminContact: mailto: $ml_contact_email\n"
647                         ."GlueSiteSecurityContact: mailto: $ml_contact_email\n"
648                         ."GlueSiteEmailContact: mailto: $ml_contact_email\n"
649                         ."GlueSiteLocation: $ml_city , $ml_country\n"
650                         ."GlueSiteLatitude: $ml_lat\n"
651                         ."GlueSiteLongitude: $ml_long\n"
652                         ."GlueSiteSponsor: $osg_sponsor\n"
653                         ."GlueSiteOtherInfo: UNDEFINED\n"
654                         ."GlueForeignKey: GlueSiteUniqueID=$fullhost\n"
655                         ."GlueSiteWeb: $osg_site_policy\n";
656
657     safe_write($config_file, $contents);
658
659     vdt_install_log("===== BEGIN osg-info-static-site.conf =====\n");
660     vdt_install_log($contents);
661     vdt_install_log("===== END osg-info-static-site.conf =====\n");
662
663     return;
664 }
665 ###########################################################################
666 #
667 # Function: add_to_pbs_queues
668 # Purpose:  Helper function for fix_for_pbs_queues
669 #
670 ###########################################################################
671 sub add_to_pbs_queues
672 {
673     my ($gp_ptr,$tmp_ptr,$is_user_list) = @_;
674     my $tmp_grep;
675     my $is_vo;
676     my $tmp_vo;
677
678     for my $gp (@$gp_ptr){
679        $tmp_vo=$gp;
680        if($is_user_list==1){
681           if (defined $user_vo_map{$gp}){
682              $tmp_vo= $user_vo_map{$gp};
683           }else{
684              next;
685           }
686        }
687        $is_vo = grep {m/^$tmp_vo$/} @vo_list;
688        if ($is_vo!=0) {
689           $tmp_grep = grep {m/^$tmp_vo$/} @$tmp_ptr;
690           if($tmp_grep == 0){
691              push  @$tmp_ptr, $tmp_vo;
692           }
693        }else{ #Special case for usatlas and uscms (since they may match with atlas and cms)
694           my($tmp) = $tmp_vo =~ /(?:us)?([a-zA-Z_]+)\d*/;
695           $is_vo = grep {m/^$tmp$/} @vo_list;
696           if ($is_vo!=0) {
697              $tmp_grep = grep {m/^$gp$/} @$tmp_ptr;
698              if($tmp_grep == 0){
699                 push  @$tmp_ptr, $gp;
700              }
701           }
702        }
703     }
704 }
705
706 ###########################################################################
707 #
708 # Function: fix_for_pbs_queues
709 # Purpose:  Here we create groups for each queue in pbs rather than each VO.
710 #           We track that VOs that are allowed to submit the job to queue
711 #
712 ###########################################################################
713
714 sub fix_for_pbs_queues{
715     my $queue;
716     my $group_enable = 0;
717     my $user_enable = 0;
718     my $host_enable = 0;
719     my @pbs_users;
720     my @pbs_groups;
721     my @pbs_hosts;
722     my $use_queue=0;
723     my $lastline=''; # added to fix multi-line acl_{users,groups,hosts}
724
725 #    open QSTAT, "$pbs_qstat -Q -f 2>&1 |" or die "Error running qstat ---.\n" ;
726     my @qstat_dump=`$pbs_qstat -Q -f 2>&1`or die "Error running qstat ---.\n" ;
727     my $line_num;
728     my $qstat_len=$#qstat_dump;
729
730     for($line_num=0;$line_num<=$qstat_len;$line_num++){
731         if($line_num<$qstat_len){
732             $_=$qstat_dump[$line_num];
733         }else{
734             $_='';
735         }
736         if(m/Queue:\s*(\S+)\s*/ || $line_num==$qstat_len){
737             # Condense and remove undef and make sure it works
738             # inititate variables at beginning of Queue (empty array and strings)
739             my $tmp_queue=$1;
740             my @tmp_groups;
741             if($use_queue==1) {
742                if($host_enable==1){
743                    my $is_valid_host = grep {m/^\s*$fullhost\s*$/} @pbs_hosts;
744                    if ($is_valid_host==0){
745                        my ($tmp_name,$tmp_aliases,$tmp_addrtype,$tmp_length,@address) = gethostbyname($fullhost);
746                        my ($tmpa,$tmpb,$tmpc,$tmpd) = unpack('C4',$address[0]);
747                        my $ip = "$tmpa.$tmpb.$tmpc.$tmpd";
748                        $is_valid_host = grep {m/^$ip$/} @pbs_hosts;
749                        if ($is_valid_host==0){
750                            $use_queue=0;
751                        }
752                    }
753                }
754                if($use_queue==1) {
755                   if($group_enable==1){
756                       add_to_pbs_queues(\@pbs_groups,\@tmp_groups,0);
757                   }
758                   if($user_enable==1){
759                       add_to_pbs_queues(\@pbs_users,\@tmp_groups,1);
760                   }
761                   if($user_enable==0 && $group_enable==0){
762                       @tmp_groups=@vo_list;
763                   }
764                   if($#tmp_groups>=0){
765                       @{$pbsQueues{$queue}}=@tmp_groups;
766                   }
767                }
768             }
769             undef @pbs_groups;
770             undef @pbs_users;
771             undef @pbs_hosts;
772             undef @tmp_groups;
773             undef $queue;
774             $lastline='';
775             $host_enable=0;
776             $group_enable = 0;
777             $user_enable = 0;
778             $use_queue=0;
779             $queue = $tmp_queue;
780         }
781         elsif(m/queue_type\s*=\s*(\S+)\s*/){
782             my $queue_type = $1;
783             if($queue_type eq "Execution"){
784                 $use_queue=1;
785             }else{
786                 $use_queue=0;
787             }
788         }
789         elsif(m/\s*acl_host_enable\s*=\s*True\s*/i){
790             $host_enable=1;
791         }
792         elsif(m/\s*acl_group_enable\s*=\s*True\s*/i){
793             $group_enable=1;
794         }
795         elsif(m/\s*acl_user_enable\s*=\s*True\s*/i){
796             $user_enable=1;
797         }
798         elsif(m/\s*acl_groups\s*=\s*(.+)\s*/i){
799             @pbs_groups = split /,/, $1;
800             $lastline='groups';
801         }
802         elsif(m/\s*acl_users\s*=\s*(.+)\s*/i){
803             @pbs_users = split /,/, $1;
804             $lastline='users';
805         }
806         elsif(m/\s*acl_hosts\s*=\s*(.+)\s*/i){
807             @pbs_hosts = split /,/, $1;
808             $lastline='hosts';
809         }
810         elsif($lastline ne '') { # line did not match anything else so double-check its not a multi-line wrap
811             if(!(m/\s*=\s*/i)) { # if its not a attr = value statement, then it should be a multi-line wrap
812                my @tmparr=split /,/, $_;
813                push(@pbs_users,@tmparr)  if $lastline=='users';
814                push(@pbs_groups,@tmparr) if $lastline=='groups';
815                push(@pbs_hosts,@tmparr)  if $lastline=='hosts';
816             }else{ #obviously not a multi-line wrap because we already ran into a attr = value statement
817                $lastline='';
818             }
819         }
820
821     }
822    
823
824 }
825 ###########################################################################
826 #
827 # Function: fix_for_lsf_queues
828 # Purpose:  Here we create groups for each queue in pbs rather than each VO.
829 #           We track that VOs that are allowed to submit the job to queue
830 #
831 ###########################################################################
832 sub fix_for_lsf_queues(){
833 my @bqueues;
834
835 @bqueues=`bqueues -w | awk '{print \$1}'`;
836 foreach my $item (@bqueues) {
837    chomp($item);
838    if($item ne 'QUEUE_NAME' and $item ne '') {
839       push(@lsfQueues,$item);
840    }
841 }
842
843 }
844
845
846
847 ###########################################################################
848 #
849 # Function: get_os_release
850 # Purpose:  Get the current OS release
851 #
852 ###########################################################################
853 sub get_os_release(){
854 my $arch;
855 my $rel;
856 my $ver;
857
858 $arch=`lsb_release -i 2>/dev/null | cut -f2`;
859 $rel=`lsb_release -r 2>/dev/null | cut -f2`;
860 $ver=`lsb_release -c 2>/dev/null | cut -f2`;
861
862 if(!defined $arch || !$arch){ #If one of the lsb_release doesnot return correct value then all of them should return correct value
863     if (-e "/etc/debian_version"){
864         my $fh = new FileHandle "/etc/debian_version";
865         chomp(my $version = <$fh>);
866         $arch = "linux-debian-$version";
867         $rel = "Debian Linux";
868         $ver=$version;
869     }elsif (-e "/etc/rocks-release"){
870         my $fh = new FileHandle "/etc/rocks-release";
871         chomp(my $version_str = <$fh>);
872         my ($version) = $version_str =~ /(\d+\.\d+)/;
873         $arch = "linux-rocks-$version";
874         $ver = $version;
875         $rel = "Rocks Linux";
876     }elsif (-e "/etc/redhat-release"){
877         my $fh = new FileHandle "/etc/redhat-release";
878         chomp(my $version_str = <$fh>);
879         if ($version_str =~ /Red Hat Linux (?:release )?([\d\.]+)/){
880             $arch = "linux-redhat-$1";
881             $ver = $1;
882             $rel = "RedHat Linux";
883         }elsif ($version_str =~ /Enterprise Linux AS release ([\d\.]+)/){
884             $arch = "linux-rhel-$1";
885             $ver = $1;
886             $rel = "RedHat Enterprise Linux";
887         }elsif ($version_str =~ /Fedora Core release ([\d\.]+)/){
888             $arch = "linux-fedora-$1";
889             $ver = $1;
890             $rel = "Fedora Core"
891         }elsif ($version_str =~ /Scientific Linux Release (\d\.?\d)(?:\.\d|\d) \(Fermi\)/) {
892             my $version = $1;
893             $version =~ s/(\d)(\d)/$1.$2/;
894             $arch = "linux-sl-fermi-$version";
895             $ver = $version;
896             $rel = "Scientific Linux";
897         }elsif ($version_str =~ /Scientific Linux SL release (\d\.?\d) \(\w+\)/){
898             my $version = $1;
899             $rel = $3;
900             $version =~ s/(\d)(\d)/$1.$2/;
901             $arch = "linux-sl-fermi-$version";
902             $ver = $version;
903         }else{
904             $arch="RedHat Generic";
905             $rel="RedHat Unknown";
906             $ver="Unknown";
907         }
908     }elsif (-e "/usr/bin/sw_vers"){
909         chomp(my $version = `/usr/bin/sw_vers -productVersion`);
910         $arch = "darwin-$version";
911         $ver = $version;
912         $rel = "Darwin";
913     }
914 }
915     if(!defined $arch || !$arch){
916         $arch = "linux-Unknown";
917     }
918     if(!defined $ver || !$ver){
919         $ver = "Unknown";
920     }
921      if(!defined $rel || !$rel){
922         $rel = "Linux";
923     }
924 chomp($arch);
925 chomp($ver);
926 chomp($rel);
927 return ("$arch", "$ver", "$rel");
928 }
929 ###########################################################################
930 #
931 # Function: get_cpu_info
932 # Purpose:  Get cpu info from /proc/cpuinfo (DEPRECATED)
933 #
934 ###########################################################################
935 sub get_cpu_info(){
936     my $model="Pentium IV";
937     my $vendor = "Intel";
938     my $line;
939     if (-e "/proc/cpuinfo"){
940         my $file = "/proc/cpuinfo";
941         my $contents = slurp($file);
942         my @lines = split /\n/, $contents;
943         foreach $line (@lines){
944             if($line =~ m/^model\s*name\s*\:\s*(.*)$/){
945                 $model=$1;
946                 chomp($model);
947             }
948             if($line=~ m/^vendor_id\s*\:\s*(.*)$/){
949                 $vendor = $1;
950                 chomp($vendor);
951             }
952         }
953     }
954     return ("$model", "$vendor");
955 }
956 ###########################################################################
957 #
958 # Function: create_cluster_config_file
959 # Purpose:  We create the static conf file osg-info-static-cluster.conf
960 #
961 ###########################################################################
962 sub create_cluster_config_file
963 {
964     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-cluster.conf";
965     my $contents    = "";
966     $contents = $contents."\ndn: GlueClusterUniqueID=$fullhost\n"
967              ."GlueClusterName: $fullhost\n"
968              ."GlueClusterService: $fullhost\n"
969              ."GlueClusterTmpDir: $data\n"
970              ."GlueClusterWNTmpDir: $wn_tmp\n";
971
972     if ($batch =~ /^pbs$/i) {
973         foreach my $queue (keys %pbsQueues){
974             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
975         }
976     } elsif ($batch =~/lsf/i) {
977         foreach my $queue (@lsfQueues){
978             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
979         }
980     }else{
981         foreach $vo (@vo_list){
982             $contents = $contents."GlueForeignKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
983         }
984     }
985     $contents = $contents."GlueForeignKey: GlueSiteUniqueID=$fullhost\n";
986     $contents = $contents."GlueInformationServiceURL: $bdii_contact\n";
987
988
989     #Change the OSG Version
990     my $osg_ver = `$vdt_location/osg-version`;
991     chomp($osg_ver);
992     my @os = &get_os_release();
993     #my @cpu = &get_cpu_info();
994
995     for(my $sc_count=1;$sc_count<=$scinfo{sc_number};$sc_count++) {
996         my $pcpus=$scinfo{$sc_count}{scnumpcpus}*$scinfo{$sc_count}{scnodes};
997         my $lcpus=$scinfo{$sc_count}{scnumlcpus}*$scinfo{$sc_count}{scnodes};
998         $contents = $contents."\ndn: GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
999                  ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n"
1000                  ."GlueSubClusterName: $scinfo{$sc_count}{scname}\n"
1001                  ."GlueHostApplicationSoftwareRunTimeEnvironment: $osg_ver\n"
1002                  ."GlueHostArchitectureSMPSize: $scinfo{$sc_count}{scnumpcpus}\n"
1003                  ."GlueHostBenchmarkSF00: 380\n"
1004                  ."GlueHostBenchmarkSI00: 400\n"
1005                  ."GlueHostMainMemoryRAMSize: $scinfo{$sc_count}{scramsize}\n"
1006                  ."GlueHostMainMemoryVirtualSize: $scinfo{$sc_count}{scramsize}\n"
1007                  ."GlueHostNetworkAdapterInboundIP: $scinfo{$sc_count}{scinbound}\n"
1008                  ."GlueHostNetworkAdapterOutboundIP: $scinfo{$sc_count}{scoutbound}\n"
1009                  ."GlueHostOperatingSystemName: $os[0]\n"
1010                  ."GlueHostOperatingSystemRelease: $os[2]\n"
1011                  ."GlueHostOperatingSystemVersion: $os[1]\n"
1012                  ."GlueHostProcessorClockSpeed: $scinfo{$sc_count}{scclock}\n"
1013                  ."GlueHostProcessorModel: $scinfo{$sc_count}{scmodel}\n"
1014                  ."GlueHostProcessorVendor: $scinfo{$sc_count}{scvendor}\n"
1015                  ."GlueSubClusterPhysicalCPUs: $pcpus\n"
1016                  ."GlueSubClusterLogicalCPUs: $lcpus\n"
1017                  ."GlueSubClusterTmpDir: $data\n"
1018                  ."GlueSubClusterWNTmpDir: $wn_tmp\n"
1019                  ."GlueInformationServiceURL: $bdii_contact";
1020
1021
1022         # Add local stograge requirement information
1023         $contents = $contents."\ndn: GlueLocationLocalID=OSG_SITE_READ, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1024                              ."GlueLocationName: OSG_SITE_READ\n"
1025                              ."GlueLocationVersion: UNDEFINED\n"
1026                              ."GlueLocationPath: $site_read\n"
1027                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1028    
1029         $contents = $contents."\ndn: GlueLocationLocalID=OSG_SITE_WRITE, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1030                              ."GlueLocationName: OSG_SITE_WRITE\n"
1031                              ."GlueLocationVersion: UNDEFINED\n"
1032                              ."GlueLocationPath: $site_write\n"
1033                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1034
1035         $contents = $contents."\ndn: GlueLocationLocalID=OSG_GRID, GlueSubClusterUniqueID=$scinfo{$sc_count}{scname}, GlueClusterUniqueID=$fullhost\n"
1036                              ."GlueLocationName: OSG_GRID\n"
1037                              ."GlueLocationVersion: UNDEFINED\n"
1038                              ."GlueLocationPath: $osg_grid\n"
1039                              ."GlueChunkKey: GlueClusterUniqueID=$fullhost\n";
1040     }
1041     safe_write($config_file, $contents);
1042
1043     vdt_install_log("===== BEGIN osg-info-static-cluster.conf =====\n");
1044     vdt_install_log($contents);
1045     vdt_install_log("===== END osg-info-static-cluster.conf =====\n");
1046
1047     return;
1048 }
1049
1050 ###########################################################################
1051 #
1052 # Function: create_ce_config_file
1053 # Purpose:  We create the static conf file osg-info-static-ce.conf
1054 #
1055 ###########################################################################
1056 sub create_ce_config_file
1057 {
1058
1059     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-ce.conf";
1060     my $contents    = "";
1061
1062     $contents = $contents."\nGlueCEHostingCluster: $fullhost\n"
1063                          ."GlueCEInfoGatekeeperPort: 2119\n"
1064                          ."GlueCEInfoHostName: $fullhost\n"
1065                          ."GlueCEInfoLRMSType: $batch\n"
1066                          ."GlueCEInfoLRMSVersion: not defined\n"
1067                          ."GlueCEInfoTotalCPUs: 0\n"
1068                          ."GlueCEPolicyMaxCPUTime: 6000\n"
1069                          ."GlueCEPolicyMaxRunningJobs: 0\n"
1070                          ."GlueCEPolicyMaxTotalJobs: 0\n"
1071                          ."GlueCEPolicyMaxWallClockTime: 6000\n"
1072                          ."GlueCEPolicyPriority: 1\n"
1073                          ."GlueCEPolicyMaxObtainableWallClockTime: 0\n"
1074                          ."GlueCEPolicyMaxObtainableCPUTime: 0\n"
1075                          ."GlueCEPolicyMaxWaitingJobs: 0\n"
1076                          ."GlueCEPolicyMaxSlotsPerJob: 0\n"
1077                          ."GlueCEPolicyPreemption: 0\n"
1078                          ."GlueCEStateEstimatedResponseTime: 14400\n"
1079                          ."GlueCEStateFreeCPUs: 0\n"
1080                          ."GlueCEStateRunningJobs: 0\n"
1081                          ."GlueCEStateStatus: Production\n"
1082                          ."GlueCEStateTotalJobs: 0\n"
1083                          ."GlueCEStateWaitingJobs: 0\n"
1084                          ."GlueCEStateWorstResponseTime: 0\n"
1085                          ."GlueCEInfoJobManager: $batch\n"
1086                          ."GlueCEStateFreeJobSlots: 0\n"
1087                          ."GlueInformationServiceURL: $bdii_contact\n"
1088                          ."GlueCEPolicyAssignedJobSlots: 0\n"
1089                          ."GlueCEImplementationName: UNDEFINED\n"
1090                          ."GlueCEImplementationVersion: UNDEFINED\n"
1091                          ."GlueCECapability: UNDEFINED\n";
1092
1093     if ($batch =~ /^pbs$/i) {
1094         foreach my $queue (keys %pbsQueues){
1095             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1096                                  ."GlueCEName: $queue\n"
1097                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1098                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$queue\n"
1099                                  ."GlueCEInfoApplicationDir:  $app\n"
1100                                  ."GlueCEInfoDataDir: $data\n";
1101             foreach $vo (@{$pbsQueues{$queue}}){
1102                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1103             }
1104
1105             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1106                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1107             } else {
1108                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1109             }
1110         }
1111     }
1112     elsif ($batch =~ /^lsf$/i) {
1113         foreach my $queue (@lsfQueues){
1114             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1115                                  ."GlueCEName: $queue\n"
1116                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1117                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$queue\n"
1118                                  ."GlueCEInfoApplicationDir:  $app\n"
1119                                  ."GlueCEInfoDataDir: $data\n";
1120             foreach $vo (@vo_list){
1121                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1122             }
1123
1124             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1125                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1126             } else {
1127                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1128             }
1129         }
1130     }
1131     else{
1132         foreach $vo (@vo_list){
1133             $contents = $contents."\ndn: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1134                                  ."GlueCEName: $vo\n"
1135                                  ."GlueForeignKey: GlueClusterUniqueID=$fullhost\n"
1136                                  ."GlueCEAccessControlBaseRule: VO:$vo\n"
1137                                  ."GlueCEInfoContactString: $fullhost:2119/jobmanager-$batch-$vo\n"
1138                                  ."GlueCEInfoApplicationDir:  $app\n"
1139                                  ."GlueCEInfoDataDir: $data\n";
1140
1141             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1142                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1143             } else {
1144                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1145             }
1146         }
1147     }
1148
1149     if ($batch =~ /^pbs$/i) {
1150         foreach my $queue (keys %pbsQueues){
1151
1152             foreach $vo (@{$pbsQueues{$queue}}){
1153                 $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1154                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1155            
1156                 if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1157                     $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1158                 } else {
1159                     $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1160                 }
1161
1162                 $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1163                                      ."GlueCEInfoDataDir: $data\n"
1164                                      ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1165             }
1166         }
1167     } elsif ($batch =~ /^lsf$/i) {
1168         foreach my $queue (@lsfQueues){
1169             foreach $vo (@vo_list){
1170                 $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1171                 $contents = $contents."GlueCEAccessControlBaseRule: VO:$vo\n";
1172            
1173                 if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1174                     $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1175                 } else {
1176                     $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1177                 }
1178
1179                 $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1180                                      ."GlueCEInfoDataDir: $data\n"
1181                                      ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1182             }
1183         }
1184     }else{
1185         foreach $vo (@vo_list){
1186             $contents = $contents."\ndn: GlueVOViewLocalID=$vo,GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1187                                  ."GlueCEAccessControlBaseRule: VO:$vo\n";
1188
1189             if ($default_se =~ /^UNDEFINED$/i || $default_se eq "") {
1190                 $contents = $contents."GlueCEInfoDefaultSE:  $fullhost\n";
1191             } else {
1192                 $contents = $contents."GlueCEInfoDefaultSE: $default_se\n";
1193             }
1194
1195             $contents = $contents."GlueCEInfoApplicationDir:  $app\n"
1196                                  ."GlueCEInfoDataDir: $data\n"
1197                                  ."GlueChunkKey: GlueCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
1198         }
1199     }
1200
1201     safe_write($config_file, $contents);
1202
1203     vdt_install_log("===== BEGIN osg-info-static-ce.conf =====\n");
1204     vdt_install_log($contents);
1205     vdt_install_log("===== END osg-info-static-ce.conf =====\n");
1206
1207     return;
1208 }
1209
1210 ###########################################################################
1211 #
1212 # Function: create_se_config_file
1213 # Purpose:  We create the static conf file osg-info-static-se.conf
1214 #
1215 ###########################################################################
1216 sub create_se_config_file
1217 {
1218
1219     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-se.conf";
1220     my $contents    = "";
1221
1222
1223     # Write SE part of configuration. A site could publish both srm and gsiftp information through GIP simultaneously.
1224     my ($major_ver, $minor_ver) = split(/\./, $se_control_version);
1225     my $se_version=$major_ver;
1226
1227     if ($srm && $dynamic_dcache!=1) {
1228         $contents=$contents."\ndn: GlueSEUniqueID=$se_host\n"
1229                            ."GlueSEName: $se_name:srm_v$se_version\n"
1230                            ."GlueSEType: srm\n"
1231                            ."GlueSEPort: 8443\n"
1232                            ."GlueSESizeTotal: 0\n"
1233                            ."GlueSESizeFree: 0\n"
1234                            ."GlueSEArchitecture: srm\n"
1235                            ."GlueSEImplementationName: UNDEFINED\n"
1236                            ."GlueSEImplementationVersion: UNDEFINED\n"
1237                            ."GlueSEStatus: not tested\n"
1238                            ."GlueSETotalOnlineSize: 0\n"
1239                            ."GlueSEUsedOnlineSize: 0\n"
1240                            ."GlueSETotalNearlineSize: 0\n"
1241                            ."GlueSEUsedNearlineSize: 0\n"
1242                            ."GlueForeignKey: GlueSiteUniqueID=$fullhost\n"
1243                            ."GlueInformationServiceURL: $bdii_contact\n";
1244
1245
1246         $contents=$contents."\ndn: GlueSEAccessProtocolLocalID=gsiftp,GlueSEUniqueID=$se_host\n"
1247                            ."GlueSEAccessProtocolType: gsiftp\n"
1248                            ."GlueSEAccessProtocolPort: 2811\n"
1249                            ."GlueSEAccessProtocolVersion: 1.0.0\n"
1250                            ."GlueSEAccessProtocolSupportedSecurity: gsi\n"
1251                            ."GlueSEAccessProtocolMaxStreams: 1\n"
1252                            ."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1253
1254
1255         if($se_version eq '2') {
1256            $contents=$contents."\ndn: GlueSEControlProtocolLocalID=srm_v2,GlueSEUniqueID=$se_host\n"
1257                               ."GlueSEControlProtocolType: srm\n"
1258                               ."GlueSEControlProtocolEndpoint: httpg://$se_host:8443/srm/managerv2\n"
1259                               ."GlueSEControlProtocolVersion: 2.2.0\n"
1260                               ."GlueSEControlProtocolCapability: control\n"
1261                               ."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1262         }
1263
1264         $contents=$contents."\ndn: GlueSEControlProtocolLocalID=srm_v1,GlueSEUniqueID=$se_host\n"
1265                            ."GlueSEControlProtocolType: srm\n"
1266                            ."GlueSEControlProtocolEndpoint: httpg://$se_host:8443/srm/managerv1\n"
1267                            ."GlueSEControlProtocolVersion: 1.1.0\n"
1268                            ."GlueSEControlProtocolCapability: control\n"
1269                            ."GlueChunkKey: GlueSEUniqueID=$se_host\n\n";
1270
1271
1272
1273         $service_contents="\ndn: GlueServiceUniqueID=httpg://$se_host:8443/srm/managerv$se_version\n"
1274             ."GlueServiceUniqueID: httpg://$se_host:8443/srm/managerv$se_version\n"
1275             ."GlueServiceName: $se_host\n"
1276             ."GlueServiceType: SRM\n"
1277             ."GlueServiceVersion: $se_control_version\n"
1278             ."GlueServiceEndpoint: httpg://$se_host:8443/srm/managerv$se_version\n"
1279             ."GlueServiceURI: httpg://$se_host:8443/srm/managerv$se_version\n"
1280             ."GlueServiceAccessPointURL: httpg://$se_host:8443/srm/managerv$se_version\n"
1281             ."GlueServiceStatus: OK\n"
1282             ."GlueServiceStatusInfo: not tested\n"
1283             ."GlueServiceWSDL: UNDEFINED\n"
1284             ."GlueServiceSemantics: UNDEFINED\n"
1285             ."GlueServiceStartTime: 1970-01-01T00:00:00Z\n"
1286             ."GlueServiceOwner:OSG\n";
1287         foreach $vo (@vo_list) {
1288                                 $service_contents=$service_contents."GlueServiceAccessControlRule: $vo\n";
1289         }
1290         $service_contents=$service_contents."GlueForeignKey: GlueSiteUniqueID=$fullhost\n";
1291         $service_contents=$service_contents."\n";
1292
1293         $contents=$contents."\ndn: GlueSALocalID=$se_host,GlueSEUniqueID=$se_host\n"
1294                            ."GlueSARoot: $sa_path\n"
1295                            ."GlueSAPath: $sa_path\n";
1296         foreach $vo (@vo_list){
1297             $contents=$contents."GlueSAAccessControlBaseRule: $vo\n";
1298         }
1299         $contents=$contents."GlueChunkKey: GlueSEUniqueID=$se_host\n"
1300                            ."GlueSAType: permanent\n"
1301                            ."GlueSAPolicyFileLifeTime: permanent\n"
1302                            ."GlueSAName: $se_host\n"
1303                            ."GlueSATotalOnlineSize: 0\n"
1304                            ."GlueSAUsedOnlineSize: 0\n"
1305                            ."GlueSAFreeOnlineSize: 0\n"
1306                            ."GlueSAReservedOnlineSize: 0\n"
1307                            ."GlueSATotalNearlineSize: 0\n"
1308                            ."GlueSAUsedNearlineSize: 0\n"
1309                            ."GlueSAFreeNearlineSize: 0\n"
1310                            ."GlueSAReservedNearlineSize: 0\n"
1311                            ."GlueSARetentionPolicy: UNDEFINED\n"
1312                            ."GlueSAAccessLatency: 0\n"
1313                            ."GlueSAExpirationMode: UNDEFINED\n"
1314                            ."GlueSACapability: UNDEFINED\n"
1315                            ."GlueSAPolicyMaxFileSize: 10000\n"
1316                            ."GlueSAPolicyMinFileSize: 1\n"
1317                            ."GlueSAPolicyMaxData: 100\n"
1318                            ."GlueSAPolicyMaxNumFiles: 10\n"
1319                            ."GlueSAPolicyMaxPinDuration: 10\n"
1320                            ."GlueSAPolicyQuota: 0\n"
1321                            ."GlueSAStateAvailableSpace: 1\n"
1322                            ."GlueSAStateUsedSpace: 1\n\n";
1323
1324         $contents=$contents."dn: GlueVOInfoLocalID=$se_host,GlueSALocalID=$se_host\n"
1325                            ."GlueChunkKey: GlueSALocalID=$se_host\n"
1326                            ."GlueVOInfoLocalID: $se_host\n"
1327                            ."GlueVOInfoName: $se_host\n"
1328                            ."GlueVOInfoPath: $sa_path\n";
1329         foreach $vo (@vo_list){
1330             $contents=$contents."GlueVOInfoAccessControlBaseRule: $vo\n";
1331         }
1332         $contents=$contents."GlueVOInfoTag: UNAVAILABLE\n\n";
1333
1334
1335         foreach $vo (@vo_list){
1336
1337             my $se_access_root = $vo_access_roots{$vo};
1338             if ($se_access_root!~/^$/) {
1339                 $se_access{$vo} = $se_access_root;
1340                 $contents=$contents."\ndn: GlueSALocalID=$vo,GlueSEUniqueID=$se_host\n"
1341                                    ."GlueSARoot: $vo:$se_access_root\n"
1342                                    ."GlueSAPath: $sa_path\n"
1343                                    ."GlueSAAccessControlBaseRule: $vo\n"
1344                                    ."GlueChunkKey: GlueSEUniqueID=$se_host\n"
1345                                    ."GlueSAType: permanent\n"
1346                                    ."GlueSAPolicyFileLifeTime: permanent\n"
1347                                    ."GlueSAName: $vo\n"
1348                                    ."GlueSATotalOnlineSize: 0\n"
1349                                    ."GlueSAUsedOnlineSize: 0\n"
1350                                    ."GlueSAFreeOnlineSize: 0\n"
1351                                    ."GlueSAReservedOnlineSize: 0\n"
1352                                    ."GlueSATotalNearlineSize: 0\n"
1353                                    ."GlueSAUsedNearlineSize: 0\n"
1354                                    ."GlueSAFreeNearlineSize: 0\n"
1355                                    ."GlueSAReservedNearlineSize: 0\n"
1356                                    ."GlueSARetentionPolicy: UNDEFINED\n"
1357                                    ."GlueSAAccessLatency: 0\n"
1358                                    ."GlueSAExpirationMode: UNDEFINED\n"
1359                                    ."GlueSACapability: UNDEFINED\n"
1360                                    ."GlueSAPolicyMaxFileSize: 10000\n"
1361                                    ."GlueSAPolicyMinFileSize: 1\n"
1362                                    ."GlueSAPolicyMaxData: 100\n"
1363                                    ."GlueSAPolicyMaxNumFiles: 10\n"
1364                                    ."GlueSAPolicyMaxPinDuration: 10\n"
1365                                    ."GlueSAPolicyQuota: 0\n"
1366                                    ."GlueSAStateAvailableSpace: 1\n"
1367                                    ."GlueSAStateUsedSpace: 1\n\n";
1368
1369                 $contents=$contents."dn: GlueVOInfoLocalID=$vo,GlueSALocalID=$vo\n"
1370                                    ."GlueChunkKey: GlueSALocalID=$vo\n"
1371                                    ."GlueVOInfoLocalID: $vo\n"
1372                                    ."GlueVOInfoName: $vo\n"
1373                                    ."GlueVOInfoPath: $se_access_root\n"
1374                                    ."GlueVOInfoAccessControlBaseRule: $vo\n"
1375                                    ."GlueVOInfoTag: UNAVAILABLE\n\n";
1376
1377
1378             }
1379         }
1380
1381     }
1382
1383         my $service_config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-service.conf";
1384         safe_write($service_config_file, $service_contents);
1385         vdt_install_log("===== BEGIN osg-info-static-service.conf =====\n");
1386         vdt_install_log($service_contents);
1387         vdt_install_log("===== END osg-info-static-service.conf =====\n");
1388
1389     if ($disk) {
1390         $contents=$contents."\ndn: GlueSEUniqueID=$se_disk\n"
1391                            ."GlueSEName: $osg_site_name:disk\n"
1392                            ."GlueSEType: disk\n"
1393                            ."GlueSEPort: 2811\n"
1394                            ."GlueSESizeTotal: 0\n"
1395                            ."GlueSESizeFree: 0\n"
1396                            ."GlueSEArchitecture: disk\n"
1397                            ."GlueSEImplementationName: UNDEFINED\n"
1398                            ."GlueSEImplementationVersion: UNDEFINED\n"
1399                            ."GlueSEStatus: not tested\n"
1400                            ."GlueSETotalOnlineSize: 0\n"
1401                            ."GlueSEUsedOnlineSize: 0\n"
1402                            ."GlueSETotalNearlineSize: 0\n"
1403                            ."GlueSEUsedNearlineSize: 0\n"
1404                            ."GlueForeignKey: GlueSiteUniqueID=$fullhost\n"
1405                            ."GlueInformationServiceURL: $bdii_contact\n";
1406
1407
1408
1409         $contents=$contents."\ndn: GlueSEAccessProtocolLocalID=gsiftp,GlueSEUniqueID=$se_disk\n"
1410                            ."GlueSEAccessProtocolType: gsiftp\n"
1411                            ."GlueSEAccessProtocolPort: 2811\n"
1412                            ."GlueSEAccessProtocolVersion: 1.0.0\n"
1413                            ."GlueSEAccessProtocolMaxStreams: 1\n"
1414                            ."GlueSEAccessProtocolSupportedSecurity: gsi\n"
1415                            ."GlueChunkKey: GlueSEUniqueID=$se_disk\n\n";
1416
1417
1418
1419         $contents=$contents."\ndn: GlueSALocalID=$se_disk,GlueSEUniqueID=$se_disk\n"
1420                            ."GlueSARoot: $se_data\n"
1421                            ."GlueSAPath: $se_data\n";
1422         foreach $vo (@vo_list){
1423             $contents=$contents."GlueSAAccessControlBaseRule: $vo\n"
1424         }
1425         $contents=$contents."GlueChunkKey: GlueSEUniqueID=$se_disk\n"
1426                            ."GlueSAType: permanent\n"
1427                            ."GlueSAPolicyFileLifeTime: permanent\n"
1428                            ."GlueSAName: $se_disk\n"
1429                            ."GlueSATotalOnlineSize: 0\n"
1430                            ."GlueSAUsedOnlineSize: 0\n"
1431                            ."GlueSAFreeOnlineSize: 0\n"
1432                            ."GlueSAReservedOnlineSize: 0\n"
1433                            ."GlueSATotalNearlineSize: 0\n"
1434                            ."GlueSAUsedNearlineSize: 0\n"
1435                            ."GlueSAFreeNearlineSize: 0\n"
1436                            ."GlueSAReservedNearlineSize: 0\n"
1437                            ."GlueSARetentionPolicy: UNDEFINED\n"
1438                            ."GlueSAAccessLatency: 0\n"
1439                            ."GlueSAExpirationMode: UNDEFINED\n"
1440                            ."GlueSACapability: UNDEFINED\n"
1441                            ."GlueSAPolicyMaxFileSize: 10000\n"
1442                            ."GlueSAPolicyMinFileSize: 1\n"
1443                            ."GlueSAPolicyMaxData: 100\n"
1444                            ."GlueSAPolicyMaxNumFiles: 10\n"
1445                            ."GlueSAPolicyMaxPinDuration: 10\n"
1446                            ."GlueSAPolicyQuota: 0\n"
1447                            ."GlueSAStateAvailableSpace: 1\n"
1448                            ."GlueSAStateUsedSpace: 1\n\n";
1449
1450         $contents=$contents."dn: GlueVOInfoLocalID=$se_disk,GlueSALocalID=$se_disk\n"
1451                            ."GlueChunkKey: GlueSALocalID=$se_disk\n"
1452                            ."GlueVOInfoLocalID: $se_disk\n"
1453                            ."GlueVOInfoName: $se_disk\n"
1454                            ."GlueVOInfoPath: $se_data\n";
1455         foreach $vo (@vo_list){
1456                            $contents=$contents."GlueVOInfoAccessControlBaseRule: $vo\n";
1457         }
1458                            $contents=$contents."GlueVOInfoTag: UNAVAILABLE\n\n";
1459
1460         foreach $vo (@vo_list){
1461             $contents=$contents."\ndn: GlueSALocalID=$vo,GlueSEUniqueID=$se_disk\n"
1462                                ."GlueSARoot: $vo:$vo\n"
1463                                ."GlueSAPath: $se_data\n"
1464                                ."GlueSAAccessControlBaseRule: $vo\n"
1465                                ."GlueChunkKey: GlueSEUniqueID=$se_disk\n"
1466                                ."GlueSAType: permanent\n"
1467                                ."GlueSAPolicyFileLifeTime: permanent\n"
1468                                ."GlueSAName: $vo\n"
1469                                ."GlueSATotalOnlineSize: 0\n"
1470                                ."GlueSAUsedOnlineSize: 0\n"
1471                                ."GlueSAFreeOnlineSize: 0\n"
1472                                ."GlueSAReservedOnlineSize: 0\n"
1473                                ."GlueSATotalNearlineSize: 0\n"
1474                                ."GlueSAUsedNearlineSize: 0\n"
1475                                ."GlueSAFreeNearlineSize: 0\n"
1476                                ."GlueSAReservedNearlineSize: 0\n"
1477                                ."GlueSARetentionPolicy: UNDEFINED\n"
1478                                ."GlueSAAccessLatency: 0\n"
1479                                ."GlueSAExpirationMode: UNDEFINED\n"
1480                                ."GlueSACapability: UNDEFINED\n"
1481                                ."GlueSAPolicyMaxFileSize: 10000\n"
1482                                ."GlueSAPolicyMinFileSize: 1\n"
1483                                ."GlueSAPolicyMaxData: 100\n"
1484                                ."GlueSAPolicyMaxNumFiles: 10\n"
1485                                ."GlueSAPolicyMaxPinDuration: 10\n"
1486                                ."GlueSAPolicyQuota: 0\n"
1487                                ."GlueSAStateAvailableSpace: 1\n"
1488                                ."GlueSAStateUsedSpace: 1\n\n";
1489
1490             $contents=$contents."dn: GlueVOInfoLocalID=$vo,GlueSALocalID=$vo\n"
1491                                ."GlueChunkKey: GlueSALocalID=$vo\n"
1492                                ."GlueVOInfoLocalID: $vo\n"
1493                                ."GlueVOInfoName: $vo\n"
1494                                ."GlueVOInfoPath: $se_data\n"
1495                                ."GlueVOInfoAccessControlBaseRule: $vo\n"
1496                                ."GlueVOInfoTag: UNAVAILABLE\n\n";
1497         }
1498     }
1499
1500     safe_write($config_file, $contents);
1501
1502     vdt_install_log("===== BEGIN osg-info-static-se.conf =====\n");
1503     vdt_install_log($contents);
1504     vdt_install_log("===== END osg-info-static-se.conf =====\n");
1505
1506     return;
1507 }
1508
1509 ###########################################################################
1510 #
1511 # Function: create_cesebind_config_file
1512 # Purpose:  We create the static conf file osg-info-static-cesebind.conf
1513 #
1514 ###########################################################################
1515 sub create_cesebind_config_file
1516 {
1517
1518     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-cesebind.conf";
1519     my $contents    = "";
1520
1521     if ($batch =~ /^pbs$/i) {
1522         foreach my $queue (keys %pbsQueues){
1523             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1524             if ($disk) {
1525                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1526             }
1527             if ($srm) {
1528                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1529             }
1530
1531             if ($disk) {
1532                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1533                                      ."GlueCESEBindCEAccesspoint: $data\n"
1534                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1535             }
1536
1537             if ($srm && defined $sa_path) {
1538                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1539                                      ."GlueCESEBindCEAccesspoint: $sa_path\n"
1540                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1541             }
1542         }
1543     } elsif ($batch =~ /^lsf$/i) {
1544         foreach my $queue (@lsfQueues){
1545             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n";
1546             if ($disk) {
1547                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1548             }
1549             if ($srm) {
1550                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1551             }
1552
1553             if ($disk) {
1554                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1555                                      ."GlueCESEBindCEAccesspoint: $data\n"
1556                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1557             }
1558
1559             if ($srm && defined $sa_path) {
1560                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$queue\n"
1561                                      ."GlueCESEBindCEAccesspoint: $sa_path\n"
1562                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$queue\n";
1563             }
1564         }
1565     }else{
1566         foreach $vo (@vo_list){
1567             $contents = $contents."\ndn: GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n";
1568             if ($disk) {
1569                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_disk\n";
1570             }
1571             if ($srm) {
1572                 $contents = $contents."GlueCESEBindGroupSEUniqueID: $se_host\n";
1573             }
1574
1575             if ($disk) {
1576                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_disk, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1577                                      ."GlueCESEBindCEAccesspoint: $data\n"
1578                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$vo\n";
1579             }
1580
1581             if ($srm && exists $se_access{$vo} && defined $sa_path) {
1582                 $contents = $contents."\ndn: GlueCESEBindSEUniqueID=$se_host, GlueCESEBindGroupCEUniqueID=$fullhost:2119/jobmanager-$batch-$vo\n"
1583                                      ."GlueCESEBindCEAccesspoint: $sa_path/$se_access{$vo}\n"
1584                                      ."GlueCESEBindCEUniqueID: $fullhost:2119/jobmanager-$batch-$vo\n";
1585             }
1586         }
1587     }
1588
1589     safe_write($config_file, $contents);
1590
1591     vdt_install_log("===== BEGIN osg-info-static-cesebind.conf =====\n");
1592     vdt_install_log($contents);
1593     vdt_install_log("===== END osg-info-static-cesebind.conf =====\n");
1594
1595     return;
1596 }
1597 #
1598 ###########################################################################
1599 #
1600 # Function: create_service_config_file
1601 # Purpose:  We create the static conf file osg-info-static-service.conf
1602 #
1603 ###########################################################################
1604 sub create_service_config_file
1605 {
1606
1607     my $config_file = "$lcg_location/share/doc/osg-info-gip-config/osg-info-static-service.conf";
1608     my $contents    = "\n";
1609
1610     if(-e $config_file) {
1611         my $tmp;
1612         open(FILE,$config_file) || die "Could not open the config_file\n";
1613         while($tmp=<FILE>) {
1614             $contents.=$tmp;
1615         }
1616         close(FILE);
1617     }
1618
1619     safe_write($config_file, $contents);
1620
1621     vdt_install_log("===== BEGIN osg-info-static-service.conf =====\n");
1622     vdt_install_log($contents);
1623     vdt_install_log("===== END osg-info-static-service.conf =====\n");
1624
1625     return;
1626 }
1627
1628 ###########################################################################
1629 #
1630 # Function: create_generic_config_file
1631 # Purpose:  We create the static conf file osg-info-generic.conf
1632 #
1633 ###########################################################################
1634 sub create_generic_config_file
1635 {
1636     my $config_file = "$lcg_location/etc/osg-info-generic.conf";
1637     if (-e $config_file){
1638         vdt_install_log("Warning: osg-info-generic.conf left unchanged since it already exists")
1639     }else{
1640         my $contents    = "";
1641
1642         $contents = $contents."temp_dir = $lcg_location/var/gip/tmp\n"
1643                              ."plugin_dir = $lcg_location/var/gip/plugin\n"
1644                              ."static_dir = $lcg_location/var/gip/ldif\n"
1645                              ."provider_dir = $lcg_location/var/gip/provider\n"
1646                              ."freshness = 300\n"
1647                              ."cache_ttl = 600\n"
1648                              ."response = 60\n"
1649                              ."timeout = 150\n";
1650
1651         safe_write($config_file, $contents);
1652
1653         vdt_install_log("===== BEGIN osg-info-generic.conf =====\n");
1654         vdt_install_log($contents);
1655         vdt_install_log("===== END osg-info-generic.conf =====\n");
1656     }
1657     return;
1658 }
1659
1660 ###########################################################################
1661 #
1662 # Function: create_config_file
1663 # Purpose:  We copy the example GIP configuration file and edit it as best
1664 #           we can on behalf of the sysadmin. Note that there is still a lot of
1665 #           editing to be done. For example, we change things like
1666 #           jobmanager-pbs to jobmanager-condor, but they also have
1667 #           jobmanager-pbs-{short|medium|long}, which will probably never
1668 #           exist on a Condor pool. It will just require hand-editing by
1669 #           the system administrator.
1670 #
1671 ###########################################################################
1672 sub create_config_file
1673 {
1674     create_site_config_file
1675     create_cluster_config_file();
1676     create_ce_config_file();
1677     create_se_config_file();
1678     create_cesebind_config_file();
1679     create_service_config_file();
1680     create_generic_config_file();
1681     create_wrapper_files();
1682     create_static_ldif_files();
1683     return;
1684 }
1685
1686 ###########################################################################
1687 #
1688 # Function: create_wrapper_files
1689 # Purpose:  We create the necessary wrapper files
1690 #
1691 ###########################################################################
1692 sub create_wrapper_files
1693 {
1694     #Creating Wrapper Script
1695     my $wrapper_file = "$lcg_location/libexec/osg-info-wrapper";
1696     my $contents='#!/bin/sh';
1697     $contents=$contents."\n".'export LANG=C';
1698     $contents=$contents."\n$lcg_location/bin/lcg-info-generic $lcg_location/etc/osg-info-generic.conf\n";
1699
1700     safe_write($wrapper_file, $contents);
1701     system("chmod +x $wrapper_file");
1702     vdt_install_log("===== BEGIN osg-info-wrapper =====\n");
1703     vdt_install_log($contents);
1704     vdt_install_log("===== END osg-info-wrapper =====\n");
1705
1706     #Create provider wrapper when necessary (Currently used for gums-monitoring)
1707     $wrapper_file = "$lcg_location/var/gip/provider/osg-info-dynamic-providers";
1708     $contents='#!/bin/sh';
1709     $contents=$contents."\n"."$lcg_location/libexec/osg-info-software-provider $app/etc $fullhost\n";
1710     if ($gums == 1){
1711         $contents=$contents."\n"."$lcg_location/libexec/osg-info-gums-status-probe $vdt_location\n";
1712     }
1713     if ($dynamic_dcache == 1){
1714         $contents = $contents."\n$lcg_location/libexec/services_info_provider.py\n";
1715         $contents = $contents."\n$lcg_location/libexec/token_info_provider.py\n";
1716     }
1717
1718     $contents = $contents."\nif [ -f \"$lcg_location/etc/add-attributes.conf\" ]; then\n    cat $lcg_location/etc/add-attributes.conf\nfi\n";
1719
1720         #We remove the existing wrapper file because it will cause duplication of information
1721     system("rm -f $wrapper_file");
1722     safe_write($wrapper_file, $contents);
1723     system("chmod +x $wrapper_file");
1724     vdt_install_log("===== BEGIN osg-info-wrapper =====\n");
1725     vdt_install_log($contents);
1726     vdt_install_log("===== END osg-info-wrapper =====\n");
1727
1728     #Create pluging wrappers here
1729
1730     $wrapper_file = "$lcg_location/var/gip/plugin/osg-info-dynamic-plugins";
1731
1732     # Create appropriate lcg-info-dynamic-ce-plugin wrapper script in plugin dir
1733     my $ldif_file = "$lcg_location/var/gip/ldif/osg-info-static-ce.ldif";
1734     $contents = '#!/bin/sh'."\n";
1735     if ($batch =~ /^condor$/i) {
1736         # The condor script is different--it requires the path to the binaries as an argument.
1737         $contents = $contents."$lcg_location/libexec/osg-info-dynamic-condor $condor_bin_location $ldif_file \n";
1738     }
1739     elsif ($batch =~ /^lsf$/i) {
1740         # The lsf script is also different--it requires the path to the binaries as an argument.
1741         $contents = $contents."$lcg_location/libexec/osg-info-dynamic-lsf $lsf_bin_location $ldif_file \n";
1742     }
1743     elsif ($batch =~ /pbs/i) {
1744         # The pbs script is also different--it requires the path to the binaries as an argument.
1745         $contents = $contents."$lcg_location/libexec/osg-info-dynamic-pbs $pbs_bin_location $ldif_file \n";
1746     }
1747     else {
1748         $contents = $contents."$lcg_location/libexec/osg-info-dynamic-$batch $ldif_file \n";
1749     }
1750
1751     # 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
1752     #$ldif_file = "$lcg_location/var/gip/ldif/osg-info-static-cluster.ldif";
1753     #$contents = $contents."\n$lcg_location/libexec/osg-info-dynamic-software $ldif_file $lcg_location/var/info\n";
1754    
1755
1756     # Create appropriate lcg-info-dynamic-location-plugin wrapper script in plugin dir
1757     $ldif_file = "$lcg_location/var/gip/ldif/osg-info-static-cluster.ldif";
1758     $contents = $contents."\n$lcg_location/libexec/osg-info-dynamic-location $ldif_file $app/etc\n";
1759
1760     # Create appropriate lcg-info-dynamic-se-plugin wrapper script in plugin dir
1761     $ldif_file = "$lcg_location/var/gip/ldif/osg-info-static-se.ldif";
1762     if($disk){
1763         $contents = $contents."\n$lcg_location/libexec/osg-info-dynamic-classicSE $ldif_file $app/etc\n";
1764     }
1765     # This script has been deprecated (newer versions of dcache have disabled this functionality)
1766     # if($srm){
1767     #     $contents = $contents."\n$lcg_location/libexec/osg-info-dynamic-dcache $ldif_file $vdt_location\n";
1768     # }
1769     $contents = $contents."\nif [ -f \"$lcg_location/etc/alter-attributes.conf\" ]; then\n    cat $lcg_location/etc/alter-attributes.conf\nfi\n";
1770
1771     #We remove the existing wrapper file because it will cause duplication of information
1772     system("rm -f $wrapper_file");
1773
1774     safe_write($wrapper_file, $contents);
1775     system("chmod +x $wrapper_file");
1776     vdt_install_log("===== BEGIN osg-info-dynamic-plugins =====\n");
1777     vdt_install_log($contents);
1778     vdt_install_log("===== END osg-info-dynamic-plugins =====\n");
1779 }
1780
1781 ###########################################################################
1782 #
1783 # Function: create_static_ldif_files
1784 # Purpose:  We create the following static ldif files
1785 #           1. lcg-info-static-site.ldif
1786 #           2. lcg-info-static-cluster.ldif
1787 #           3. lcg-info-static-ce.ldif
1788 #           4. lcg-info-static-se.ldif
1789 #           5. lcg-info-static-cesebind.ldif
1790 #           6. lcg-info-static-service.ldif
1791 #
1792 ###########################################################################
1793 sub create_static_ldif_files
1794 {
1795
1796     my $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-site.conf -t $lcg_location/etc/GlueSite.template`;
1797
1798     safe_write("$lcg_location/var/gip/ldif/osg-info-static-site.ldif", $contents);
1799
1800     vdt_install_log("===== BEGIN osg-info-static-site.ldif =====\n");
1801     vdt_install_log($contents);
1802     vdt_install_log("===== END osg-info-static-site.ldif =====\n");
1803
1804     $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-cluster.conf -t $lcg_location/etc/GlueCluster.template`;
1805
1806     safe_write("$lcg_location/var/gip/ldif/osg-info-static-cluster.ldif", $contents);
1807
1808     vdt_install_log("===== BEGIN osg-info-static-cluster.ldif =====\n");
1809     vdt_install_log($contents);
1810     vdt_install_log("===== END osg-info-static-cluster.ldif =====\n");
1811
1812     $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-ce.conf -t $lcg_location/etc/GlueCE.template`;
1813
1814     safe_write("$lcg_location/var/gip/ldif/osg-info-static-ce.ldif", $contents);
1815
1816     vdt_install_log("===== BEGIN osg-info-static-ce.ldif =====\n");
1817     vdt_install_log($contents);
1818     vdt_install_log("===== END osg-info-static-ce.ldif =====\n");
1819
1820     $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-se.conf -t $lcg_location/etc/GlueSE.template`;
1821
1822     safe_write("$lcg_location/var/gip/ldif/osg-info-static-se.ldif", $contents);
1823
1824     vdt_install_log("===== BEGIN osg-info-static-se.ldif =====\n");
1825     vdt_install_log($contents);
1826     vdt_install_log("===== END osg-info-static-se.ldif =====\n");
1827
1828     $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-cesebind.conf -t $lcg_location/etc/GlueCESEBind.template`;
1829
1830     safe_write("$lcg_location/var/gip/ldif/osg-info-static-cesebind.ldif", $contents);
1831
1832     vdt_install_log("===== BEGIN osg-info-static-cesebind.ldif =====\n");
1833     vdt_install_log($contents);
1834     vdt_install_log("===== END osg-info-static-cesebind.ldif =====\n");
1835
1836     $contents = `$lcg_location/sbin/lcg-info-static-create -c $lcg_location/share/doc/osg-info-gip-config/osg-info-static-service.conf -t $lcg_location/etc/GlueService.template`;
1837
1838     safe_write("$lcg_location/var/gip/ldif/osg-info-static-service.ldif", $contents);
1839
1840     vdt_install_log("===== BEGIN osg-info-static-service.ldif =====\n");
1841     vdt_install_log($contents);
1842     vdt_install_log("===== END osg-info-static-service.ldif =====\n");
1843
1844 }
1845
1846 ###########################################################################
1847 #
1848 # Function: edit_slapd_conf
1849 # Purpose:  Edit $globus_location/etc/grid-info-slapd.conf to include the
1850 #           GLUE Schema and the site name.
1851 #
1852 ###########################################################################
1853 sub edit_slapd_conf
1854 {
1855     my $slapd_conf  = "$globus_location/etc/grid-info-slapd.conf";
1856     my $contents;
1857     my $line;
1858         my $in_giis = 0;
1859     my $site_name;
1860
1861     $site_name = $osg_site_name;
1862     $site_name =~ s/\"//g;
1863
1864     # We read the file and eliminate old glue schema lines while
1865     # adding the lines we want in the right place.
1866     open(CONF, "<", $slapd_conf);
1867     while (defined($line = <CONF>)) {
1868         if ($line =~ 'include.*core\.schema') {
1869             $contents .= $line;
1870             $contents .= "include $globus_location/etc/Glue-CORE.schema\n";
1871             $contents .= "include $globus_location/etc/Glue-CE.schema\n";
1872             $contents .= "include $globus_location/etc/Glue-CESEBind.schema\n";
1873             $contents .= "include $globus_location/etc/Glue-SE.schema\n";
1874                 } elsif ($line =~ '^database\s+(\S*)') {
1875                         if ($1 eq "giis") {
1876                                 $in_giis = 1;
1877                         } else {
1878                                 $in_giis = 0;
1879                         }
1880                         $contents .= $line;
1881                 } elsif ($in_giis && $line =~ "^(suffix.*Mds-Vo-name=).*(o=Grid\")") {
1882                         $contents .= "$1$site_name, $2\n";
1883         } elsif ($line !~ 'include.*Glue.*schema') {
1884             $contents .= $line;
1885         }
1886     }
1887     close(CONF);
1888
1889     safe_write($slapd_conf, $contents);
1890
1891     vdt_install_log("===== BEGIN grid-info-slapd.conf =====\n");
1892     vdt_install_log($contents);
1893     vdt_install_log("===== END grid-info-slapd.conf =====\n");
1894
1895     return;
1896 }
1897
1898 ###########################################################################
1899 #
1900 # Function: edit_resource_ldif_conf
1901 # Purpose:  Edit $globus_location/etc/grid-info-resource-ldif.conf.
1902 #           This is where we put in the description of how to run the
1903 #           glue information provider.
1904 # Note:     We aren't going to use slurp to read the file, because
1905 #           we need to do some careful deletions from this file.
1906 #
1907 ###########################################################################
1908 sub edit_resource_ldif_conf
1909 {
1910     my $ldif_conf = "$globus_location/etc/grid-info-resource-ldif.conf";
1911     my $contents;
1912     my $line;
1913
1914     open(CONF, "<", $ldif_conf);
1915     my $in_block = 0;
1916     my $in_comment_block = 0;
1917     while (defined($line = <CONF>)) {
1918         # This chunk of text indicates the beginning of the block we want to remove.
1919         if ($line =~ "dn: Mds-Vo-Name=local, o=Grid") {
1920             $in_block = 1;
1921         }
1922         # Empty lines indicate separators between chunks in the file
1923         elsif ($in_block && $line =~ '^\s*$') {
1924             $in_block = 0;
1925             $in_comment_block = 0;
1926         }
1927         # Take the line if we're not in the block
1928         elsif (!$in_block){
1929             # These blocks should be commented out (There are more than three blocks,
1930             # but they start out the same way)
1931             if (   $line =~ "^dn: Mds-Host-hn"
1932                 || $line =~ "^dn: Mds-Device-Group-name"
1933                 || $line =~ "^dn: Mds-Software-deployment") {
1934                 $in_comment_block = 1;
1935             }
1936             if ($in_comment_block) {
1937                 if ($line =~ '^\s*$') {
1938                     $in_comment_block = 0;
1939                 } else {
1940                     $contents .= "#";
1941                 }
1942             }
1943             $contents .= $line;
1944         }
1945     }
1946     close(CONF);
1947
1948     # Now we add the text we want, which describes what kind of information
1949     # the glue information provider provides, and how to run it.
1950     $contents .= "\n";
1951     $contents .= "dn: Mds-Vo-Name=local, o=Grid\n";
1952     $contents .= "objectclass: GlobusTop\n";
1953     $contents .= "objectclass: GlobusActiveObject\n";
1954     $contents .= "objectclass: GlobusActiveSearch\n";
1955     $contents .= "type: exec\n";
1956     $contents .= "path: $lcg_location/libexec\n";
1957     $contents .= "base: osg-info-wrapper\n";
1958     $contents .= "cachetime: 60\n";
1959     $contents .= "timelimit: 60\n";
1960     $contents .= "sizelimit: 500\n";
1961
1962     safe_write($ldif_conf, $contents);
1963
1964     vdt_install_log("===== BEGIN grid-info-resource-ldif.conf =====\n");
1965     vdt_install_log($contents);
1966     vdt_install_log("===== END grid-info-resource-ldif.conf =====\n");
1967
1968     return;
1969 }
1970
1971 ###########################################################################
1972 #
1973 # Function: edit_resource_register_conf
1974 # Purpose:  Edit $globus_location/etc/grid-info-resource-register.conf
1975 #           to contain our site name.
1976 #
1977 ###########################################################################
1978 sub edit_resource_register_conf
1979 {
1980     my $register_conf = "$globus_location/etc/grid-info-resource-register.conf";
1981     my $contents;
1982     my $site_name;
1983
1984     $site_name = $osg_site_name;
1985     $site_name =~ s/\"//g;
1986
1987         $contents = slurp($register_conf);
1988         $contents =~ s|^dn(.*)(Mds-Vo-name=).*(o=grid)|dn$1$2$site_name, $3|m;
1989         safe_write($register_conf, $contents);
1990
1991     vdt_install_log("===== BEGIN grid-info-resource-register.conf =====\n");
1992     vdt_install_log($contents);
1993     vdt_install_log("===== END grid-info-resource-register.conf =====\n");
1994
1995     return;
1996 }
1997
1998 ###########################################################################
1999 #
2000 # Function: describe_postinstall
2001 # Purpose:  Tell people what they have to do to finish up the process.
2002 #           We tell them both to stdout and to the post-install README.
2003 #           We expect them to run this interactively, which is why it goes
2004 #           to stdout, but we don't want them to lose the information, which
2005 #           is why it goes to the post-install README.
2006 #
2007 ###########################################################################
2008 sub describe_postinstall
2009 {
2010     my $post =
2011         "We have set up the Generic Information Providers (GIP). "
2012         ."If you were running the GRIS (MDS), you must stop and "
2013         ."restart it for these changes to take affect. You can do this "
2014         ."with the following commands:\n\n";
2015
2016     my $stop_cmd  = "$vdt_location/post-install/gris stop";
2017     my $start_cmd = "$vdt_location/post-install/gris start";
2018
2019     my $post2 =
2020         "Note that this information is also in $vdt_location/post-install/README\n";
2021
2022     #post_install_log("$post");
2023     #post_install_log("$stop_cmd");
2024     #post_install_log("$start_cmd");
2025
2026     if ($have_warnings) {
2027        # print "\n";
2028     }
2029     #print wrap("", "", "$post\n");
2030     #print "\n";
2031     #print "$stop_cmd\n";
2032     #print "$start_cmd\n\n";
2033     #print wrap("", "", "$post2\n");
2034
2035     return;
2036 }
2037 ###########################################################################
2038 #
2039 # Function: setup_cemon
2040 # Purpose:  Links CEmonitor with the GIP
2041 #
2042 ###########################################################################
2043 sub setup_cemon
2044 {
2045    ##
2046    ## Check to make sure CEMon is installed
2047    ##
2048       return unless(-d "${vdt_location}/glite/etc/glite-ce-ce-plugin");
2049
2050    ##
2051    ## Create our plugin script
2052    ##
2053    my $glite_plugin = "${vdt_location}/glite/etc/glite-ce-ce-plugin/glite-ce-info";
2054    my $contents = "#!/bin/sh\n".
2055                   "${vdt_location}/lcg/libexec/osg-info-wrapper";
2056    safe_write($glite_plugin, $contents);
2057    system("chmod 0755 $glite_plugin");
2058 }
2059            
2060
Note: See TracBrowser for help on using the browser.