octofacts-updater 0.5.0 → 0.5.1
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 +4 -4
- data/.version +1 -1
- data/lib/octofacts_updater/cli.rb +33 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b50c8a2fec8f9a4246634633180bf12276c66e
|
4
|
+
data.tar.gz: 41484ac0bc84813a554ff68c7e92ebee525756e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbd45aa3e9cb4d6e7e79e25dc85339887c3a6044d958ddc4e20fb8664310909c2be3d37e6a8315e15b80076779747d1f66a840d34178b23347839a2ee76ef345
|
7
|
+
data.tar.gz: f74a33d55190ff784ced6238717266ed6ff94c07a8f4e4bfa09e5c159f389b95ec56a2c28b4e6040c84eddb25c2914c4d0a99e893dcd330d4455b6df840ad704
|
data/.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -16,8 +16,8 @@ module OctofactsUpdater
|
|
16
16
|
end
|
17
17
|
|
18
18
|
opts.on("-c", "--config <config_file>", String, "Path to configuration file") do |f|
|
19
|
-
|
20
|
-
@opts[:config]
|
19
|
+
@opts[:config] = File.expand_path(f)
|
20
|
+
raise "Invalid configuration file #{@opts[:config].inspect}" unless File.file?(@opts[:config])
|
21
21
|
end
|
22
22
|
|
23
23
|
opts.on("-H", "--hostname <hostname>", String, "FQDN of the host whose facts are to be gathered") do |h|
|
@@ -67,11 +67,12 @@ module OctofactsUpdater
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def usage
|
70
|
-
puts "Usage: octofacts-updater --action <action> [--config
|
70
|
+
puts "Usage: octofacts-updater --action <action> [--config /path/to/config.yaml] [other options]"
|
71
71
|
puts ""
|
72
72
|
puts "Available actions:"
|
73
|
-
puts " bulk:
|
74
|
-
puts " facts:
|
73
|
+
puts " bulk: Update fixtures and index in bulk"
|
74
|
+
puts " facts: Obtain facts for one node (requires --hostname <hostname>)"
|
75
|
+
puts " reindex: Build a new index from the existing fact fixtures"
|
75
76
|
puts ""
|
76
77
|
end
|
77
78
|
|
@@ -106,6 +107,7 @@ module OctofactsUpdater
|
|
106
107
|
|
107
108
|
return handle_action_bulk if opts[:action] == "bulk"
|
108
109
|
return handle_action_facts if opts[:action] == "facts"
|
110
|
+
return handle_action_bulk if opts[:action] == "reindex"
|
109
111
|
|
110
112
|
usage
|
111
113
|
exit 255
|
@@ -126,19 +128,39 @@ module OctofactsUpdater
|
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
131
|
+
def nodes_for_bulk
|
132
|
+
if opts[:action] == "reindex"
|
133
|
+
@opts[:quick] = true
|
134
|
+
|
135
|
+
path = if opts[:path]
|
136
|
+
File.expand_path(opts[:path])
|
137
|
+
elsif @config.fetch("index", {})["node_path"]
|
138
|
+
File.expand_path(@config.fetch("index", {})["node_path"], File.dirname(opts[:config]))
|
139
|
+
else
|
140
|
+
raise ArgumentError, "Must set --path, or define index:node_path to a valid directory in configuration"
|
141
|
+
end
|
142
|
+
|
143
|
+
unless File.directory?(path)
|
144
|
+
raise Errno::ENOENT, "--path must be a directory (#{path.inspect} is not)"
|
145
|
+
end
|
134
146
|
|
135
|
-
|
147
|
+
Dir.glob("#{path}/*.yaml").map { |f| File.basename(f, ".yaml") }
|
148
|
+
elsif opts[:host_list]
|
136
149
|
opts[:host_list]
|
137
150
|
elsif opts[:hostname]
|
138
151
|
[opts[:hostname]]
|
139
152
|
else
|
140
153
|
OctofactsUpdater::FactIndex.load_file(index_file).nodes(true)
|
141
154
|
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def handle_action_bulk
|
158
|
+
facts_to_index = @config.fetch("index", {})["indexed_facts"]
|
159
|
+
unless facts_to_index.is_a?(Array)
|
160
|
+
raise ArgumentError, "Must declare index:indexed_facts in configuration to use bulk update"
|
161
|
+
end
|
162
|
+
|
163
|
+
nodes = nodes_for_bulk
|
142
164
|
if nodes.empty?
|
143
165
|
raise ArgumentError, "Cannot run bulk update with no nodes to check"
|
144
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octofacts-updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-10-
|
13
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: diffy
|