Пример #1
0
/**
 * \brief To initialize the FMS monitor with individual parameters instead of configuration file
 * \param vishnuId The password of the root user vishnu_user for the connection with the database
 * \param dbConfig The configuration of the database
 * \param machineId The machine identifier
 * \param batchType The batch scheduler type
 * \return raises an execption
*/
void
MonitorFMS::init(int vishnuId, DbConfiguration dbConfig) {

  DbFactory factory;

  mdatabaseVishnu = factory.createDatabaseInstance(dbConfig);

  std::string sqlCommand("SELECT * FROM vishnu where vishnuid="+vishnu::convertToString(vishnuId));

  try {
    /*connection to the database*/
    mdatabaseVishnu->connect();

    /* Checking of vishnuid on the database */
    boost::scoped_ptr<DatabaseResult> result(mdatabaseVishnu->getResult(sqlCommand.c_str()));
    if (result->getResults().size() == 0) {
      throw SystemException(ERRCODE_DBERR, "The vishnuid is unrecognized");
    }
  } catch (VishnuException& e) {
    exit(0);
  }

}
Пример #2
0
int
ServerXMS::init(SedConfig& cfg) {
  using vishnu::convertToString;
  using vishnu::UMSMAPPERNAME;
  using vishnu::FMSMAPPERNAME;
  using vishnu::TMSMAPPERNAME;

  msendmailScriptPath = cfg.sendmailScriptPath;
  DbFactory factory;
  AuthenticatorFactory authfactory;
  int errorCode(0);

  setenv("VISHNU_DEBUG_LEVEL", vishnu::convertToString(mdebugLevel).c_str(), 0);

  //set the machineId
  mmachineId = cfg.mid;

  // initialize the SeD configuration object
  msedConfig = &cfg.config;

  mhasUMS = cfg.hasUMS;
  mhasTMS = cfg.hasTMS;
  mhasFMS = cfg.hasFMS;

  // set the debug level
  bool isSetDebugLevel = msedConfig->getConfigValue(vishnu::DEBUG_LEVEL, mdebugLevel);
  if (!isSetDebugLevel || mdebugLevel < 0) {
    mdebugLevel = 0;
  }

  //initialization of the batchType
  mbatchType = cfg.batchType;

  if (mhasTMS) {
    //initialization of the batchVersion
    if (mbatchType != DELTACLOUD && mbatchType != OPENNEBULA) {
      msedConfig->getRequiredConfigValue<std::string>(vishnu::BATCHVERSION, mbatchVersion);
    }

    std::string batchDefaultConfigFile;
    if (msedConfig->getConfigValue(vishnu::DEFAULTBATCHCONFIGFILE, batchDefaultConfigFile)) {
      switch(mbatchType) {
      case TORQUE:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "#PBS");
        break;
      case LOADLEVELER:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "# @");
        break;
      case SLURM:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "#SBATCH");
        break;
      case LSF:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "#BSUB");
        break;
      case SGE:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "#$");
        break;
      case PBSPRO:
        getConfigOptions(batchDefaultConfigFile.c_str(), mdefaultBatchOption, "#PBS");
        break;
      case DELTACLOUD:
        //No yet supported
        break;
      case POSIX:
        //No yet supported
        break;
      default:
        break;
      }
    }
  }

  try {
    mdatabaseVishnu = factory.createDatabaseInstance(cfg.dbConfig);
    mauthenticator = authfactory.createAuthenticatorInstance(cfg.authenticatorConfig);

    mvishnuId = cfg.vishnuId;

    std::string sqlCommand("SELECT * FROM vishnu where vishnuid="+convertToString(mvishnuId));

    /*connection to the database*/
    mdatabaseVishnu->connect();
    mmapperTMS = new TMSMapper(MapperRegistry::getInstance(), TMSMAPPERNAME);
    mmapperTMS->registerMapper();
    mmapperFMS = new FMSMapper(MapperRegistry::getInstance(), FMSMAPPERNAME);
    mmapperFMS->registerMapper();
    mmapperUMS = new UMSMapper(MapperRegistry::getInstance(), UMSMAPPERNAME);
    mmapperUMS->registerMapper();

    /* Checking of vishnuid on the database */
    boost::scoped_ptr<DatabaseResult> result(mdatabaseVishnu->getResult(sqlCommand.c_str()));
    if (result->getResults().size() == 0) {
      SystemException e(ERRCODE_DBERR, "The vishnuid is unrecognized");
      throw e;
    }

  } catch (VishnuException& e) {
    std::cout << e.what() << "\n";
    errorCode = 1;
  }

// initialization of the service table
  initMap(cfg.mid);

  return errorCode;
}