@@ -68,8 +68,6 @@ ConvertCmd::ProcessRequest() noexcept
6868 ConfigSubcmd (convert.config (), reply, json);
6969 } else if (subcmd == eos::console::ConvertProto::kFile ) {
7070 FileSubcmd (convert.file (), reply, json);
71- } else if (subcmd == eos::console::ConvertProto::kRule ) {
72- RuleSubcmd (convert.rule (), reply, json);
7371 } else if (subcmd == eos::console::ConvertProto::kList ) {
7472 ListSubcmd (convert.list (), reply, json);
7573 } else if (subcmd == eos::console::ConvertProto::kClear ) {
@@ -302,97 +300,6 @@ void ConvertCmd::FileSubcmd(const eos::console::ConvertProto_FileProto& file,
302300 reply.set_std_out (out.str ());
303301}
304302
305- // ------------------------------------------------------------------------------
306- // Execute rule subcommand
307- // ------------------------------------------------------------------------------
308- void ConvertCmd::RuleSubcmd (const eos::console::ConvertProto_RuleProto& rule,
309- eos::console::ReplyProto& reply,
310- bool json)
311- {
312- using eos::common::LayoutId;
313- auto conversion = rule.conversion ();
314- XrdOucErrInfo errInfo;
315- std::ostringstream out;
316- std::ostringstream err;
317- std::string errmsg;
318- std::string path;
319- int retc = 0 ;
320- auto enforce_dir = XrdSfsFileExistence::XrdSfsFileExistIsDirectory;
321- path = PathFromIdentifierProto (rule.identifier (), errmsg);
322-
323- if (!path.length ()) {
324- reply.set_std_err (errmsg);
325- reply.set_retc (errno);
326- return ;
327- }
328-
329- if ((retc = CheckValidPath (path.c_str (), mVid , errmsg, enforce_dir))) {
330- reply.set_std_err (errmsg);
331- reply.set_retc (retc);
332- return ;
333- }
334-
335- if ((retc = CheckConversionProto (conversion, errmsg))) {
336- reply.set_std_err (errmsg);
337- reply.set_retc (retc);
338- return ;
339- }
340-
341- if (conversion.checksum ().empty ()) {
342- err << " error: no conversion checksum provided" ;
343- reply.set_std_err (err.str ());
344- reply.set_retc (EINVAL);
345- return ;
346- }
347-
348- // Handle space default scenario
349- std::string space = conversion.space ().empty () ?
350- " default.0" : conversion.space ();
351- // Handle checksum
352- LayoutId::eChecksum echecksum = static_cast <LayoutId::eChecksum>(
353- LayoutId::GetChecksumFromString (conversion.checksum ()));
354- // ------------------------------------------
355- // This part acts as a placeholder
356- // ------------------------------------------
357- // Build conversion rule
358- std::string conversion_rule = BuildConversionId (conversion.layout (), echecksum,
359- conversion.replica (), 0 , space,
360- conversion.placement ());
361- size_t pos = conversion_rule.find (" :" );
362-
363- if (pos != std::string::npos) {
364- conversion_rule.erase (0 , pos + 1 );
365- }
366-
367- // Set rule as extended attribute
368- eos_info (" msg=\" placing conversion rule\" path=%s conversion_rule=%s" ,
369- path.c_str (), conversion_rule.c_str ());
370-
371- if (gOFS ->_attr_set (path.c_str (), errInfo, mVid , 0 , " sys.eos.convert.rule" ,
372- conversion_rule.c_str ())) {
373- err << " error: could not set conversion rule '" << conversion_rule
374- << " ' on path '" << path << " ' -- emsg=" << errInfo.getErrText ();
375- reply.set_std_err (err.str ());
376- reply.set_retc (errInfo.getErrInfo ());
377- return ;
378- }
379-
380- if (json) {
381- Json::Value json;
382- json[" conversion_rule" ] = conversion_rule;
383- json[" path" ] = path;
384- Json::StreamWriterBuilder builder;
385- std::unique_ptr<Json::StreamWriter> jsonwriter (
386- builder.newStreamWriter ());
387- jsonwriter->write (json, &out);
388- } else {
389- out << " Set conversion rule '" << conversion_rule
390- << " ' on path '" << path << " '" ;
391- }
392-
393- reply.set_std_out (out.str ());
394- }
395-
396303// ------------------------------------------------------------------------------
397304// List jobs subcommand
398305// ------------------------------------------------------------------------------
0 commit comments