From a067694fcdd228cbb86486a5a6e395cd8421d2c1 Mon Sep 17 00:00:00 2001 From: "R.I.Pienaar" Date: Mon, 28 Dec 2020 16:07:57 +0100 Subject: [PATCH] (#87) update DDL files Signed-off-by: R.I.Pienaar --- Rakefile | 32 +++++++++++++++++ lib/mcollective/agent/choria_util.ddl | 4 +-- lib/mcollective/agent/choria_util.json | 4 +-- lib/mcollective/agent/choria_util.rb | 49 -------------------------- lib/mcollective/agent/rpcutil.ddl | 4 +-- lib/mcollective/agent/rpcutil.json | 4 +-- lib/mcollective/agent/scout.ddl | 4 +-- lib/mcollective/agent/scout.json | 4 +-- 8 files changed, 44 insertions(+), 61 deletions(-) delete mode 100644 lib/mcollective/agent/choria_util.rb diff --git a/Rakefile b/Rakefile index dee76f09..6b610422 100644 --- a/Rakefile +++ b/Rakefile @@ -31,3 +31,35 @@ task :test do sh "bundle exec rubocop --config .rubocop.yml lib" sh "bundle exec rspec" end + +desc "Update JSON DDL files" +task :update_ddl do + require "mcollective" + + Dir.glob("lib/mcollective/agent/*.ddl") do |ddlfile| + next if ddlfile =~ /^choria_uril/ + + agent_dir = File.dirname(ddlfile) + agent_name = File.basename(ddlfile, ".ddl") + json_file = File.join(agent_dir, "%s.json" % agent_name) + + ddl = MCollective::DDL.new(agent_name, :agent, false) + ddl.instance_eval(File.read(ddlfile)) + + data = { + "$schema" => "https://choria.io/schemas/mcorpc/ddl/v1/agent.json", + "metadata" => ddl.meta, + "actions" => [] + } + + ddl.actions.sort.each do |action| + data["actions"] << ddl.action_interface(action) + end + + puts "Writing JSON DDL in %s" % json_file + + File.open(json_file, "w") do |jddl| + jddl.print(JSON.pretty_generate(data)) + end + end +end diff --git a/lib/mcollective/agent/choria_util.ddl b/lib/mcollective/agent/choria_util.ddl index 2024ee18..f578874f 100644 --- a/lib/mcollective/agent/choria_util.ddl +++ b/lib/mcollective/agent/choria_util.ddl @@ -4,7 +4,7 @@ metadata :name => "choria_util", :license => "Apache-2.0", :version => "0.19.0", :url => "https://choria.io", - :timeout => 20 + :timeout => 2 requires :mcollective => "2.9.0" @@ -50,7 +50,7 @@ action "machine_transition", :description => "Attempts to force a transition in :optional => false output :success, - :description => "Indicates if the transition was succesfully accepted", + :description => "Indicates if the transition was successfully accepted", :display_as => "Accepted" end diff --git a/lib/mcollective/agent/choria_util.json b/lib/mcollective/agent/choria_util.json index 67078c5c..8162af4c 100644 --- a/lib/mcollective/agent/choria_util.json +++ b/lib/mcollective/agent/choria_util.json @@ -7,7 +7,7 @@ "license": "Apache-2.0", "version": "0.19.0", "url": "https://choria.io", - "timeout": 20 + "timeout": 2 }, "actions": [ { @@ -232,7 +232,7 @@ }, "output": { "success": { - "description": "Indicates if the transition was succesfully accepted", + "description": "Indicates if the transition was successfully accepted", "display_as": "Accepted", "default": null } diff --git a/lib/mcollective/agent/choria_util.rb b/lib/mcollective/agent/choria_util.rb deleted file mode 100644 index 76af3464..00000000 --- a/lib/mcollective/agent/choria_util.rb +++ /dev/null @@ -1,49 +0,0 @@ -module MCollective - module Agent - class Choria_util < RPC::Agent - action "machine_states" do - reply.fail!("Choria Autonomous Agents are not support on mcollectived based Choria Servers") - end - - action "machine_transtion" do - reply.fail!("Choria Autonomous Agents are not support on mcollectived based Choria Servers") - end - - action "info" do - connector = PluginManager["connector_plugin"] - - reply.fail!("Only support collectives using the Choria NATS connector") unless connector.is_a?(Connector::Nats) - - reply[:security] = config.securityprovider - reply[:connector] = config.connector - reply[:client_version] = connector.client_version - reply[:client_flavour] = connector.client_flavour - reply[:client_options] = stringify_keys(connector.active_options).reject {|k, _| k == "tls"} - reply[:client_stats] = stringify_keys(connector.stats) - reply[:facter_domain] = choria.facter_domain - reply[:facter_command] = choria.facter_cmd - reply[:srv_domain] = choria.srv_domain - reply[:using_srv] = choria.should_use_srv? - reply[:middleware_servers] = choria.middleware_servers.map {|s| s.join(":")} - reply[:path] = ENV.fetch("PATH", "") - reply[:choria_version] = "mcollective plugin %s" % Util::Choria::VERSION - reply[:secure_protocol] = !$choria_unsafe_disable_protocol_security # rubocop:disable Style/GlobalVars - reply[:connector_tls] = !$choria_unsafe_disable_nats_tls # rubocop:disable Style/GlobalVars - - if connector.connected? - reply[:connected_server] = "%s://%s:%s" % [connector.connected_server.scheme, connector.connected_server.host, connector.connected_server.port] - else - reply[:connected_server] = "disconnected" - end - end - - def stringify_keys(hash) - Hash[hash.map {|key, val| [key.to_s, val]}] - end - - def choria - @_choria ||= Util::Choria.new(false) - end - end - end -end diff --git a/lib/mcollective/agent/rpcutil.ddl b/lib/mcollective/agent/rpcutil.ddl index 01293b02..c4e5b520 100644 --- a/lib/mcollective/agent/rpcutil.ddl +++ b/lib/mcollective/agent/rpcutil.ddl @@ -3,8 +3,8 @@ metadata :name => "rpcutil", :author => "R.I.Pienaar ", :license => "Apache License, Version 2.0", :version => "0.19.0", - :url => "https://docs.puppetlabs.com/mcollective/", - :timeout => 10 + :url => "https://choria.io/", + :timeout => 2 action "collective_info", :description => "Info about the main and sub collectives" do display :always diff --git a/lib/mcollective/agent/rpcutil.json b/lib/mcollective/agent/rpcutil.json index 0ee8117e..09c87f0a 100644 --- a/lib/mcollective/agent/rpcutil.json +++ b/lib/mcollective/agent/rpcutil.json @@ -6,8 +6,8 @@ "author": "R.I.Pienaar ", "license": "Apache License, Version 2.0", "version": "0.19.0", - "url": "https://docs.puppetlabs.com/mcollective/", - "timeout": 10 + "url": "https://choria.io/", + "timeout": 2 }, "actions": [ { diff --git a/lib/mcollective/agent/scout.ddl b/lib/mcollective/agent/scout.ddl index 2493b01a..5b234db5 100644 --- a/lib/mcollective/agent/scout.ddl +++ b/lib/mcollective/agent/scout.ddl @@ -1,8 +1,8 @@ metadata :name => "scout", - :description => "Choria Scout Management API", + :description => "Choria Scout Agent Management API", :author => "R.I.Pienaar ", :license => "Apache-2.0", - :version => "0.19.0", + :version => "0.0.1", :url => "https://choria.io", :provider => "golang", :timeout => 5 diff --git a/lib/mcollective/agent/scout.json b/lib/mcollective/agent/scout.json index 9c7e5a8e..fd62e2c1 100644 --- a/lib/mcollective/agent/scout.json +++ b/lib/mcollective/agent/scout.json @@ -2,10 +2,10 @@ "$schema": "https://choria.io/schemas/mcorpc/ddl/v1/agent.json", "metadata": { "name": "scout", - "description": "Choria Scout Management API", + "description": "Choria Scout Agent Management API", "author": "R.I.Pienaar ", "license": "Apache-2.0", - "version": "0.19.0", + "version": "0.0.1", "url": "https://choria.io", "provider": "golang", "timeout": 5