dtk-node-agent 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/README.md +21 -4
- data/bin/dtk-node-agent +17 -0
- data/lib/config/install.config +2 -2
- data/lib/dtk-node-agent/installer.rb +30 -25
- data/lib/dtk-node-agent/version.rb +18 -1
- metadata +23 -110
- data/mcollective_additions/debian.mcollective.init +0 -92
- data/mcollective_additions/plugins/README.md +0 -1
- data/mcollective_additions/plugins/v1.2/agent/discovery.rb +0 -39
- data/mcollective_additions/plugins/v1.2/agent/get_log_fragment.ddl +0 -15
- data/mcollective_additions/plugins/v1.2/agent/get_log_fragment.rb +0 -79
- data/mcollective_additions/plugins/v1.2/agent/git_access.ddl +0 -9
- data/mcollective_additions/plugins/v1.2/agent/git_access.rb +0 -79
- data/mcollective_additions/plugins/v1.2/agent/netstat.ddl +0 -9
- data/mcollective_additions/plugins/v1.2/agent/netstat.rb +0 -34
- data/mcollective_additions/plugins/v1.2/agent/puppet_apply.ddl +0 -9
- data/mcollective_additions/plugins/v1.2/agent/puppet_apply.rb +0 -630
- data/mcollective_additions/plugins/v1.2/agent/rpcutil.ddl +0 -204
- data/mcollective_additions/plugins/v1.2/agent/rpcutil.rb +0 -101
- data/mcollective_additions/plugins/v1.2/facts/pbuilder_facts.rb +0 -35
- data/mcollective_additions/plugins/v2.2/agent/action_agent.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/action_agent.rb +0 -47
- data/mcollective_additions/plugins/v2.2/agent/dev_manager.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/dev_manager.rb +0 -111
- data/mcollective_additions/plugins/v2.2/agent/discovery.rb +0 -39
- data/mcollective_additions/plugins/v2.2/agent/dtk_node_agent_git_client.rb +0 -94
- data/mcollective_additions/plugins/v2.2/agent/execute_tests.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/execute_tests.rb +0 -111
- data/mcollective_additions/plugins/v2.2/agent/execute_tests_v2.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/execute_tests_v2.rb +0 -131
- data/mcollective_additions/plugins/v2.2/agent/get_log_fragment.ddl +0 -15
- data/mcollective_additions/plugins/v2.2/agent/get_log_fragment.rb +0 -79
- data/mcollective_additions/plugins/v2.2/agent/git_access.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/git_access.rb +0 -61
- data/mcollective_additions/plugins/v2.2/agent/netstat.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/netstat.rb +0 -34
- data/mcollective_additions/plugins/v2.2/agent/ps.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/ps.rb +0 -37
- data/mcollective_additions/plugins/v2.2/agent/puppet_apply.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/agent/puppet_apply.rb +0 -818
- data/mcollective_additions/plugins/v2.2/agent/puppet_cancel.ddl +0 -10
- data/mcollective_additions/plugins/v2.2/agent/puppet_cancel.rb +0 -78
- data/mcollective_additions/plugins/v2.2/agent/rpcutil.ddl +0 -204
- data/mcollective_additions/plugins/v2.2/agent/rpcutil.rb +0 -101
- data/mcollective_additions/plugins/v2.2/agent/ssh_agent.ddl +0 -13
- data/mcollective_additions/plugins/v2.2/agent/ssh_agent.rb +0 -97
- data/mcollective_additions/plugins/v2.2/agent/sync_agent_code.ddl +0 -10
- data/mcollective_additions/plugins/v2.2/agent/sync_agent_code.rb +0 -85
- data/mcollective_additions/plugins/v2.2/agent/tail.ddl +0 -11
- data/mcollective_additions/plugins/v2.2/agent/tail.rb +0 -67
- data/mcollective_additions/plugins/v2.2/audit/logfile.rb +0 -26
- data/mcollective_additions/plugins/v2.2/connector/r8stomp.rb +0 -238
- data/mcollective_additions/plugins/v2.2/connector/stomp.rb +0 -349
- data/mcollective_additions/plugins/v2.2/connector/stomp_em.rb +0 -191
- data/mcollective_additions/plugins/v2.2/data/agent_data.ddl +0 -22
- data/mcollective_additions/plugins/v2.2/data/agent_data.rb +0 -17
- data/mcollective_additions/plugins/v2.2/data/collective_data.ddl +0 -20
- data/mcollective_additions/plugins/v2.2/data/collective_data.rb +0 -9
- data/mcollective_additions/plugins/v2.2/data/fact_data.ddl +0 -28
- data/mcollective_additions/plugins/v2.2/data/fact_data.rb +0 -55
- data/mcollective_additions/plugins/v2.2/data/fstat_data.ddl +0 -89
- data/mcollective_additions/plugins/v2.2/data/fstat_data.rb +0 -56
- data/mcollective_additions/plugins/v2.2/discovery/flatfile.ddl +0 -11
- data/mcollective_additions/plugins/v2.2/discovery/flatfile.rb +0 -48
- data/mcollective_additions/plugins/v2.2/discovery/mc.ddl +0 -11
- data/mcollective_additions/plugins/v2.2/discovery/mc.rb +0 -30
- data/mcollective_additions/plugins/v2.2/discovery/stdin.ddl +0 -11
- data/mcollective_additions/plugins/v2.2/discovery/stdin.rb +0 -66
- data/mcollective_additions/plugins/v2.2/facts/pbuilder_facts.rb +0 -37
- data/mcollective_additions/plugins/v2.2/facts/yaml_facts.rb +0 -61
- data/mcollective_additions/plugins/v2.2/registration/agentlist.rb +0 -10
- data/mcollective_additions/plugins/v2.2/security/sshkey.ddl +0 -9
- data/mcollective_additions/plugins/v2.2/security/sshkey.rb +0 -362
- data/mcollective_additions/plugins/v2.2/util/puppetrunner.rb +0 -36
- data/mcollective_additions/plugins/v2.2/validator/array_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/array_validator.rb +0 -9
- data/mcollective_additions/plugins/v2.2/validator/ipv4address_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/ipv4address_validator.rb +0 -16
- data/mcollective_additions/plugins/v2.2/validator/ipv6address_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/ipv6address_validator.rb +0 -16
- data/mcollective_additions/plugins/v2.2/validator/length_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/length_validator.rb +0 -11
- data/mcollective_additions/plugins/v2.2/validator/regex_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/regex_validator.rb +0 -9
- data/mcollective_additions/plugins/v2.2/validator/shellsafe_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/shellsafe_validator.rb +0 -13
- data/mcollective_additions/plugins/v2.2/validator/typecheck_validator.ddl +0 -7
- data/mcollective_additions/plugins/v2.2/validator/typecheck_validator.rb +0 -28
- data/mcollective_additions/redhat.mcollective.init +0 -139
- data/mcollective_additions/redhat.mcollective.service +0 -14
- data/mcollective_additions/server.cfg +0 -22
- data/src/etc/logrotate.d/mcollective +0 -10
- data/src/etc/mcollective.default +0 -6
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
require 'eventmachine'
|
|
2
|
-
module MCollective
|
|
3
|
-
module Connector
|
|
4
|
-
# Handles sending and receiving messages over the Stomp protocol
|
|
5
|
-
#
|
|
6
|
-
# This plugin supports version 1.1 or 1.1.6 and newer of the Stomp rubygem
|
|
7
|
-
# the versions between those had multi threading issues.
|
|
8
|
-
#
|
|
9
|
-
# For all versions you can configure it as follows:
|
|
10
|
-
#
|
|
11
|
-
# connector = stomp
|
|
12
|
-
# plugin.stomp.host = stomp.your.net
|
|
13
|
-
# plugin.stomp.port = 6163
|
|
14
|
-
# plugin.stomp.user = you
|
|
15
|
-
# plugin.stomp.password = secret
|
|
16
|
-
#
|
|
17
|
-
# For versions of ActiveMQ that supports message priorities
|
|
18
|
-
# you can set a priority, this will cause a "priority" header
|
|
19
|
-
# to be emitted if present:
|
|
20
|
-
#
|
|
21
|
-
# plugin.stomp.priority = 4
|
|
22
|
-
#
|
|
23
|
-
class Stomp_em<Base
|
|
24
|
-
#this is effectively a singleton, but not mixin in Singleton beacuse mcollective isstantiates with new
|
|
25
|
-
#TODO: may look at making singleton and patching with making :new public, recognizing that will only be called once
|
|
26
|
-
|
|
27
|
-
module StompClient
|
|
28
|
-
include EM::Protocols::Stomp
|
|
29
|
-
def initialize(*args)
|
|
30
|
-
super(*args)
|
|
31
|
-
#TODO: if cannot fidn user and log this shoudl be error
|
|
32
|
-
conn_opts = (args.last.kind_of?(Hash))? args.last : {}
|
|
33
|
-
@login = conn_opts[:login]
|
|
34
|
-
@passcode = conn_opts[:passcode]
|
|
35
|
-
@connected = false
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def connection_completed
|
|
39
|
-
connect :login => @login, :passcode => @passcode
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def receive_msg msg
|
|
43
|
-
if msg.command == "CONNECTED"
|
|
44
|
-
pp [:is_connected]
|
|
45
|
-
@connected = true
|
|
46
|
-
else
|
|
47
|
-
Stomp_em.process(msg)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def is_connected?()
|
|
52
|
-
@connected
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def initialize
|
|
57
|
-
@config = Config.instance
|
|
58
|
-
@subscriptions = []
|
|
59
|
-
@connected = nil
|
|
60
|
-
@connection = nil
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def set_context(context)
|
|
64
|
-
@@decode_context = context[:decode_context]
|
|
65
|
-
@@multiplexer = context[:multiplexer]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def disconnect
|
|
69
|
-
#TODO: need to write
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Connects to the Stomp middleware
|
|
73
|
-
def connect
|
|
74
|
-
if @connection
|
|
75
|
-
Log.debug("Already connection, not re-initializing connection")
|
|
76
|
-
return
|
|
77
|
-
end
|
|
78
|
-
begin
|
|
79
|
-
host = nil
|
|
80
|
-
port = nil
|
|
81
|
-
user = nil
|
|
82
|
-
password = nil
|
|
83
|
-
@@base64 = false
|
|
84
|
-
|
|
85
|
-
@@base64 = get_bool_option("stomp.base64", false)
|
|
86
|
-
@@msgpriority = get_option("stomp.priority", 0).to_i
|
|
87
|
-
|
|
88
|
-
# Maintain backward compat for older stomps
|
|
89
|
-
host = get_env_or_option("STOMP_SERVER", "stomp.host")
|
|
90
|
-
port = get_env_or_option("STOMP_PORT", "stomp.port", 6163).to_i
|
|
91
|
-
user = get_env_or_option("STOMP_USER", "stomp.user")
|
|
92
|
-
password = get_env_or_option("STOMP_PASSWORD", "stomp.password")
|
|
93
|
-
|
|
94
|
-
#TODO: assume reactor is running already
|
|
95
|
-
@connection = EM.connect host, port, StompClient, :login => user, :passcode => password
|
|
96
|
-
Log.debug("Connecting to #{host}:#{port}")
|
|
97
|
-
rescue Exception => e
|
|
98
|
-
pp e.backtrace[0..5]
|
|
99
|
-
raise("Could not connect to Stomp Server: #{e}")
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def wait_until_connected?
|
|
104
|
-
return if @connected
|
|
105
|
-
loop do
|
|
106
|
-
return if @connected = @connection.is_connected?
|
|
107
|
-
sleep 1
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def self.process(msg)
|
|
113
|
-
# STOMP puts the payload in the body variable, pass that
|
|
114
|
-
# into the payload of MCollective::Request and discard all the
|
|
115
|
-
# other headers etc that stomp provides
|
|
116
|
-
raw_msg =
|
|
117
|
-
if @@base64
|
|
118
|
-
Request.new(SSL.base64_decode(msg.body))
|
|
119
|
-
else
|
|
120
|
-
Request.new(msg.body)
|
|
121
|
-
end
|
|
122
|
-
msg = @@decode_context.r8_decode_receive(raw_msg)
|
|
123
|
-
@@multiplexer.process_response(msg,msg[:requestid])
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
#TODO: make automic subscribe_and_send because need subscribe to happen before send does
|
|
127
|
-
# Subscribe to a topic or queue
|
|
128
|
-
def subscribe(source)
|
|
129
|
-
unless @subscriptions.include?(source)
|
|
130
|
-
EM::defer do
|
|
131
|
-
Log.debug("Subscribing to #{source}")
|
|
132
|
-
wait_until_connected?
|
|
133
|
-
@connection.subscribe(source)
|
|
134
|
-
@subscriptions << source
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
def subscribe_and_send(source,destination,body,params={})
|
|
139
|
-
EM::defer do
|
|
140
|
-
wait_until_connected?
|
|
141
|
-
unless @subscriptions.include?(source)
|
|
142
|
-
Log.debug("Subscribing to #{source}")
|
|
143
|
-
@connection.subscribe(source)
|
|
144
|
-
@subscriptions << source
|
|
145
|
-
end
|
|
146
|
-
@connection.send(destination,body,params)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
# Subscribe to a topic or queue
|
|
151
|
-
def unsubscribe(source)
|
|
152
|
-
#TODO
|
|
153
|
-
end
|
|
154
|
-
private
|
|
155
|
-
def get_env_or_option(env, opt, default=nil)
|
|
156
|
-
return ENV[env] if ENV.include?(env)
|
|
157
|
-
return @config.pluginconf[opt] if @config.pluginconf.include?(opt)
|
|
158
|
-
return default if default
|
|
159
|
-
|
|
160
|
-
raise("No #{env} environment or plugin.#{opt} configuration option given")
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
# looks for a config option, accepts an optional default
|
|
164
|
-
#
|
|
165
|
-
# raises an exception when it cant find a value anywhere
|
|
166
|
-
def get_option(opt, default=nil)
|
|
167
|
-
return @config.pluginconf[opt] if @config.pluginconf.include?(opt)
|
|
168
|
-
return default if default
|
|
169
|
-
|
|
170
|
-
raise("No plugin.#{opt} configuration option given")
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# gets a boolean option from the config, supports y/n/true/false/1/0
|
|
174
|
-
def get_bool_option(opt, default)
|
|
175
|
-
return default unless @config.pluginconf.include?(opt)
|
|
176
|
-
|
|
177
|
-
val = @config.pluginconf[opt]
|
|
178
|
-
|
|
179
|
-
if val =~ /^1|yes|true/
|
|
180
|
-
return true
|
|
181
|
-
elsif val =~ /^0|no|false/
|
|
182
|
-
return false
|
|
183
|
-
else
|
|
184
|
-
return default
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# vi:tabstop=4:expandtab:ai
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
metadata :name => "Agent",
|
|
2
|
-
:description => "Meta data about installed MColletive Agents",
|
|
3
|
-
:author => "R.I.Pienaar <rip@devco.net>",
|
|
4
|
-
:license => "ASL 2.0",
|
|
5
|
-
:version => "1.0",
|
|
6
|
-
:url => "http://marionette-collective.org/",
|
|
7
|
-
:timeout => 1
|
|
8
|
-
|
|
9
|
-
dataquery :description => "Agent Meta Data" do
|
|
10
|
-
input :query,
|
|
11
|
-
:prompt => "Agent Name",
|
|
12
|
-
:description => "Valid agent name",
|
|
13
|
-
:type => :string,
|
|
14
|
-
:validation => /^[\w\_]+$/,
|
|
15
|
-
:maxlength => 20
|
|
16
|
-
|
|
17
|
-
[:license, :timeout, :description, :url, :version, :author].each do |item|
|
|
18
|
-
output item,
|
|
19
|
-
:description => "Agent #{item}",
|
|
20
|
-
:display_as => item.to_s.capitalize
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module MCollective
|
|
2
|
-
module Data
|
|
3
|
-
class Agent_data<Base
|
|
4
|
-
query do |plugin|
|
|
5
|
-
raise "No agent called #{plugin} found" unless PluginManager.include?("#{plugin}_agent")
|
|
6
|
-
|
|
7
|
-
agent = PluginManager["#{plugin}_agent"]
|
|
8
|
-
|
|
9
|
-
result[:agent] = plugin
|
|
10
|
-
|
|
11
|
-
[:license, :timeout, :description, :url, :version, :author].each do |item|
|
|
12
|
-
result[item] = agent.meta[item]
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
metadata :name => "Collective",
|
|
2
|
-
:description => "Collective membership",
|
|
3
|
-
:author => "Puppet Labs",
|
|
4
|
-
:license => "ASL 2.0",
|
|
5
|
-
:version => "1.0",
|
|
6
|
-
:url => "http://marionette-collective.org/",
|
|
7
|
-
:timeout => 1
|
|
8
|
-
|
|
9
|
-
dataquery :description => "Collective" do
|
|
10
|
-
input :query,
|
|
11
|
-
:prompt => 'Collective',
|
|
12
|
-
:description => 'Collective name to ask about, eg mcollective',
|
|
13
|
-
:type => :string,
|
|
14
|
-
:validation => /./,
|
|
15
|
-
:maxlength => 256
|
|
16
|
-
|
|
17
|
-
output :member,
|
|
18
|
-
:description => 'Node is a member of the named collective',
|
|
19
|
-
:display_as => 'member'
|
|
20
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
metadata :name => "Fact",
|
|
2
|
-
:description => "Structured fact query",
|
|
3
|
-
:author => "Puppet Labs",
|
|
4
|
-
:license => "ASL 2.0",
|
|
5
|
-
:version => "1.0",
|
|
6
|
-
:url => "http://marionette-collective.org/",
|
|
7
|
-
:timeout => 1
|
|
8
|
-
|
|
9
|
-
dataquery :description => "Fact" do
|
|
10
|
-
input :query,
|
|
11
|
-
:prompt => 'Fact Path',
|
|
12
|
-
:description => 'Path to a fact, eg network.eth0.address',
|
|
13
|
-
:type => :string,
|
|
14
|
-
:validation => /./,
|
|
15
|
-
:maxlength => 256
|
|
16
|
-
|
|
17
|
-
output :exists,
|
|
18
|
-
:description => 'Fact is present',
|
|
19
|
-
:display_as => 'exists'
|
|
20
|
-
|
|
21
|
-
output :value,
|
|
22
|
-
:description => 'Fact value',
|
|
23
|
-
:display_as => 'value'
|
|
24
|
-
|
|
25
|
-
output :value_encoding,
|
|
26
|
-
:description => 'Encoding of the fact value (text/plain or application/json)',
|
|
27
|
-
:display_as => 'value_encoding'
|
|
28
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module MCollective
|
|
2
|
-
module Data
|
|
3
|
-
class Fact_data<Base
|
|
4
|
-
query do |path|
|
|
5
|
-
parts = path.split /\./
|
|
6
|
-
walk_path(parts)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
def walk_path(path)
|
|
12
|
-
# Set up results as though we didn't find the value
|
|
13
|
-
result[:exists] = false
|
|
14
|
-
result[:value] = false
|
|
15
|
-
result[:value_encoding] = false
|
|
16
|
-
|
|
17
|
-
facts = PluginManager['facts_plugin'].get_facts
|
|
18
|
-
|
|
19
|
-
path.each do |level|
|
|
20
|
-
case facts
|
|
21
|
-
when Array
|
|
22
|
-
level = Integer(level)
|
|
23
|
-
if level >= facts.size
|
|
24
|
-
# array index out would be out of bounds, so we don't have the value
|
|
25
|
-
return
|
|
26
|
-
end
|
|
27
|
-
when Hash
|
|
28
|
-
if !facts.include?(level)
|
|
29
|
-
# we don't have the key for the next level, so give up
|
|
30
|
-
return
|
|
31
|
-
end
|
|
32
|
-
else
|
|
33
|
-
# this isn't a container data type, so we can't walk into it
|
|
34
|
-
return
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
facts = facts[level]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
result[:exists] = true
|
|
41
|
-
case facts
|
|
42
|
-
when Array, Hash
|
|
43
|
-
# Currently data plugins cannot return structured data, so until
|
|
44
|
-
# this is fixed flatten the data with json and flag that we have
|
|
45
|
-
# munged the data
|
|
46
|
-
result[:value] = facts.to_json
|
|
47
|
-
result[:value_encoding] = 'application/json'
|
|
48
|
-
else
|
|
49
|
-
result[:value] = facts
|
|
50
|
-
result[:value_encoding] = 'text/plain'
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
metadata :name => "File Stat",
|
|
2
|
-
:description => "Retrieve file stat data for a given file",
|
|
3
|
-
:author => "R.I.Pienaar <rip@devco.net>",
|
|
4
|
-
:license => "ASL 2.0",
|
|
5
|
-
:version => "1.0",
|
|
6
|
-
:url => "http://marionette-collective.org/",
|
|
7
|
-
:timeout => 1
|
|
8
|
-
|
|
9
|
-
dataquery :description => "File stat information" do
|
|
10
|
-
input :query,
|
|
11
|
-
:prompt => "File Name",
|
|
12
|
-
:description => "Valid File Name",
|
|
13
|
-
:type => :string,
|
|
14
|
-
:validation => /.+/,
|
|
15
|
-
:maxlength => 120
|
|
16
|
-
|
|
17
|
-
output :name,
|
|
18
|
-
:description => "File name",
|
|
19
|
-
:display_as => "Name"
|
|
20
|
-
|
|
21
|
-
output :output,
|
|
22
|
-
:description => "Human readable information about the file",
|
|
23
|
-
:display_as => "Status"
|
|
24
|
-
|
|
25
|
-
output :present,
|
|
26
|
-
:description => "Indicates if the file exist using 0 or 1",
|
|
27
|
-
:display_as => "Present"
|
|
28
|
-
|
|
29
|
-
output :size,
|
|
30
|
-
:description => "File size",
|
|
31
|
-
:display_as => "Size"
|
|
32
|
-
|
|
33
|
-
output :mode,
|
|
34
|
-
:description => "File mode",
|
|
35
|
-
:display_as => "Mode"
|
|
36
|
-
|
|
37
|
-
output :md5,
|
|
38
|
-
:description => "File MD5 digest",
|
|
39
|
-
:display_as => "MD5"
|
|
40
|
-
|
|
41
|
-
output :mtime,
|
|
42
|
-
:description => "File modification time",
|
|
43
|
-
:display_as => "Modification time"
|
|
44
|
-
|
|
45
|
-
output :ctime,
|
|
46
|
-
:description => "File change time",
|
|
47
|
-
:display_as => "Change time"
|
|
48
|
-
|
|
49
|
-
output :atime,
|
|
50
|
-
:description => "File access time",
|
|
51
|
-
:display_as => "Access time"
|
|
52
|
-
|
|
53
|
-
output :mtime_seconds,
|
|
54
|
-
:description => "File modification time in seconds",
|
|
55
|
-
:display_as => "Modification time"
|
|
56
|
-
|
|
57
|
-
output :ctime_seconds,
|
|
58
|
-
:description => "File change time in seconds",
|
|
59
|
-
:display_as => "Change time"
|
|
60
|
-
|
|
61
|
-
output :atime_seconds,
|
|
62
|
-
:description => "File access time in seconds",
|
|
63
|
-
:display_as => "Access time"
|
|
64
|
-
|
|
65
|
-
output :mtime_age,
|
|
66
|
-
:description => "File modification age in seconds",
|
|
67
|
-
:display_as => "Modification age"
|
|
68
|
-
|
|
69
|
-
output :ctime_age,
|
|
70
|
-
:description => "File change age in seconds",
|
|
71
|
-
:display_as => "Change age"
|
|
72
|
-
|
|
73
|
-
output :atime_age,
|
|
74
|
-
:description => "File access age in seconds",
|
|
75
|
-
:display_as => "Access age"
|
|
76
|
-
|
|
77
|
-
output :uid,
|
|
78
|
-
:description => "File owner",
|
|
79
|
-
:display_as => "Owner"
|
|
80
|
-
|
|
81
|
-
output :gid,
|
|
82
|
-
:description => "File group",
|
|
83
|
-
:display_as => "Group"
|
|
84
|
-
|
|
85
|
-
output :type,
|
|
86
|
-
:description => "File type",
|
|
87
|
-
:display_as => "Type"
|
|
88
|
-
end
|
|
89
|
-
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module MCollective
|
|
2
|
-
module Data
|
|
3
|
-
class Fstat_data<Base
|
|
4
|
-
query do |file|
|
|
5
|
-
result[:name] = file
|
|
6
|
-
result[:output] = "not present"
|
|
7
|
-
result[:type] = "unknown"
|
|
8
|
-
result[:mode] = "0000"
|
|
9
|
-
result[:present] = 0
|
|
10
|
-
result[:size] = 0
|
|
11
|
-
result[:mtime] = 0
|
|
12
|
-
result[:ctime] = 0
|
|
13
|
-
result[:atime] = 0
|
|
14
|
-
result[:mtime_seconds] = 0
|
|
15
|
-
result[:ctime_seconds] = 0
|
|
16
|
-
result[:atime_seconds] = 0
|
|
17
|
-
result[:md5] = 0
|
|
18
|
-
result[:uid] = 0
|
|
19
|
-
result[:gid] = 0
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if File.exists?(file)
|
|
23
|
-
result[:output] = "present"
|
|
24
|
-
result[:present] = 1
|
|
25
|
-
|
|
26
|
-
if File.symlink?(file)
|
|
27
|
-
stat = File.lstat(file)
|
|
28
|
-
else
|
|
29
|
-
stat = File.stat(file)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
[:size, :uid, :gid].each do |item|
|
|
33
|
-
result[item] = stat.send(item)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
[:mtime, :ctime, :atime].each do |item|
|
|
37
|
-
result[item] = stat.send(item).strftime("%F %T")
|
|
38
|
-
result["#{item}_seconds".to_sym] = stat.send(item).to_i
|
|
39
|
-
result["#{item}_age".to_sym] = Time.now.to_i - stat.send(item).to_i
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
result[:mode] = "%o" % [stat.mode]
|
|
43
|
-
result[:md5] = Digest::MD5.hexdigest(File.read(file)) if stat.file?
|
|
44
|
-
|
|
45
|
-
result[:type] = "directory" if stat.directory?
|
|
46
|
-
result[:type] = "file" if stat.file?
|
|
47
|
-
result[:type] = "symlink" if stat.symlink?
|
|
48
|
-
result[:type] = "socket" if stat.socket?
|
|
49
|
-
result[:type] = "chardev" if stat.chardev?
|
|
50
|
-
result[:type] = "blockdev" if stat.blockdev?
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|