Skip to content

Commit

Permalink
(misc) update ddls from go-choria
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <[email protected]>
  • Loading branch information
ripienaar committed Mar 5, 2021
1 parent db4982f commit 139c9c3
Show file tree
Hide file tree
Showing 5 changed files with 429 additions and 248 deletions.
15 changes: 13 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
313 changes: 206 additions & 107 deletions lib/mcollective/agent/choria_util.ddl
Original file line number Diff line number Diff line change
@@ -1,152 +1,251 @@
metadata :name => "choria_util",
:description => "Choria Utilities",
:author => "R.I.Pienaar <[email protected]>",
: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 <[email protected]>",
: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

Loading

0 comments on commit 139c9c3

Please sign in to comment.