{"action":"created","issue":{"url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/72","repository_url":"https://api.github.com/repos/ripienaar/mcollective-choria","labels_url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/72/comments","events_url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/72/events","html_url":"https://github.com/ripienaar/mcollective-choria/issues/72","id":195020360,"number":72,"title":"revisit 'mco rpc'","user":{"login":"ripienaar","id":82342,"avatar_url":"https://avatars.githubusercontent.com/u/82342?v=3","gravatar_id":"","url":"https://api.github.com/users/ripienaar","html_url":"https://github.com/ripienaar","followers_url":"https://api.github.com/users/ripienaar/followers","following_url":"https://api.github.com/users/ripienaar/following{/other_user}","gists_url":"https://api.github.com/users/ripienaar/gists{/gist_id}","starred_url":"https://api.github.com/users/ripienaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripienaar/subscriptions","organizations_url":"https://api.github.com/users/ripienaar/orgs","repos_url":"https://api.github.com/users/ripienaar/repos","events_url":"https://api.github.com/users/ripienaar/events{/privacy}","received_events_url":"https://api.github.com/users/ripienaar/received_events","type":"User","site_admin":false},"labels":[{"id":407693562,"url":"https://api.github.com/repos/ripienaar/mcollective-choria/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-12T16:31:51Z","updated_at":"2016-12-12T19:56:37Z","closed_at":null,"body":"The default `mco rpc` tool is a bit meh and probably contributes greatly to the difficulty in using mcollective.\r\n\r\nIt was written before DDLs even existed and was never revisited.\r\n\r\nThis should be revisited to focus more on the problem it should solve, towards that I have come to the following basic sketch:\r\n\r\nGoals:\r\n\r\n * Focus on what users will most often want to see by creating a dynamic interface\r\n * Rethink some of the user facing terminology, removes `RPC` in favor of `Request` etc\r\n * Gradually expose the complexity inherent in a generic RPC client rather than by default produce a wall of text\r\n * Have tab completion for every part of the cli, the `mco completion` can already do this \r\n * Use `$PAGER` for things like `--action-doc` if more than `$LINES` of output\r\n\r\nThere is one possibility I also want to explore and that is to make a more interactive client that asks you client using the `:prompt` defined in the DDL, you'd start it up like `choria puppet  --interactive` and it will start asking you questions via prompts, defaults etc and construct the request - and possibly show you what command would have produced the same outcome as a learning tool.  This way people with almost no experience can interactively learn the system\r\n\r\nSome future suggestions:\r\n\r\n * Make some file where you can specify on a per agent/action basis defaults you always wish to apply, like say `--batch` or `--noop` for the runonce agent or whatever via @trevor-vaughan \r\n\r\nThe code used to produce the output can be found here https://gist.github.com/ripienaar/f68d2a9031b35f9dc3d467c9d85886ee it just prints stuff doesnt actually make requests\r\n\r\n### Default action, show available agents\r\n```\r\n$ choria\r\nChoria client version x.x.x\r\n\r\nUsage: choria <agent> <action> [agent options] [request options]\r\n\r\nAvailable agents:\r\n\r\n  package        Install and uninstall software packages\r\n  puppet         Run Puppet agent, get its status, and enable/disable it\r\n  rpcutil        General helpful actions that expose stats and internals to SimpleRPC clients\r\n  service        Start and stop system services\r\n\r\nSee choria <agent> --help for details about the agent\r\n```\r\n\r\n### Per agent generated details\r\n```\r\n$ choria puppet\r\nPuppet agent version 1.11.1\r\n\r\nUsage: choria puppet <action> [agent options] [request options]\r\n\r\nRun Puppet agent, get its status, and enable/disable it\r\n\r\nAvailable actions:\r\n\r\n  disable                Disable the Puppet agent\r\n  enable                 Enable the Puppet agent\r\n  last_run_summary       Get the summary of the last Puppet run\r\n  resource               Evaluate Puppet RAL resources\r\n  runonce                Invoke a single Puppet run\r\n  status                 Get the current status of the Puppet agent\r\n\r\nSee choria puppet <action> --help for details about one of the actions\r\n```\r\n\r\n### Per action view\r\nHere we focus on showing the available inputs the action take and turn them into `--foo` style flags and show them as options.\r\n\r\nAll the old RPC noise is hidden by default under `--filter-help` and `--request-help`, an additional `--action-doc` exist to show the DDL produced doc for the action\r\n\r\nIdeally these options would show as much as possible from the DDL things like data type and default but we have limited screen real estate\r\n\r\n```\r\n$ choria puppet runonce --help\r\nPuppet agent version 1.11.1\r\n\r\nUsage: choria puppet runonce [agent options] [request options]\r\n\r\nRun Puppet agent, get its status, and enable/disable it\r\n\r\nOptions for the runonce action:\r\n\r\n    Use --action-doc to get details about these such as types, defaults and valid values\r\n\r\nOptional options:\r\n        --force                      Will force a run immediately else subject to default splay time\r\n        --server                     Address and port of the Puppet Master in server:port format\r\n        --tags                       Restrict the Puppet run to a comma list of tags\r\n        --noop                       Do a Puppet dry run\r\n        --splay                      Sleep for a period before initiating the run\r\n        --splaylimit                 Maximum amount of time to sleep before run\r\n        --environment                Which Puppet environment to run\r\n        --use_cached_catalog         Determine if to use the cached catalog or not\r\n\r\nAdditional help:\r\n        --action-doc                 View the documentation for the runonce action\r\n        --filter-help                Help on selecting which nodes to act on\r\n        --request-help               View a full set of request options\r\n```\r\n\r\n### Per action DDL doc\r\nThis needs some iteration it really is just to show the idea here:\r\n\r\n```\r\n$ choria puppet runonce --action-doc\r\nPuppet agent version 1.11.1\r\n\r\nDefinition of the runonce action\r\n\r\nAction inputs:\r\n\r\n  Optional options:\r\n    environment (String):\r\n      Description: Which Puppet environment to run\r\n           Prompt: Environment\r\n         Required: false\r\n          Default: nil\r\n       Max Length: 50\r\n       Validation: puppet_variable\r\n\r\n    force (Boolean):\r\n      Description: Will force a run immediately else subject to default splay time\r\n           Prompt: Force\r\n         Required: false\r\n          Default: nil\r\n       Max Length: 0\r\n       Validation: none\r\n\r\n  <snip>\r\n\r\n\r\n  Action outputs:\r\n\r\n    initiated_at:\r\n      Description: Timestamp of when the runonce command was issues\r\n       Display As: Initiated at\r\n          Default: 0\r\n\r\n    summary:\r\n      Description: Summary of command run\r\n       Display As: Summary\r\n          Default:\r\n```\r\n\r\n### Host filters help\r\n\r\nSupplying `--filter-help` will add just the filter options. For demo purposes this is just a copy/paste from `mco rpc` some refining will be needed to make this suck a bit less\r\n\r\n```\r\n$ choria puppet runonce --filter-help\r\nPuppet agent version 1.11.1\r\n\r\nUsage: choria puppet runonce [agent options] [request options]\r\n\r\nRun Puppet agent, get its status, and enable/disable it\r\n\r\nOptions for the runonce action:\r\n\r\n    Use --action-doc to get details about these such as types, defaults and valid values\r\n\r\nOptional options:\r\n        --force                      Will force a run immediately else subject to default splay time\r\n        --server                     Address and port of the Puppet Master in server:port format\r\n        --tags                       Restrict the Puppet run to a comma list of tags\r\n        --noop                       Do a Puppet dry run\r\n        --splay                      Sleep for a period before initiating the run\r\n        --splaylimit                 Maximum amount of time to sleep before run\r\n        --environment                Which Puppet environment to run\r\n        --use_cached_catalog         Determine if to use the cached catalog or not\r\n\r\nAdditional help:\r\n        --action-doc                 View the documentation for the runonce action\r\n        --filter-help                Help on selecting which nodes to act on\r\n        --request-help               View a full set of request options\r\n\r\nHost Filters:\r\n    -W, --with FILTER                Combined classes and facts filter\r\n    -S, --select FILTER              Compound filter combining facts and classes\r\n    -F, --wf, --with-fact fact=val   Match hosts with a certain fact\r\n    -C, --wc, --with-class CLASS     Match hosts with a certain config management class\r\n    -A, --wa, --with-agent AGENT     Match hosts with a certain agent\r\n    -I, --wi, --with-identity IDENT  Match hosts with a certain configured identity\r\n```\r\n\r\n### Full request help\r\nFor demo purposes this is just a copy/paste from `mco rpc` some refining will be needed to make this suck a bit less\r\n\r\n```\r\n$ choria puppet runonce --request-help\r\nPuppet agent version 1.11.1\r\n\r\nUsage: choria puppet runonce [agent options] [request options]\r\n\r\nRun Puppet agent, get its status, and enable/disable it\r\n\r\nOptions for the runonce action:\r\n\r\n    Use --action-doc to get details about these such as types, defaults and valid values\r\n\r\nOptional options:\r\n        --force                      Will force a run immediately else subject to default splay time\r\n        --server                     Address and port of the Puppet Master in server:port format\r\n        --tags                       Restrict the Puppet run to a comma list of tags\r\n        --noop                       Do a Puppet dry run\r\n        --splay                      Sleep for a period before initiating the run\r\n        --splaylimit                 Maximum amount of time to sleep before run\r\n        --environment                Which Puppet environment to run\r\n        --use_cached_catalog         Determine if to use the cached catalog or not\r\n\r\nAdditional help:\r\n        --action-doc                 View the documentation for the runonce action\r\n        --filter-help                Help on selecting which nodes to act on\r\n        --request-help               View a full set of request options\r\n\r\nRequest Modifiers:\r\n        --no-results, --nr           Do not process results, just send request\r\n        --np, --no-progress          Do not show the progress bar\r\n    -1, --one                        Send request to only one discovered nodes\r\n        --batch SIZE                 Do requests in batches\r\n        --batch-sleep SECONDS        Sleep time between batches\r\n        --limit-seed NUMBER          Seed value for deterministic random batching\r\n        --limit-nodes, --ln, --limit COUNT\r\n                                     Send request to only a subset of nodes, can be a percentage\r\n    -j, --json                       Produce JSON output\r\n        --display MODE               Influence how results are displayed. One of ok, all or failed\r\n    -c, --config FILE                Load configuration from file rather than default\r\n    -v, --verbose                    Be verbose\r\n\r\n    -T, --target COLLECTIVE          Target messages to a specific sub collective\r\n        --dt, --discovery-timeout SECONDS\r\n                                     Timeout for doing discovery\r\n    -t, --timeout SECONDS            Timeout for calling remote agents\r\n    -q, --quiet                      Do not be verbose\r\n        --ttl TTL                    Set the message validity period\r\n        --reply-to TARGET            Set a custom target for replies\r\n        --dm, --disc-method METHOD   Which discovery method to use\r\n        --do, --disc-option OPTION   Options to pass to the discovery method\r\n        --nodes FILE                 List of nodes to address\r\n        --publish_timeout TIMEOUT    Timeout for publishing requests to remote agents.\r\n        --threaded                   Start publishing requests and receiving responses in threaded mode.\r\n        --sort                       Sort the output of an request before processing.\r\n        --connection-timeout TIMEOUT Set the timeout for establishing a connection to the middleware\r\n```"},"comment":{"url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/comments/266535097","html_url":"https://github.com/ripienaar/mcollective-choria/issues/72#issuecomment-266535097","issue_url":"https://api.github.com/repos/ripienaar/mcollective-choria/issues/72","id":266535097,"user":{"login":"ripienaar","id":82342,"avatar_url":"https://avatars.githubusercontent.com/u/82342?v=3","gravatar_id":"","url":"https://api.github.com/users/ripienaar","html_url":"https://github.com/ripienaar","followers_url":"https://api.github.com/users/ripienaar/followers","following_url":"https://api.github.com/users/ripienaar/following{/other_user}","gists_url":"https://api.github.com/users/ripienaar/gists{/gist_id}","starred_url":"https://api.github.com/users/ripienaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripienaar/subscriptions","organizations_url":"https://api.github.com/users/ripienaar/orgs","repos_url":"https://api.github.com/users/ripienaar/repos","events_url":"https://api.github.com/users/ripienaar/events{/privacy}","received_events_url":"https://api.github.com/users/ripienaar/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T19:56:37Z","updated_at":"2016-12-12T19:56:37Z","body":"@binford2k well, it is pretty awful ... :) I could probably retain the exact same argument parsing on this as a backward option? \r\n\r\n"}}
{"actor":{"display_login":"ripienaar"}}