arc_weld 0.2.5 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8be92b6b4bc6671d3fad7ecbd85bdc9f416dca81
4
- data.tar.gz: 34fff3801941baa988e048d7a4ee67d3076dab92
3
+ metadata.gz: 185b20cf9daefae896f7e79f91a4e7dcc65433d9
4
+ data.tar.gz: 30e29565d435aacb40f9926f9250bf802d0cd807
5
5
  SHA512:
6
- metadata.gz: 0e72e252985832fab45a9d4005a1b9a0962ee36975d96ac075f80ab2427662f8047d098d2ce2a73ab1b4d37a929f058fe9361cbf0c7f36b506c5b54d477c3d89
7
- data.tar.gz: 8444e68093ca41fb9e69885a0c36d4c4ec0f31e836e9825331181ac455440324222702480c430807bc58e1814ab97cf38b5051c99c23d76c806194e3db54b94d
6
+ metadata.gz: fa66678d4b1d2fcea65c461cf0b97f670c4e0de2cb78fe2e42fa59f9e3be626b3c2a29e60b0d2bc7b434ba46f6c2d32baa8610abc4d5be755523494cbe05f3b1
7
+ data.tar.gz: 12c2ab85729ce8ed1c8931288bddb1274acbf0ac509a5f3401e346ba6e94655d63998bdefbf72cdcaab9844e5a14306ac434a650893802eb7d0c7b6d730dea7a
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source 'https://artifacts.ercot.com/mirrors/rubygems/'
2
+ #source 'https://rubygems.org'
2
3
 
3
4
  gemspec
data/lib/arc_weld/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'arc_weld'
2
2
  require 'arc_weld/cli/project'
3
3
  require 'arc_weld/cli/readers/relation_csv'
4
+ require 'arc_weld/cli/readers/relation_csv_category_uri'
4
5
  require 'arc_weld/cli/readers/resource_csv'
5
6
  require 'openssl'
6
7
  require 'json'
@@ -82,11 +82,11 @@ module ArcWeld
82
82
  relationships.each do |rel|
83
83
  klass = ArcWeld::Cli::RelationReaders.const_get(constantize(rel['driver']))
84
84
  rel_reader = klass.new(
85
- path: File.join(input_dir,rel['file']),
86
- relationship_type: rel['type'] )
87
- sources = resources[rel_reader.src_type]
88
- dests = resources[rel_reader.dst_type]
89
- rel_reader.relate(sources,dests)
85
+ path: File.join(input_dir,rel['file']),
86
+ relationship_type: rel['type']
87
+ )
88
+
89
+ rel_reader.relate(resources)
90
90
  end
91
91
  end
92
92
 
@@ -21,10 +21,19 @@ module ArcWeld
21
21
  self
22
22
  end
23
23
 
24
- def relate(sources,destinations)
24
+ def sources(inputs)
25
+ inputs[src_type]
26
+ end
27
+
28
+ def destinations(inputs)
29
+ inputs[dst_type]
30
+ end
31
+
32
+ def relate(inputs)
25
33
  csv.each do |selected_src, selected_dst|
26
- src_instance=sources.find {|s| s.send(src_select)==selected_src}
27
- dst_instance=destinations.find {|s| s.send(dst_select)==selected_dst}
34
+ src_instance=sources(inputs).find {|s| s.send(src_select) == selected_src }
35
+ dst_instance=destinations(inputs).find {|s| s.send(dst_select) == selected_dst}
36
+
28
37
  if (src_instance.nil? || dst_instance.nil?)
