Uploaded image for project: 'WildFly Core'
  1. WildFly Core
  2. WFCORE-1471

CLI class is mixing commands and operations

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      Hide

      CommandContext cleanContext = null;
      try

      { cleanContext = CommandContextFactory.getInstance().newCommandContext(); }

      catch (CliInitializationException ex) {
      }
      try

      { CommandContext ctx = CommandContextFactory.getInstance().newCommandContext( new CommandContextConfiguration.Builder().setController(new URI("http-remoting", null, TestSuiteEnvironment.getServerAddress(), 745, null, null, null).toString()) .setUsername(null) .setPassword(null) .setClientBindAddress(null) .build()); ctx.connectController(); }

      catch (Exception ex)

      { System.err.println("OK GOT EXPECTED EXCEPTION"); }

      cleanContext.handle("embed-server --std-out=echo");
      try

      { ModelNode request = cleanContext.buildRequest("reload --admin-only=false"); ModelNode response = cleanContext.getModelControllerClient().execute(request); }

      catch (Exception e) {
      try

      { cleanContext.handle("reload --admin-only=false"); cleanContext.getExitCode(); }

      catch (Exception ex)

      { ex.printStackTrace(); }

      }
      try

      { CommandContext ctx2 = CommandContextFactory.getInstance().newCommandContext( new CommandContextConfiguration.Builder().setController(new URI("http-remoting", null, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), null, null, null).toString()) .setUsername(null) .setPassword(null) .setClientBindAddress(null) .build()); ctx2.connectController(); }

      catch (Exception ex)

      { System.err.println("NOT EXPECTED EXCEPTION!!!!!!!"); ex.printStackTrace(); }
      Show
      CommandContext cleanContext = null; try { cleanContext = CommandContextFactory.getInstance().newCommandContext(); } catch (CliInitializationException ex) { } try { CommandContext ctx = CommandContextFactory.getInstance().newCommandContext( new CommandContextConfiguration.Builder().setController(new URI("http-remoting", null, TestSuiteEnvironment.getServerAddress(), 745, null, null, null).toString()) .setUsername(null) .setPassword(null) .setClientBindAddress(null) .build()); ctx.connectController(); } catch (Exception ex) { System.err.println("OK GOT EXPECTED EXCEPTION"); } cleanContext.handle("embed-server --std-out=echo"); try { ModelNode request = cleanContext.buildRequest("reload --admin-only=false"); ModelNode response = cleanContext.getModelControllerClient().execute(request); } catch (Exception e) { try { cleanContext.handle("reload --admin-only=false"); cleanContext.getExitCode(); } catch (Exception ex) { ex.printStackTrace(); } } try { CommandContext ctx2 = CommandContextFactory.getInstance().newCommandContext( new CommandContextConfiguration.Builder().setController(new URI("http-remoting", null, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), null, null, null).toString()) .setUsername(null) .setPassword(null) .setClientBindAddress(null) .build()); ctx2.connectController(); } catch (Exception ex) { System.err.println("NOT EXPECTED EXCEPTION!!!!!!!"); ex.printStackTrace(); }

      Description

      CLI.cmd method logic is not in sync with the CLI syntax.
      A fallback is implemented in order to route requests to cx.handle only if ctx.buildRequest(cliCommand) is failing.
      For example this doesn't cope with reload vs :reload. In this case, buildRequest will succeed both for reload and :reload. CLI.cmd("reload") will end to be treated as CLI.cmd(":reload");

      Furthermore batch and workflow are not supported by CLI.

      I am suggesting to implement the following logic:
      1) If batch is enabled or a workflow is enabled, route the command to handle
      2) Parse the request.
      3) If this is an operation, route to execute
      4) Otherwise route to handle

        Attachments

          Activity

            People

            Assignee:
            jdenise Jean Francois Denise
            Reporter:
            jdenise Jean Francois Denise
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: