Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #590 from tgooding/master
Browse files Browse the repository at this point in the history
Improve configuration settings and add CONTRIBID substitution
  • Loading branch information
tgooding authored Feb 24, 2019
2 parents 1f14682 + ece2cd8 commit cc7ace9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bb/src/bbcmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ int main(int orig_argc, const char** orig_argv)
("command", po::value< string >(), "Command")
("help", "Display commands and options")
("config", po::value<string>()->default_value(DEFAULT_CONFIGFILE), "Path to configuration file")
("compute_config", po::value<string>(), "Path to configuration file used on compute nodes")
("jobid", po::value<string>(), "bbcmd Job ID")
("jobindex", po::value<string>(), "bbcmd Job index")
("jobstepid", po::value<string>(), "bbcmd Job step ID")
Expand Down Expand Up @@ -1133,10 +1134,14 @@ int main(int orig_argc, const char** orig_argv)
// Valid command processing
command = vm["command"].as<string>();

if (curConfig.load(vm["config"].as<string>()))
std::string configfile = vm["config"].as<string>();
if((vm.count("target") == 0) && (vm.count("compute_config") > 0))
{
configfile = vm["compute_config"].as<string>();
}
if (curConfig.load(configfile))
{
rc = -1;
std::string configfile = vm["config"].as<string>();
errorText << "Error loading configuration from " << configfile;
cerr << errorText << endl;
bberror << err("error.configfile", configfile);
Expand Down Expand Up @@ -1319,6 +1324,11 @@ int main(int orig_argc, const char** orig_argv)
contribid = id;
Coral_SetVar("contribid", to_string(id).c_str());
}
string tmp = string("CONTRIBID=") + to_string(contribid);
char* newenv = (char*)malloc(tmp.size()+1);
memcpy(newenv, tmp.c_str(), tmp.size()+1);
putenv(newenv); // pointer ownership is transferred to putenv

bberror.setToNotClear(); //do not clear bberror for bbcmd calls of BB APIs
rc = (*bbcmd_map[command].func)(vm);
bberror << err("rc", rc);
Expand Down

0 comments on commit cc7ace9

Please sign in to comment.