Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions GPP/cpp/GPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,60 @@ CF::ExecutableDevice::ProcessID_Type GPP_i::execute (const char* name, const CF:
prepend_args.push_back(waveform_name+"."+name_binding);
}
}
bool useDocker = false;
if (tmp_params.find("__DOCKER_IMAGE__") != tmp_params.end()) {
std::string image_name = tmp_params["__DOCKER_IMAGE__"].toString();
LOG_DEBUG(GPP_i, __FUNCTION__ << "Component specified a Docker image: " << image_name);
std::string target = GPP_i::find_exec("docker");
if(!target.empty()) {
char buffer[128];
std::string result = "";
std::string docker_query = target + " image -q " + image_name;
FILE* pipe = popen(docker_query.c_str(), "r");
if (!pipe)
throw CF::ExecutableDevice::ExecuteFail(CF::CF_EINVAL, "Could not run popen");
try {
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL) {
result += buffer;
}
}
} catch (...) {
pclose(pipe);
throw;
}
pclose(pipe);
if (result.empty()) {
CF::Properties invalidParameters;
invalidParameters.length(invalidaParameters.length() + 1);
invalidParameters[invalidParameters.length() -1].id = "__DOCKER_IMAGE__";
invalidParameters[invalidParameters.length() -1].value <<= image_name.c_str();
throw CF::ExecutableDevice::InvalidParameters(invalidParameters);
}
std::string container_name(component_id);
std::replace(container_name.begin(), container_name.end(), ':', '-');
prepend_args.push_back(target);
prepend_args.push_back("run");
prepend_args.push_back("--sig-proxy=true");
prepend_args.push_back("--rm");
prepend_args.push_back("--name");
prepend_args.push_back(container_name);
prepend_args.push_back("--net=host");
prepend_args.push_back("-v");
prepend_args.push_back(docker_omniorb_cfg+":/etc/omniORB.cfg");
if ( tmp_params.find("__DOCKER_ARGS__") != tmp_params.end()) {
std::string docker_args_raw = tmp_params["__DOCKER_ARGS__"].toString();
std::vector<std::string> docker_args;
boost::split(docker_args, docker_args_raw, boost::is_any_of(" "));
BOOST_FOREACH( const std::string& arg, docker_args) {
prepend_args.push_back(arg);
}
}
prepend_args.push_back(image_name);
LOG_DEBUG(GPP_i, __FUNCTION__ << "Component will launch within a Docker container using this image: " << image_name);
useDocker = true;
}
}
CF::ExecutableDevice::ProcessID_Type ret_pid;
try {
ret_pid = do_execute(name, options, tmp_params, prepend_args);
Expand Down
3 changes: 2 additions & 1 deletion GPP/cpp/GPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class GPP_i : public GPP_base

CF::ExecutableDevice::ProcessID_Type do_execute (const char* name, const CF::Properties& options,
const CF::Properties& parameters,
const std::vector<std::string> prepend_args)
const std::vector<std::string> prepend_args,
const bool use_docker)
throw (CF::ExecutableDevice::ExecuteFail,
CF::InvalidFileName, CF::ExecutableDevice::InvalidOptions,
CF::ExecutableDevice::InvalidParameters,
Expand Down
10 changes: 9 additions & 1 deletion GPP/cpp/GPP_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,15 @@ void GPP_base::loadProperties()
"",
"external",
"property");


addProperty(docker_omniorb_cfg,
"docker_omniorb_cfg",
"docker_omniorb_cfg",
"readonly",
"/etc/omniORB.cfg",
"external",
"property");

addProperty(mcastnicInterface,
"",
"DCE:4e416acc-3144-47eb-9e38-97f1d24f7700",
Expand Down
4 changes: 3 additions & 1 deletion GPP/cpp/GPP_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ class GPP_base : public ExecutableDevice_impl, protected ThreadedComponent
std::string os_version;
/// Property: hostName
std::string hostName;
// Property: docker_omniorb_cfg
std::string docker_omniorb_cfg;
/// Property: useScreen
bool useScreen;
bool useScreen;
/// Property: componentOutputLog
std::string componentOutputLog;
/// Property: mcastnicInterface
Expand Down
1 change: 1 addition & 0 deletions GPP/tests/.md5sums
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dbaf096c6b94ee57160c4c2e3f5abc26 test_GPP.py