Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Defines | Functions | Variables
environment.cpp File Reference
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <arc/ArcLocation.h>
#include <arc/Utils.h>
#include <arc/Thread.h>
#include "environment.h"

Go to the source code of this file.

Classes

class  prstring

Defines

#define olog   std::cerr

Functions

std::string operator+ (const char *, const prstring &)
std::string operator+ (const std::string &, const prstring &)
std::string globus_loc (void)
 Globus installation path - $GLOBUS_LOCATION, /opt/globus.
std::string globus_scripts_loc (void)
std::string nordugrid_loc (void)
 ARC installation path - $ARC_LOCATION, executable path.
std::string nordugrid_libexec_loc (void)
 ARC system tools - $ARC_LOCATION/libexec/arc, $ARC_LOCATION/libexec.
std::string nordugrid_lib_loc (void)
std::string nordugrid_sbin_loc (void)
std::string nordugrid_config_loc (void)
 ARC configuration file /etc/arc.conf $ARC_LOCATION/etc/arc.conf.
std::string cert_dir_loc (void)
void nordugrid_config_loc (const std::string &val)
std::string runtime_config_dir (void)
void runtime_config_dir (const std::string &val)
std::string support_mail_address (void)
 Email address of person responsible for this ARC installation grid.manager, it can also be set from configuration file.
void support_mail_address (const std::string &val)
std::string globus_gridmap (void)
 Global gridmap files with welcomed users' DNs and UNIX names $GRIDMAP, default /etc/grid-security/grid-mapfile.
static bool file_exists (const char *name)
static bool dir_exists (const char *name)
bool read_env_vars (bool guess)
 Read environment, check files and set variables Accepts: guess - if false, default values are not allowed. Returns: true - success. false - something is missing.

Variables

static prstring globus_loc_
static prstring globus_scripts_loc_
static prstring nordugrid_loc_
static prstring nordugrid_libexec_loc_
static prstring nordugrid_lib_loc_
static prstring nordugrid_sbin_loc_
static prstring nordugrid_config_loc_
static prstring cert_dir_loc_
static prstring runtime_config_dir_
static prstring support_mail_address_
static prstring globus_gridmap_

Define Documentation

#define olog   std::cerr

Definition at line 12 of file environment.cpp.


Function Documentation

std::string cert_dir_loc ( void  )

