From 139c9c3aaec9dcc3bb53914b4eb18ff23949b4e2 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Fri, 5 Mar 2021 11:19:03 +0100 Subject: [PATCH] (misc) update ddls from go-choria Signed-off-by: R.I.Pienaar --- Rakefile | 15 +- lib/mcollective/agent/choria_util.ddl | 313 ++++++++++++++++--------- lib/mcollective/agent/choria_util.json | 102 +++++++- lib/mcollective/agent/rpcutil.json | 5 +- lib/mcollective/agent/scout.json | 242 +++++++++---------- 5 files changed, 429 insertions(+), 248 deletions(-) diff --git a/Rakefile b/Rakefile index 656bc529..c5526af5 100644 --- a/Rakefile +++ b/Rakefile @@ -19,13 +19,24 @@ desc "Update JSON DDL files" task :update_ddl do require "mcollective" - Dir.glob("lib/mcollective/agent/*.ddl") do |ddlfile| - next if ddlfile =~ /^choria_uril/ + ["choria_util", "rpcutil", "scout"].each do |ddl| + ["ddl", "json"].each do |ext| + fname = "%s.%s" % [ddl, ext] + outfile = File.join("lib/mcollective/agent", fname) + url = "https://raw.githubusercontent.com/choria-io/go-choria/master/providers/agent/mcorpc/ddl/agent/%s" % fname + + puts "Updating %s via %s" % [outfile, url] + system("curl -so %s %s" % [outfile, url]) + end + end + Dir.glob("lib/mcollective/agent/*.ddl") do |ddlfile| agent_dir = File.dirname(ddlfile) agent_name = File.basename(ddlfile, ".ddl") json_file = File.join(agent_dir, "%s.json" % agent_name) + next if agent_name =~ /^(choria_util|rpcutil|scout)/ + ddl = MCollective::DDL.new(agent_name, :agent, false) ddl.instance_eval(File.read(ddlfile)) diff --git a/lib/mcollective/agent/choria_util.ddl b/lib/mcollective/agent/choria_util.ddl index f578874f..0f36c95e 100644 --- a/lib/mcollective/agent/choria_util.ddl +++ b/lib/mcollective/agent/choria_util.ddl @@ -1,152 +1,251 @@ -metadata :name => "choria_util", - :description => "Choria Utilities", - :author => "R.I.Pienaar ", - :license => "Apache-2.0", - :version => "0.19.0", - :url => "https://choria.io", - :timeout => 2 +metadata :name => "choria_util", + :description => "Choria Utilities", + :author => "R.I.Pienaar ", + :license => "Apache-2.0", + :version => "0.19.0", + :url => "https://choria.io", + :timeout => 2 -requires :mcollective => "2.9.0" -action "machine_transition", :description => "Attempts to force a transition in a hosted Choria Autonomous Agent" do +action "info", :description => "Choria related information from the running Daemon and Middleware" do + display :failed + + + + output :choria_version, + :description => "Choria version", + :display_as => "Choria Version" + + output :client_flavour, + :description => "Middleware client gem flavour", + :display_as => "Middleware Client Flavour" + + output :client_options, + :description => "Active Middleware client gem options", + :display_as => "Middleware Client Options" + + output :client_stats, + :description => "Middleware client gem statistics", + :display_as => "Middleware Client Stats" + + output :client_version, + :description => "Middleware client library version", + :display_as => "Middleware Client Library Version" + + output :connected_server, + :description => "Connected middleware server", + :display_as => "Connected Broker" + + output :connector, + :description => "Connector plugin", + :display_as => "Connector" + + output :connector_tls, + :description => "If the connector is running with TLS security enabled", + :display_as => "Connector TLS" + + output :facter_command, + :description => "Command used for Facter", + :display_as => "Facter" + + output :facter_domain, + :description => "Facter domain", + :display_as => "Facter Domain" + + output :middleware_servers, + :description => "Middleware Servers configured or discovered", + :display_as => "Middleware" + + output :path, + :description => "Active OS PATH", + :display_as => "Path" + + output :secure_protocol, + :description => "If the protocol is running with PKI security enabled", + :display_as => "Protocol Secure" + + output :security, + :description => "Security Provider plugin", + :display_as => "Security Provider" + + output :srv_domain, + :description => "Configured SRV domain", + :display_as => "SRV Domain" + + output :using_srv, + :description => "Indicates if SRV records are considered", + :display_as => "SRV Used" + + summarize do + aggregate summary(:choria_version) + aggregate summary(:client_version) + aggregate summary(:client_flavour) + aggregate summary(:connected_server) + aggregate summary(:srv_domain) + aggregate summary(:using_srv) + aggregate summary(:secure_protocol) + aggregate summary(:connector_tls) + end +end + +action "machine_state", :description => "Retrieves the current state of a specific Choria Autonomous Agent" do + display :ok + input :instance, - :prompt => "Instance ID", + :prompt => "Instance ID", :description => "Machine Instance ID", - :type => :string, - :validation => '^.+-.+-.+-.+-.+$', - :maxlength => 36, - :optional => true + :type => :string, + :validation => '^.+-.+-.+-.+-.+$', + :maxlength => 36, + :optional => true - input :version, - :prompt => "Version", - :description => "Machine Version", - :type => :string, - :validation => '^\d+\.\d+\.\d+$', - :maxlength => 20, - :optional => true input :name, - :prompt => "Name", + :prompt => "Name", :description => "Machine Name", - :type => :string, - :validation => '^[a-zA-Z][a-zA-Z0-9_-]+', - :maxlength => 128, - :optional => true + :type => :string, + :validation => '^[a-zA-Z][a-zA-Z0-9_-]+', + :maxlength => 128, + :optional => true + input :path, - :prompt => "Path", + :prompt => "Path", :description => "Machine Path", - :type => :string, - :validation => '.+', - :maxlength => 512, - :optional => true + :type => :string, + :validation => '.+', + :maxlength => 512, + :optional => true - input :transition, - :prompt => "Transition Name", - :description => "The transition event to send to the machine", - :type => :string, - :validation => '^[a-zA-Z][a-zA-Z0-9_-]+$', - :maxlength => 128, - :optional => false - output :success, - :description => "Indicates if the transition was successfully accepted", - :display_as => "Accepted" + + + output :available_transitions, + :description => "The list of available transitions this autonomous agent can make", + :type => "array", + :display_as => "Available Transitions" + + output :current_state, + :description => "The Choria Scout specific state for Scout checks", + :display_as => "Scout State" + + output :id, + :description => "The unique running ID of the autonomous agent", + :type => "string", + :display_as => "ID" + + output :name, + :description => "The name of the autonomous agent", + :type => "string", + :display_as => "Name" + + output :path, + :description => "The location on disk where the autonomous agent is stored", + :type => "string", + :display_as => "Path" + + output :scout, + :description => "True when this autonomous agent represents a Choria Scout Check", + :type => "boolean", + :display_as => "Scout Check" + + output :start_time, + :description => "The time the autonomous agent was started in unix seconds", + :type => "string", + :display_as => "Started" + + output :state, + :description => "The current state the agent is in", + :type => "string", + :display_as => "State" + + output :version, + :description => "The version of the autonomous agent", + :type => "string", + :display_as => "Version" + + summarize do + aggregate summary(:state) + aggregate summary(:name) + aggregate summary(:version) + end end action "machine_states", :description => "States of the hosted Choria Autonomous Agents" do display :always - output :machine_names, - :description => "List of running machine names", - :display_as => "Machine Names" + output :machine_ids, :description => "List of running machine IDs", - :display_as => "Machine IDs" + :display_as => "Machine IDs" + + output :machine_names, + :description => "List of running machine names", + :display_as => "Machine Names" output :states, :description => "Hash map of machine statusses indexed by machine ID", - :display_as => "Machine States" + :display_as => "Machine States" summarize do aggregate summary(:machine_names) end end -action "info", :description => "Choria related information from the running Daemon and Middleware" do - output :security, - :description => "Security Provider plugin", - :display_as => "Security Provider" - - output :secure_protocol, - :description => "If the protocol is running with PKI security enabled", - :display_as => "Protocol Secure" - - output :connector, - :description => "Connector plugin", - :display_as => "Connector" +action "machine_transition", :description => "Attempts to force a transition in a hosted Choria Autonomous Agent" do + display :failed - output :connector_tls, - :description => "If the connector is running with TLS security enabled", - :display_as => "Connector TLS" + input :instance, + :prompt => "Instance ID", + :description => "Machine Instance ID", + :type => :string, + :validation => '^.+-.+-.+-.+-.+$', + :maxlength => 36, + :optional => true - output :path, - :description => "Active OS PATH", - :display_as => "Path" - output :choria_version, - :description => "Choria version", - :display_as => "Choria Version" + input :name, + :prompt => "Name", + :description => "Machine Name", + :type => :string, + :validation => '^[a-zA-Z][a-zA-Z0-9_-]+', + :maxlength => 128, + :optional => true - output :client_version, - :description => "Middleware client library version", - :display_as => "Middleware Client Library Version" - output :client_flavour, - :description => "Middleware client gem flavour", - :display_as => "Middleware Client Flavour" + input :path, + :prompt => "Path", + :description => "Machine Path", + :type => :string, + :validation => '.+', + :maxlength => 512, + :optional => true - output :client_options, - :description => "Active Middleware client gem options", - :display_as => "Middleware Client Options" - output :connected_server, - :description => "Connected middleware server", - :display_as => "Connected Broker" + input :transition, + :prompt => "Transition Name", + :description => "The transition event to send to the machine", + :type => :string, + :validation => '^[a-zA-Z][a-zA-Z0-9_-]+$', + :maxlength => 128, + :optional => false - output :client_stats, - :description => "Middleware client gem statistics", - :display_as => "Middleware Client Stats" - output :facter_domain, - :description => "Facter domain", - :display_as => "Facter Domain" + input :version, + :prompt => "Version", + :description => "Machine Version", + :type => :string, + :validation => '^\d+\.\d+\.\d+$', + :maxlength => 20, + :optional => true - output :facter_command, - :description => "Command used for Facter", - :display_as => "Facter" - output :srv_domain, - :description => "Configured SRV domain", - :display_as => "SRV Domain" - output :using_srv, - :description => "Indicates if SRV records are considered", - :display_as => "SRV Used" - output :middleware_servers, - :description => "Middleware Servers configured or discovered", - :display_as => "Middleware" + output :success, + :description => "Indicates if the transition was successfully accepted", + :display_as => "Accepted" - summarize do - aggregate summary(:choria_version) - aggregate summary(:client_version) - aggregate summary(:client_flavour) - aggregate summary(:connected_server) - aggregate summary(:srv_domain) - aggregate summary(:using_srv) - aggregate summary(:secure_protocol) - aggregate summary(:connector_tls) - end end + diff --git a/lib/mcollective/agent/choria_util.json b/lib/mcollective/agent/choria_util.json index 8162af4c..c7ae6624 100644 --- a/lib/mcollective/agent/choria_util.json +++ b/lib/mcollective/agent/choria_util.json @@ -149,6 +149,106 @@ } ] }, + { + "action": "machine_state", + "description": "Retrieves the current state of a specific Choria Autonomous Agent", + "display": "ok", + "input": { + "instance": { + "prompt": "Instance ID", + "description": "Machine Instance ID", + "type": "string", + "default": null, + "optional": true, + "validation": "^.+-.+-.+-.+-.+$", + "maxlength": 36 + }, + "name": { + "prompt": "Name", + "description": "Machine Name", + "type": "string", + "default": null, + "optional": true, + "validation": "^[a-zA-Z][a-zA-Z0-9_-]+", + "maxlength": 128 + }, + "path": { + "prompt": "Path", + "description": "Machine Path", + "type": "string", + "default": null, + "optional": true, + "validation": ".+", + "maxlength": 512 + } + }, + "aggregate": [ + { + "function": "summary", + "args": [ + "state" + ] + }, + { + "function": "summary", + "args": [ + "name" + ] + }, + { + "function": "summary", + "args": [ + "version" + ] + } + ], + "output": { + "name": { + "type": "string", + "description": "The name of the autonomous agent", + "display_as": "Name" + }, + "version": { + "type": "string", + "description": "The version of the autonomous agent", + "display_as": "Version" + }, + "state": { + "type": "string", + "description": "The current state the agent is in", + "display_as": "State" + }, + "path": { + "type": "string", + "description": "The location on disk where the autonomous agent is stored", + "display_as": "Path" + }, + "id": { + "type": "string", + "description": "The unique running ID of the autonomous agent", + "display_as": "ID" + }, + "start_time": { + "type": "string", + "description": "The time the autonomous agent was started in unix seconds", + "display_as": "Started" + }, + "available_transitions": { + "type": "array", + "description": "The list of available transitions this autonomous agent can make", + "display_as": "Available Transitions" + }, + "scout": { + "type": "boolean", + "description": "True when this autonomous agent represents a Choria Scout Check", + "display_as": "Scout Check" + }, + "current_state": { + "description": "The Choria Scout specific state for Scout checks", + "display_as": "Scout State" + } + } + }, { "action": "machine_states", "input": { @@ -241,4 +341,4 @@ "description": "Attempts to force a transition in a hosted Choria Autonomous Agent" } ] -} \ No newline at end of file +} diff --git a/lib/mcollective/agent/rpcutil.json b/lib/mcollective/agent/rpcutil.json index 6ed19bd6..c0ad2cb5 100644 --- a/lib/mcollective/agent/rpcutil.json +++ b/lib/mcollective/agent/rpcutil.json @@ -308,8 +308,7 @@ }, "machines": { "description": "Autonomous Agents", - "display_as": "Machines", - "default": null + "display_as": "Machines" } }, "display": "always", @@ -330,4 +329,4 @@ "description": "Responds to requests for PING with PONG" } ] -} \ No newline at end of file +} diff --git a/lib/mcollective/agent/scout.json b/lib/mcollective/agent/scout.json index fd62e2c1..165f8787 100644 --- a/lib/mcollective/agent/scout.json +++ b/lib/mcollective/agent/scout.json @@ -1,122 +1,58 @@ { "$schema": "https://choria.io/schemas/mcorpc/ddl/v1/agent.json", "metadata": { - "name": "scout", - "description": "Choria Scout Agent Management API", - "author": "R.I.Pienaar ", "license": "Apache-2.0", + "author": "R.I.Pienaar ", + "timeout": 5, + "name": "scout", "version": "0.0.1", "url": "https://choria.io", - "provider": "golang", - "timeout": 5 + "description": "Choria Scout Agent Management API", + "provider": "golang" }, "actions": [ { "action": "checks", - "input": { - }, + "display": "ok", + "description": "Obtain a list of checks and their current status", + "input": {}, "output": { "checks": { "description": "Details about each check", - "display_as": "Checks", - "default": null, - "type": "array" + "type": "array", + "display_as": "Checks" } - }, - "display": "ok", - "description": "Obtain a list of checks and their current status" + } }, { - "action": "goss_validate", + "action": "resume", "input": { - "file": { - "prompt": "Goss File", - "description": "Path to the Goss validation specification", - "type": "string", - "default": null, - "optional": false, - "validation": ".+", - "maxlength": 256 - }, - "vars": { - "prompt": "Vars File", - "description": "Path to a file to use as template variables", - "type": "string", - "default": null, - "optional": true, - "validation": ".+", - "maxlength": 256 + "checks": { + "prompt": "Checks", + "description": "Check to resume, empty means all", + "type": "array", + "optional": true } }, "output": { - "failures": { - "description": "The number of tests that failed", - "display_as": "Failed Tests", - "default": null, - "type": "integer" - }, - "results": { - "description": "The full test results", - "display_as": "Results", - "default": null, + "failed": { + "description": "List of checks that could not be resumed", + "display_as": "Failed", "type": "array" }, - "runtime": { - "description": "The time it took to run the tests, in seconds", - "display_as": "Runtime", - "default": null, - "type": "integer" - }, - "success": { - "description": "Indicates if the test passed", - "display_as": "Success", - "default": null, - "type": "string" - }, - "summary": { - "description": "A human friendly test result", - "display_as": "Summary", - "default": null, - "type": "string" + "transitioned": { + "description": "List of checks that were resumed", + "display_as": "Triggered", + "type": "array" }, - "tests": { - "description": "The number of tests that were run", - "display_as": "Tests", - "default": null, - "type": "integer" + "skipped": { + "description": "List of checks that was skipped", + "display_as": "Skipped", + "type": "array" } }, "display": "failed", - "description": "Performs a Goss validation using a specific file", - "aggregate": [ - { - "function": "summary", - "args": [ - "tests", - { - "format": "%s Test Cases on %d node(s)" - } - ] - }, - { - "function": "summary", - "args": [ - "failures", - { - "format": "%s Failed Cases on %d node(s)" - } - ] - }, - { - "function": "summary", - "args": [ - "success", - { - "format": "%s Passed Cases on %d node(s)" - } - ] - } - ] + "description": "Resume active checking of one or more checks" }, { "action": "maintenance", @@ -125,7 +61,6 @@ "prompt": "Checks", "description": "Check to pause, empty means all", "type": "array", - "default": null, "optional": true } }, @@ -133,19 +68,16 @@ "failed": { "description": "List of checks that could not be paused", "display_as": "Failed", - "default": null, - "type": "array" - }, - "skipped": { - "description": "List of checks that was skipped", - "display_as": "Skipped", - "default": null, "type": "array" }, "transitioned": { "description": "List of checks that were paused", "display_as": "Triggered", - "default": null, + "type": "array" + }, + "skipped": { + "description": "List of checks that was skipped", + "display_as": "Skipped", "type": "array" } }, @@ -153,38 +85,82 @@ "description": "Pause checking of one or more checks" }, { - "action": "resume", + "action": "goss_validate", + "description": "Performs a Goss validation using a specific file", + "display": "failed", + "aggregate": [ + { + "function": "summary", + "args": [ + "tests", + {"format": "%s Tests on %d node(s)"} + ] + }, + { + "function": "summary", + "args": [ + "failures", + {"format": "%s Failed test on %d node(s)"} + ] + }, + { + "function": "summary", + "args": [ + "success", + {"format": "%s Passed tests on %d node(s)"} + ] + } + ], "input": { - "checks": { - "prompt": "Checks", - "description": "Check to resume, empty means all", - "type": "array", - "default": null, + "file": { + "prompt": "Goss File", + "description": "Path to the Goss validation specification", + "type": "string", + "maxlength": 256, + "validation": ".+", + "optional": false + }, + "vars": { + "prompt": "Vars File", + "description": "Path to a file to use as template variables", + "type": "string", + "maxlength": 256, + "validation": ".+", "optional": true } }, "output": { - "failed": { - "description": "List of checks that could not be resumed", - "display_as": "Failed", - "default": null, - "type": "array" + "tests": { + "description": "The number of tests that were run", + "display_as": "Tests", + "type": "integer" }, - "skipped": { - "description": "List of checks that was skipped", - "display_as": "Skipped", - "default": null, - "type": "array" + "failures": { + "description": "The number of tests that failed", + "display_as": "Failed Tests", + "type": "integer" }, - "transitioned": { - "description": "List of checks that were resumed", - "display_as": "Triggered", - "default": null, + "runtime": { + "description": "The time it took to run the tests, in seconds", + "display_as": "Runtime", + "type": "integer" + }, + "success": { + "description": "Indicates if the test passed", + "display_as": "Success", + "type": "string" + }, + "summary": { + "description": "A human friendly test result", + "display_as": "Summary", + "type": "string" + }, + "results": { + "description": "The full test results", + "display_as": "Results", "type": "array" } - }, - "display": "failed", - "description": "Resume active checking of one or more checks" + } }, { "action": "trigger", @@ -193,7 +169,6 @@ "prompt": "Checks", "description": "Check to trigger, empty means all", "type": "array", - "default": null, "optional": true } }, @@ -201,19 +176,16 @@ "failed": { "description": "List of checks that could not be triggered", "display_as": "Failed", - "default": null, - "type": "array" - }, - "skipped": { - "description": "List of checks that was skipped", - "display_as": "Skipped", - "default": null, "type": "array" }, "transitioned": { "description": "List of checks that were triggered", "display_as": "Triggered", - "default": null, + "type": "array" + }, + "skipped": { + "description": "List of checks that was skipped", + "display_as": "Skipped", "type": "array" } }, @@ -221,4 +193,4 @@ "description": "Force an immediate check of one or more checks" } ] -} \ No newline at end of file +}