arc_weld 0.3.1 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/bin/weld +1 -1
- data/lib/arc_weld/cli/project.rb +14 -13
- data/lib/arc_weld/cli/readers/relation_csv.rb +7 -4
- data/lib/arc_weld/cli/readers/relation_csv_category_uri.rb +8 -4
- data/lib/arc_weld/version.rb +1 -1
- metadata +3 -5
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2277081def68f14e24ea8e16833d31d2e76f0859
|
4
|
+
data.tar.gz: 69b941694b14d6177b71a0505b1fccf9dc4cecfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 592531f511cffde34bea7c5e44e708f6b41f51f35a67abd12544dfc2552d49ade60f41a00b851b29099b6f1b64823f17856d295a8782ee0bf75234b2f7f71c67
|
7
|
+
data.tar.gz: 5ffcaba2a98a99596ec9b65a9583dc4ad68bbf8157e1f79fad3b3eaece44c5f353f7d6c02f35d9d501c69345ace178f508c994f4048158c7370156e0289cbd70
|
data/.gitignore
CHANGED
data/bin/weld
CHANGED
data/lib/arc_weld/cli/project.rb
CHANGED
@@ -14,19 +14,22 @@ module ArcWeld
|
|
14
14
|
ArcWeld.const_get(constantize(resource_type))
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
File.join(self.input_dir,
|
17
|
+
def input_file(filename)
|
18
|
+
File.join(self.input_dir, filename)
|
19
19
|
end
|
20
20
|
|
21
|
-
def resource_reader(resource_type)
|
21
|
+
def resource_reader(resource_type,filename)
|
22
22
|
klass = ArcWeld::Cli::ResourceReaders.const_get(constantize(resource_driver))
|
23
|
-
klass.new( path:
|
23
|
+
klass.new( path: input_file(filename),
|
24
24
|
target_class: resource_class_for(resource_type) )
|
25
25
|
end
|
26
26
|
|
27
27
|
def reader
|
28
28
|
@readers ||= Hash[
|
29
|
-
resource_inputs.
|
29
|
+
resource_inputs.map do |resource_type,*filenames|
|
30
|
+
resource_type_readers = filenames.flatten.map {|filename| resource_reader(resource_type,filename)}
|
31
|
+
[resource_type, resource_type_readers]
|
32
|
+
end
|
30
33
|
]
|
31
34
|
end
|
32
35
|
|
@@ -43,8 +46,8 @@ module ArcWeld
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def load_resources
|
46
|
-
reader.each do |type,
|
47
|
-
res=
|
49
|
+
reader.each do |type, type_readers|
|
50
|
+
res=type_readers.flat_map &:to_a
|
48
51
|
resources[type].push(*res)
|
49
52
|
end
|
50
53
|
end
|
@@ -91,21 +94,19 @@ module ArcWeld
|
|
91
94
|
end
|
92
95
|
|
93
96
|
def assign_resource_groups
|
94
|
-
resource_roots['zone'].add_children(*resources['zone'])
|
95
|
-
|
96
|
-
zone_assets
|
97
|
-
|
98
97
|
unzoned = resources['asset'].select {|a| a.in_zone.nil?}
|
99
98
|
resource_roots['asset'].add_children(*unzoned)
|
100
99
|
|
101
|
-
%w{ network customer location asset_category }.each do |type|
|
102
|
-
|
100
|
+
%w{ network customer location asset_category zone }.each do |type|
|
101
|
+
unrooted = resources[type].select {|instance| instance.parent_ref==instance.class.toplevel }
|
102
|
+
resource_roots[type].add_children(*unrooted)
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
def generate_archive
|
107
107
|
resource_roots
|
108
108
|
load_resources
|
109
|
+
zone_assets
|
109
110
|
assign_resource_groups
|
110
111
|
assign_model_relations
|
111
112
|
archive.add(*resources.values.flatten)
|
@@ -34,11 +34,14 @@ module ArcWeld
|
|
34
34
|
src_instance=sources(inputs).find {|s| s.send(src_select) == selected_src }
|
35
35
|
dst_instance=destinations(inputs).find {|s| s.send(dst_select) == selected_dst}
|
36
36
|
|
37
|
-
if
|
38
|
-
STDERR.puts format('could not %s %s
|
37
|
+
if src_instance.nil?
|
38
|
+
STDERR.puts format('could not %s from %s to %s (source resource not found)',
|
39
39
|
relationship_type,
|
40
|
-
selected_src,
|
41
|
-
|
40
|
+
selected_src, selected_dst)
|
41
|
+
elsif dst_instance.nil?
|
42
|
+
STDERR.puts format('could not %s from %s to %s (destination resource not found)',
|
43
|
+
relationship_type,
|
44
|
+
selected_src, selected_dst)
|
42
45
|
else
|
43
46
|
src_instance.send(relationship_type,dst_instance)
|
44
47
|
end
|
@@ -30,13 +30,17 @@ module ArcWeld
|
|
30
30
|
def relate(inputs)
|
31
31
|
csv.each do |selected_src, category_uri|
|
32
32
|
src_instance=sources(inputs).find {|s| s.send(src_select)==selected_src}
|
33
|
-
|
33
|
+
|
34
34
|
if (src_instance.nil?)
|
35
|
-
STDERR.puts format('could not %s %s
|
36
|
-
|
35
|
+
STDERR.puts format('could not add category uri %s to %s (resource nil)',
|
36
|
+
category_uri,
|
37
37
|
selected_src)
|
38
|
+
next
|
39
|
+
end
|
40
|
+
if ac_resource = inputs['asset_category'].find {|ac| ac.ref_uri==category_uri}
|
41
|
+
src_instance.add_category(ac_resource)
|
38
42
|
else
|
39
|
-
|
43
|
+
src_instance.send(relationship_type,category_uri)
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
data/lib/arc_weld/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arc_weld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Breed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gyoku
|
@@ -182,7 +182,6 @@ description: Toolkit for building ArcSight resources
|
|
182
182
|
email:
|
183
183
|
- opensource@breed.org
|
184
184
|
executables:
|
185
|
-
- setup
|
186
185
|
- weld
|
187
186
|
extensions: []
|
188
187
|
extra_rdoc_files: []
|
@@ -196,7 +195,6 @@ files:
|
|
196
195
|
- README.md
|
197
196
|
- Rakefile
|
198
197
|
- arc_weld.gemspec
|
199
|
-
- bin/setup
|
200
198
|
- bin/weld
|
201
199
|
- lib/arc_weld.rb
|
202
200
|
- lib/arc_weld/archive.rb
|
@@ -262,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
260
|
version: '0'
|
263
261
|
requirements: []
|
264
262
|
rubyforge_project:
|
265
|
-
rubygems_version: 2.4.5
|
263
|
+
rubygems_version: 2.4.5.1
|
266
264
|
signing_key:
|
267
265
|
specification_version: 4
|
268
266
|
summary: Toolkit for building ArcSight resources
|