Definition at line 164 of file environment.cpp.

                             {
  return cert_dir_loc_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool dir_exists ( const char *  name) [static]

Definition at line 200 of file environment.cpp.

                                         {
  struct stat st;
  if(lstat(name,&st) != 0) return false;
  if(!S_ISDIR(st.st_mode)) return false;
  return true;
}
static bool file_exists ( const char *  name) [static]

Definition at line 193 of file environment.cpp.

                                          {
  struct stat st;
  if(lstat(name,&st) != 0) return false;
  if(!S_ISREG(st.st_mode)) return false;
  return true;
}

Here is the caller graph for this function:

std::string globus_gridmap ( void  )

Global gridmap files with welcomed users' DNs and UNIX names $GRIDMAP, default /etc/grid-security/grid-mapfile.

Definition at line 188 of file environment.cpp.

                               {
  return globus_gridmap_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string globus_loc ( void  )

Globus installation path - $GLOBUS_LOCATION, /opt/globus.

Definition at line 136 of file environment.cpp.

                           {
  return globus_loc_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string globus_scripts_loc ( void  )

Definition at line 140 of file environment.cpp.

                                   {
  return globus_scripts_loc_.str();
}

Here is the call graph for this function:

std::string nordugrid_config_loc ( void  )

ARC configuration file /etc/arc.conf $ARC_LOCATION/etc/arc.conf.

Definition at line 160 of file environment.cpp.

                                     {
  return nordugrid_config_loc_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nordugrid_config_loc ( const std::string &  val)

Definition at line 168 of file environment.cpp.

std::string nordugrid_lib_loc ( void  )

Definition at line 152 of file environment.cpp.

                                  {
  return nordugrid_lib_loc_.str();
}

Here is the call graph for this function:

std::string nordugrid_libexec_loc ( void  )

ARC system tools - $ARC_LOCATION/libexec/arc, $ARC_LOCATION/libexec.

Definition at line 148 of file environment.cpp.

                                      {
  return nordugrid_libexec_loc_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string nordugrid_loc ( void  )

ARC installation path - $ARC_LOCATION, executable path.

Definition at line 144 of file environment.cpp.

                              {
  return nordugrid_loc_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string nordugrid_sbin_loc ( void  )

Definition at line 156 of file environment.cpp.

                                   {
  return nordugrid_sbin_loc_.str();
}

Here is the call graph for this function:

std::string operator+ ( const char *  val1,
const prstring val2 
)

Definition at line 105 of file environment.cpp.

                                                           {
  return (val1 + val2.str());
}

Here is the call graph for this function:

std::string operator+ ( const std::string &  val1,
const prstring val2 
)

Definition at line 109 of file environment.cpp.

                                                                {
  return (val1 + val2.str());
}

Here is the call graph for this function:

bool read_env_vars ( bool  guess)

Read environment, check files and set variables Accepts: guess - if false, default values are not allowed. Returns: true - success. false - something is missing.

Definition at line 207 of file environment.cpp.

                               {
  if(globus_loc_.empty()) {
    globus_loc_=Arc::GetEnv("GLOBUS_LOCATION");
    if(globus_loc_.empty()) {
      if(!guess) {
        olog<<"Warning: GLOBUS_LOCATION environment variable not defined"<<std::endl;
        //return false;
      }
      else {
        globus_loc_="/opt/globus";
      };
    };
    Arc::SetEnv("GLOBUS_LOCATION",globus_loc_.str());
  };
  globus_scripts_loc_=globus_loc_+"/libexec";

  if(nordugrid_loc_.empty()) {
    nordugrid_loc_=Arc::GetEnv("ARC_LOCATION");
    if(nordugrid_loc_.empty()) {
      nordugrid_loc_=Arc::ArcLocation::Get();
    };
    nordugrid_lib_loc_=nordugrid_loc_+"/"+PKGLIBSUBDIR;
    nordugrid_libexec_loc_=nordugrid_loc_+"/"+PKGLIBEXECSUBDIR;
  };

  if(nordugrid_config_loc_.empty()) {
    std::string tmp = Arc::GetEnv("ARC_CONFIG");
    if(tmp.empty()) {
      tmp=Arc::GetEnv("NORDUGRID_CONFIG");
      if(tmp.empty()) {
        tmp="/etc/arc.conf";
        nordugrid_config_loc_=tmp;
        if(!file_exists(tmp.c_str())) {
          olog<<"Central configuration file is missing at guessed location:\n"
              <<"  /etc/arc.conf\n"
              <<"Use ARC_CONFIG variable for non-standard location"
              <<std::endl;
          return false;
        };
      };
    };
    if(!tmp.empty()) nordugrid_config_loc_=tmp;
  };
  
  if(cert_dir_loc_.empty()) {
    cert_dir_loc_=Arc::GetEnv("X509_CERT_DIR");
  };

  // Set all environement variables for other tools
  Arc::SetEnv("ARC_CONFIG",nordugrid_config_loc_);
  if(support_mail_address_.empty()) {
    char hn[100];
    support_mail_address_="grid.manager@";
    if(gethostname(hn,99) == 0) {
      support_mail_address_+=hn;
    }
    else {
      support_mail_address_+="localhost";
    };
  };
  std::string tmp=Arc::GetEnv("GRIDMAP");
  if(tmp.empty()) { globus_gridmap_="/etc/grid-security/grid-mapfile"; }
  else { globus_gridmap_=tmp; };
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string runtime_config_dir ( void  )

Definition at line 172 of file environment.cpp.

                                   {
  return runtime_config_dir_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void runtime_config_dir ( const std::string &  val)

Definition at line 176 of file environment.cpp.

std::string support_mail_address ( void  )

Email address of person responsible for this ARC installation grid.manager, it can also be set from configuration file.

Definition at line 180 of file environment.cpp.

                                     {
  return support_mail_address_.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void support_mail_address ( const std::string &  val)

Definition at line 184 of file environment.cpp.


Variable Documentation

Definition at line 128 of file environment.cpp.

Definition at line 134 of file environment.cpp.

Definition at line 114 of file environment.cpp.

Definition at line 116 of file environment.cpp.

Definition at line 126 of file environment.cpp.

Definition at line 122 of file environment.cpp.

Definition at line 120 of file environment.cpp.

Definition at line 118 of file environment.cpp.

Definition at line 124 of file environment.cpp.

Definition at line 130 of file environment.cpp.

Definition at line 132 of file environment.cpp.