29
38
  STDERR.puts format('could not %s %s/%s',
30
39
  relationship_type,
@@ -0,0 +1,46 @@
1
+ module ArcWeld
2
+ module Cli
3
+ module RelationReaders
4
+ class CsvCategoryUri
5
+ include ArcWeld::Helpers
6
+ attr_accessor :path, :src_select, :src_class, :relationship_type
7
+
8
+ attr_accessor :inputs
9
+ attr_reader :csv, :keys, :src_type
10
+
11
+ def initialize(*args)
12
+ Hash[*args].each {|k,v| self.send(format('%s=',k),v)}
13
+ @csv = CSV.open(path)
14
+ @keys = csv.readline
15
+ @src_type, @src_select, *unused= keys.flat_map do |k|
16
+ k.split(':')
17
+ end
18
+ @src_class=ArcWeld.const_get(constantize(src_type))
19
+ self
20
+ end
21
+
22
+ def sources(inputs)
23
+ inputs[src_type]
24
+ end
25
+
26
+ def destinations(inputs)
27
+ []
28
+ end
29
+
30
+ def relate(inputs)
31
+ csv.each do |selected_src, category_uri|
32
+ src_instance=sources(inputs).find {|s| s.send(src_select)==selected_src}
33
+
34
+ if (src_instance.nil?)
35
+ STDERR.puts format('could not %s %s/%s',
36
+ relationship_type,
37
+ selected_src)
38
+ else
39
+ src_instance.send(relationship_type,category_uri)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -2,6 +2,14 @@ module ArcWeld
2
2
  module Relationships
3
3
  module InCategory
4
4
 
5
+ def add_category_uri(uri)
6
+ if (uri.match(%r{\A/All Asset Categories/}))
7
+ ref = ArcWeld::Reference.new(type: 'Group', uri: uri)
8
+ add_category(ref)
9
+ end # silent fail?
10
+
11
+ end
12
+
5
13
  def add_category(cat)
6
14
  unless in_category.include?(cat.ref)
7
15
  in_category << cat.ref
@@ -31,7 +31,14 @@ module ArcWeld
31
31
  end
32
32
 
33
33
  def parent_ref=(containing_group)
34
- @parent_ref = containing_group.ref
34
+ @parent_ref = containing_group.ref if containing_group.ref.type=='Group'
35
+ end
36
+
37
+ def parent_uri=(uri)
38
+ top_root = Regexp.new(format('\A%s',self.class.toplevel.uri))
39
+ if top_root.match(uri)
40
+ @parent_ref = ArcWeld::Reference.new(uri: uri)
41
+ end
35
42
  end
36
43
 
37
44
  def identity_hash
@@ -4,7 +4,7 @@ module ArcWeld
4
4
  include ArcWeld::Relationship
5
5
 
6
6
  resource_property :containedResourceType, :description, :memberReferencePage
7
- has_relationship :has_child, :in_category, :in_network, :has_customer, multiple: true
7
+ has_relationship :has_child, :in_category, :in_network, multiple: true
8
8
 
9
9
  def self.class_id
10
10
  fail TypeError, 'no group resource class_id'
@@ -0,0 +1,3 @@
1
+ customer:externalID,network:externalID
2
+ weld_customer_stage,weld_net_stage
3
+ weld_customer_decom,weld_net_decom
@@ -1,3 +1,4 @@
1
- group:externalID,asset_category:externalID
2
- weld_asset_root,weld_category_assets
3
- weld_zone_root,weld_category_zones
1
+ group:externalID,uri
2
+ weld_asset_root,/All Asset Categories/<%= @config[:name] -%> Categories/Welded Assets
3
+ weld_zone_root,/All Asset Categories/<%= @config[:name] -%> Categories/Welded Zones
4
+ weld_zone_root,/All Asset Categories/Site Asset Categories/Address Spaces/Protected
@@ -0,0 +1,2 @@
1
+ group:externalID,network:externalID
2
+ weld_zone_root,weld_net_stage
@@ -27,13 +27,18 @@
27
27
  },
28
28
  {
29
29
  "driver" : "csv",
30
- "type" : "add_category",
30
+ "type" : "add_network",
31
+ "file" : "zonegroup_networks.csv"
32
+ },
33
+ {
34
+ "driver" : "csv_category_uri",
35
+ "type" : "add_category_uri",
31
36
  "file" : "group_categories.csv"
32
37
  },
33
38
  {
34
39
  "driver" : "csv",
35
40
  "type" : "add_customer_resource",
36
- "file" : "customer_groups.csv"
41
+ "file" : "customer_networks.csv"
37
42
  }
38
43
  ]
39
44
  }
@@ -1,3 +1,3 @@
1
1
  module ArcWeld
2
- VERSION = '0.2.5'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arc_weld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Breed
@@ -203,6 +203,7 @@ files:
203
203
  - lib/arc_weld/cli.rb
204
204
  - lib/arc_weld/cli/project.rb
205
205
  - lib/arc_weld/cli/readers/relation_csv.rb
206
+ - lib/arc_weld/cli/readers/relation_csv_category_uri.rb
206
207
  - lib/arc_weld/cli/readers/resource_csv.rb
207
208
  - lib/arc_weld/helpers.rb
208
209
  - lib/arc_weld/reference.rb
@@ -226,16 +227,16 @@ files:
226
227
  - lib/arc_weld/resources/network.rb
227
228
  - lib/arc_weld/resources/zone.rb
228
229
  - lib/arc_weld/templates/project-csv/.gitignore.tt
229
- - lib/arc_weld/templates/project-csv/Gemfile.tt
230
230
  - lib/arc_weld/templates/project-csv/Thorfile.tt
231
231
  - lib/arc_weld/templates/project-csv/in/assets.csv.tt
232
232
  - lib/arc_weld/templates/project-csv/in/categories.csv.tt
233
- - lib/arc_weld/templates/project-csv/in/customer_groups.csv.tt
233
+ - lib/arc_weld/templates/project-csv/in/customer_networks.csv.tt
234
234
  - lib/arc_weld/templates/project-csv/in/customers.csv.tt
235
235
  - lib/arc_weld/templates/project-csv/in/group_categories.csv.tt
236
236
  - lib/arc_weld/templates/project-csv/in/locations.csv.tt
237
237
  - lib/arc_weld/templates/project-csv/in/networks.csv.tt
238
238
  - lib/arc_weld/templates/project-csv/in/zone_locations.csv.tt
239
+ - lib/arc_weld/templates/project-csv/in/zonegroup_networks.csv.tt
239
240
  - lib/arc_weld/templates/project-csv/in/zones.csv.tt
240
241
  - lib/arc_weld/templates/project-csv/lib/thor/README.txt.tt
241
242
  - lib/arc_weld/templates/project-csv/lib/thor/sample.thor.tt
@@ -261,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
262
  version: '0'
262
263
  requirements: []
263
264
  rubyforge_project:
264
- rubygems_version: 2.4.5.1
265
+ rubygems_version: 2.4.5
265
266
  signing_key:
266
267
  specification_version: 4
267
268
  summary: Toolkit for building ArcSight resources
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # add local gems here
@@ -1,3 +0,0 @@
1
- customer:externalID,group:ref_uri
2
- weld_customer_stage,/All Networks/ArcWeld
3
- weld_customer_stage,/All Zones/<%= @config[:name] %>