root/gip/trunk/vdt/setup/configure_gip

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

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

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