MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / retrieve_config_path

Function retrieve_config_path

src/ovpn3cli/arghelpers.cpp:246–269  ·  view source on GitHub ↗

* Retrieve a configuration path based on a configuration name * * @param cmd std::string containing the command name to use in * case of errors * @param config_name std::string containing the configuration name to * look up * @param dbusconn (optional) DBus::Connection to reuse an existing * connection * * @return

Source from the content-addressed store, hash-verified

244 * paths were found.
245 */
246DBus::Object::Path retrieve_config_path(const std::string &cmd,
247 const std::string &config_name,
248 DBus::Connection::Ptr dbusconn)
249{
250 auto conn = (dbusconn
251 ? dbusconn
252 : DBus::Connection::Create(DBus::BusType::SYSTEM));
253 OpenVPN3ConfigurationProxy cfgmgr(conn,
254 Constants::GenPath("configuration"));
255
256 auto paths = cfgmgr.LookupConfigName(config_name);
257 if (0 == paths.size())
258 {
259 throw CommandException(cmd,
260 "No configuration profiles found");
261 }
262 else if (1 < paths.size())
263 {
264 throw CommandException(cmd,
265 "More than one configuration profile was "
266 "found with the given name");
267 }
268 return paths.at(0);
269}

Callers 5

cmd_session_startFunction · 0.85
cmd_config_removeFunction · 0.85
cmd_config_aclFunction · 0.85
cmd_config_manageFunction · 0.85
cmd_config_dumpFunction · 0.85

Calls 3

CommandExceptionClass · 0.85
sizeMethod · 0.80
LookupConfigNameMethod · 0.45

Tested by

no test coverage detected