arc_weld 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/Guardfile +58 -0
- data/LICENSE.txt +674 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/arc_weld.gemspec +34 -0
- data/bin/setup +7 -0
- data/bin/weld +8 -0
- data/lib/arc_weld/archive.rb +87 -0
- data/lib/arc_weld/cli/project.rb +116 -0
- data/lib/arc_weld/cli/readers/relation_csv.rb +41 -0
- data/lib/arc_weld/cli/readers/resource_csv.rb +64 -0
- data/lib/arc_weld/cli.rb +45 -0
- data/lib/arc_weld/helpers.rb +12 -0
- data/lib/arc_weld/reference.rb +51 -0
- data/lib/arc_weld/relationship.rb +96 -0
- data/lib/arc_weld/relationships/customer_of.rb +28 -0
- data/lib/arc_weld/relationships/has_alternate_interface.rb +27 -0
- data/lib/arc_weld/relationships/has_child.rb +42 -0
- data/lib/arc_weld/relationships/has_customer.rb +28 -0
- data/lib/arc_weld/relationships/has_location.rb +16 -0
- data/lib/arc_weld/relationships/in_category.rb +26 -0
- data/lib/arc_weld/relationships/in_network.rb +26 -0
- data/lib/arc_weld/relationships/in_zone.rb +41 -0
- data/lib/arc_weld/relationships/location_of.rb +28 -0
- data/lib/arc_weld/resource.rb +149 -0
- data/lib/arc_weld/resource_definitions.rb +7 -0
- data/lib/arc_weld/resources/asset.rb +33 -0
- data/lib/arc_weld/resources/asset_category.rb +40 -0
- data/lib/arc_weld/resources/customer.rb +16 -0
- data/lib/arc_weld/resources/group.rb +29 -0
- data/lib/arc_weld/resources/location.rb +18 -0
- data/lib/arc_weld/resources/network.rb +14 -0
- data/lib/arc_weld/resources/zone.rb +65 -0
- data/lib/arc_weld/templates/project-csv/.gitignore.tt +2 -0
- data/lib/arc_weld/templates/project-csv/Gemfile.tt +3 -0
- data/lib/arc_weld/templates/project-csv/Thorfile.tt +9 -0
- data/lib/arc_weld/templates/project-csv/in/assets.csv.tt +2 -0
- data/lib/arc_weld/templates/project-csv/in/categories.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/customer_groups.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/customers.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/group_categories.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/locations.csv.tt +6 -0
- data/lib/arc_weld/templates/project-csv/in/networks.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/zone_locations.csv.tt +2 -0
- data/lib/arc_weld/templates/project-csv/in/zones.csv.tt +2 -0
- data/lib/arc_weld/templates/project-csv/lib/thor/README.txt.tt +2 -0
- data/lib/arc_weld/templates/project-csv/lib/thor/sample.thor.tt +7 -0
- data/lib/arc_weld/templates/project-csv/out/README-archive.txt.tt +5 -0
- data/lib/arc_weld/templates/project-csv/weld.json.tt +39 -0
- data/lib/arc_weld/version.rb +3 -0
- data/lib/arc_weld.rb +19 -0
- metadata +269 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module HasAlternateInterface
|
4
|
+
def add_interfaces(*assets)
|
5
|
+
assets.each do |asset|
|
6
|
+
unless has_alternate_interface.include?(asset)
|
7
|
+
has_alternate_interface << asset
|
8
|
+
end
|
9
|
+
unless asset.has_alternate_interface.include?(self)
|
10
|
+
asset.has_alternate_interface << self
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def related_has_alternate_interface_references
|
15
|
+
(has_alternate_interface.map {|a| a.ref.render}).join
|
16
|
+
end
|
17
|
+
def has_alternate_interface_relationship
|
18
|
+
unless has_alternate_interface.empty?
|
19
|
+
{ 'hasAlternateInterface' => {
|
20
|
+
'list!' => related_has_alternate_interface_references},
|
21
|
+
'alternateInterfaceOf' => {
|
22
|
+
'list!' => related_has_alternate_interface_references} }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module HasChild
|
4
|
+
def related_has_child_references
|
5
|
+
has_child.map {|res| res.ref.render }.join
|
6
|
+
end
|
7
|
+
|
8
|
+
def has_child_relationship
|
9
|
+
{'hasChild' => { 'list!' => related_has_child_references }}
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_attributes_from(child)
|
13
|
+
self.containedResourceType=child.resource_class_id if containedResourceType.nil?
|
14
|
+
self.parent_ref=child.class.toplevel if parent_ref.nil?
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_child(child)
|
19
|
+
unless has_child.include?(child)
|
20
|
+
if child.resource_type != 'Group'
|
21
|
+
set_attributes_from(child)
|
22
|
+
if (child.resource_class_id != self.containedResourceType)
|
23
|
+
fail RuntimeError, 'child resource does not match contained types'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
self.has_child.push(child)
|
27
|
+
child.parent_ref=self.ref
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_children(*resources)
|
32
|
+
resources.each {|res| add_child(res) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def contains_resource_type
|
36
|
+
unless self.has_child.empty?
|
37
|
+
has_child.first.resource_type
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module HasCustomer
|
4
|
+
def add_customer(cust)
|
5
|
+
unless has_customer.include?(cust)
|
6
|
+
has_customer.push(cust)
|
7
|
+
cust.add_customer_resource(self)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_customers(*customers)
|
12
|
+
customers.each { |cust| add_customer(cust) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def related_has_customer_references
|
16
|
+
(has_customer.map { |cust| cust.ref.render }).join
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_customer_relationship
|
20
|
+
unless has_customer.empty?
|
21
|
+
{ 'hasCustomer' => {
|
22
|
+
'list!' => related_has_customer_references
|
23
|
+
}}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module HasLocation
|
4
|
+
def has_location_relationship
|
5
|
+
unless has_location.nil?
|
6
|
+
{ 'hasLocation' => { 'list!' => has_location.ref.render } }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
def has_location=(location)
|
10
|
+
|
11
|
+
location.add_location_resource(self) unless location.nil?
|
12
|
+
@has_location=location
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module InCategory
|
4
|
+
|
5
|
+
def add_category(cat)
|
6
|
+
unless in_category.include?(cat.ref)
|
7
|
+
in_category << cat.ref
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_categories(*cats)
|
12
|
+
cats.each { |cat| add_category(cat) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def related_in_category_references
|
16
|
+
(in_category.map &:render).join
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_category_relationship
|
20
|
+
unless in_category.empty?
|
21
|
+
{ 'inCategory' => { 'list!' => related_in_category_references } }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module InNetwork
|
4
|
+
|
5
|
+
def related_in_network_references
|
6
|
+
(in_network.map { |net| net.ref.render }).join
|
7
|
+
end
|
8
|
+
|
9
|
+
def in_network_relationship
|
10
|
+
unless in_network.empty?
|
11
|
+
{ 'inNetwork' => { 'list!' => related_in_network_references } }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_network(net)
|
16
|
+
unless in_network.include?(net)
|
17
|
+
in_network << net
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_networks(*nets)
|
22
|
+
nets.each { |net| add_network(net) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module InZone
|
4
|
+
def in_zone_relationship
|
5
|
+
unless in_zone.nil?
|
6
|
+
{ 'inZone' => { 'list!' => in_zone.ref.render } }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def auto_zone(*zones)
|
11
|
+
my_zone = zones.find {|z| z.contains?(self.address)}
|
12
|
+
self.set_zone(my_zone) unless my_zone.nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def parent_ref_from_zone(zone)
|
16
|
+
unless zone.parent_ref == ArcWeld::Zone.toplevel
|
17
|
+
asset_group_uri = zone.ref_uri.gsub('All Zones', 'All Assets')
|
18
|
+
ArcWeld::Reference.new(
|
19
|
+
uri: asset_group_uri,
|
20
|
+
externalID: OpenSSL::Digest::MD5.base64digest(asset_group_uri),
|
21
|
+
type: 'Group'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
def set_zone(tgt_zone)
|
26
|
+
if tgt_zone.contains?(address)
|
27
|
+
self.staticAddressing = tgt_zone.staticAddressing
|
28
|
+
self.has_location = tgt_zone.has_location
|
29
|
+
self.in_network = tgt_zone.in_network
|
30
|
+
tgt_ref = parent_ref_from_zone(tgt_zone)
|
31
|
+
self.parent_ref = tgt_ref unless tgt_ref.nil?
|
32
|
+
@in_zone = tgt_zone
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def in_zone=(zone)
|
37
|
+
self.set_zone(zone)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Relationships
|
3
|
+
module LocationOf
|
4
|
+
def add_location_resource(res)
|
5
|
+
unless location_of.include?(res)
|
6
|
+
location_of.push(res)
|
7
|
+
res.has_location=self unless res.has_location==self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_location_resources(*resources)
|
12
|
+
resources.each { |res| add_location_resource(res) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def related_location_of_references
|
16
|
+
(location_of.map { |resource| resource.ref.render }).join
|
17
|
+
end
|
18
|
+
|
19
|
+
def location_of_relationship
|
20
|
+
unless location_of.empty?
|
21
|
+
{ 'locationOf' => {
|
22
|
+
'list!' => related_location_of_references
|
23
|
+
}}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Resource
|
3
|
+
def self.included(klass)
|
4
|
+
klass.class_eval '@@RESOURCE_PROPERTIES = []'
|
5
|
+
|
6
|
+
klass.class_eval do
|
7
|
+
extend ClassMethods, ArcWeld::Helpers
|
8
|
+
|
9
|
+
attr_accessor :name, :id, :externalID, :action
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
Hash[*args].each {|k,v| self.send("#{k}=",v)}
|
13
|
+
@action ||= 'insert'
|
14
|
+
yield self if block_given?
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def resource_class_id
|
22
|
+
self.class.class_variable_get :@@CLASS_ID
|
23
|
+
end
|
24
|
+
|
25
|
+
def resource_type
|
26
|
+
self.class.send :resource_type
|
27
|
+
end
|
28
|
+
|
29
|
+
def parent_ref
|
30
|
+
@parent_ref ||= self.class.toplevel
|
31
|
+
end
|
32
|
+
|
33
|
+
def parent_ref=(containing_group)
|
34
|
+
@parent_ref = containing_group.ref
|
35
|
+
end
|
36
|
+
|
37
|
+
def identity_hash
|
38
|
+
if id.nil?
|
39
|
+
{'@externalID' => externalID}
|
40
|
+
else
|
41
|
+
{'@id' => id}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def identity
|
46
|
+
if id.nil?
|
47
|
+
{:externalID => externalID}
|
48
|
+
else
|
49
|
+
{:id => id}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def property_hash
|
54
|
+
self.class.class_properties.reduce({}) do |memo, key|
|
55
|
+
memo[key] = self.send(key) unless self.send(key).nil?
|
56
|
+
memo
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def relationship_hash
|
61
|
+
{} # TODO: damn dirty hack
|
62
|
+
end
|
63
|
+
|
64
|
+
def ref_uri
|
65
|
+
self.class.uri_join(parent_ref.uri, name) unless parent_ref.nil?
|
66
|
+
end
|
67
|
+
|
68
|
+
def ref
|
69
|
+
ArcWeld::Reference.new({
|
70
|
+
type: resource_type,
|
71
|
+
uri: ref_uri
|
72
|
+
}.merge(identity)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_h
|
77
|
+
resource_h = {
|
78
|
+
resource_type => {
|
79
|
+
'childOf' => { 'list!' => parent_ref.render },
|
80
|
+
'@name' => name,
|
81
|
+
'@action' => action
|
82
|
+
}.merge(identity_hash)
|
83
|
+
.merge(property_hash)
|
84
|
+
.merge(relationship_hash)
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def render
|
89
|
+
Gyoku.xml(to_h, key_converter: :none)
|
90
|
+
end
|
91
|
+
|
92
|
+
module ClassMethods
|
93
|
+
def resource_type
|
94
|
+
name.split('::')[-1]
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def toplevel
|
99
|
+
@top ||= ArcWeld::Reference.new(
|
100
|
+
type: 'Group',
|
101
|
+
id: format('01000100010001%03d', class_id),
|
102
|
+
uri: class_root
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
def class_id
|
107
|
+
self.class_variable_get :@@CLASS_ID
|
108
|
+
end
|
109
|
+
|
110
|
+
def class_root
|
111
|
+
self.class_variable_get :@@RESOURCE_ROOT
|
112
|
+
end
|
113
|
+
|
114
|
+
def class_properties
|
115
|
+
self.class_variable_get :@@RESOURCE_PROPERTIES
|
116
|
+
end
|
117
|
+
|
118
|
+
def resource_root(str)
|
119
|
+
fail ArgumentError, 'resource root must be string' unless str.is_a?(String)
|
120
|
+
#puts format('setting resource_root %s on %s', str, self.name)
|
121
|
+
norm_str = (str.gsub(%r{\A/?},'').gsub(%r{/?\z},'').split(' ').map &:capitalize).join(' ')
|
122
|
+
self.class_eval "@@RESOURCE_ROOT = \"/#{norm_str}/\""
|
123
|
+
norm_str
|
124
|
+
end
|
125
|
+
|
126
|
+
def resource_class_id(num)
|
127
|
+
fail ArgumentError, 'class id must be Integer' unless num.is_a?(Integer)
|
128
|
+
#puts format('setting class id %d on %s', num, self.name)
|
129
|
+
self.class_eval "@@CLASS_ID = #{num}"
|
130
|
+
num
|
131
|
+
end
|
132
|
+
|
133
|
+
def resource_property(*syms)
|
134
|
+
syms.each do |sym|
|
135
|
+
#puts format('defining resource property %s on %s', sym.to_s, self.name)
|
136
|
+
register_property(sym)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def register_property(sym)
|
141
|
+
#puts format('registering property %s on %s', sym.to_s, self.name)
|
142
|
+
unless class_properties.include?(sym)
|
143
|
+
class_properties.push(sym)
|
144
|
+
self.class_eval "attr_accessor :#{sym}"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'arc_weld/resources/asset'
|
2
|
+
require 'arc_weld/resources/asset_category'
|
3
|
+
require 'arc_weld/resources/customer'
|
4
|
+
require 'arc_weld/resources/group'
|
5
|
+
require 'arc_weld/resources/location'
|
6
|
+
require 'arc_weld/resources/network'
|
7
|
+
require 'arc_weld/resources/zone'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Asset
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 4
|
7
|
+
resource_root '/All Assets/'
|
8
|
+
resource_property :description, :staticAddressing, :hostname, :macAddress, :address
|
9
|
+
|
10
|
+
has_relationship :has_location, :in_zone
|
11
|
+
has_relationship :in_category, :has_alternate_interface, :in_network, multiple: true
|
12
|
+
|
13
|
+
def safe_name_from(str)
|
14
|
+
str.split('.')[0].gsub(%r{[\/\*:\\]},'-').downcase
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_name
|
18
|
+
if staticAddressing=='false' && (hostname!=nil)
|
19
|
+
safe_name_from(hostname)
|
20
|
+
elsif (address!=nil) && (hostname!=nil)
|
21
|
+
format('%s - %s', address, safe_name_from(hostname))
|
22
|
+
elsif (address!=nil)
|
23
|
+
address
|
24
|
+
else
|
25
|
+
externalID
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def name
|
30
|
+
@name ||= generate_name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class AssetCategory
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 31
|
7
|
+
resource_root '/All Asset Categories/'
|
8
|
+
|
9
|
+
resource_property :description, :containedResourceType, :memberReferencePage
|
10
|
+
|
11
|
+
has_relationship :has_child, multiple: true
|
12
|
+
|
13
|
+
# @OVERRIDE
|
14
|
+
def ref
|
15
|
+
ArcWeld::Reference.new({
|
16
|
+
type: 'Group',
|
17
|
+
uri: ref_uri
|
18
|
+
}.merge(identity)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @OVERRIDE
|
23
|
+
def containedResourceType
|
24
|
+
resource_class_id
|
25
|
+
end
|
26
|
+
|
27
|
+
# @OVERRIDE
|
28
|
+
def to_h
|
29
|
+
resource_h = {
|
30
|
+
'Group' => {
|
31
|
+
'childOf' => { 'list!' => parent_ref.render },
|
32
|
+
'@name' => name,
|
33
|
+
'@action' => action
|
34
|
+
}.merge(identity_hash)
|
35
|
+
.merge(property_hash)
|
36
|
+
.merge(relationship_hash)
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Customer
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 35
|
7
|
+
resource_root '/All Customers/'
|
8
|
+
resource_property :description,
|
9
|
+
:streetAddress1,
|
10
|
+
:streetAddress2,
|
11
|
+
:addressState,
|
12
|
+
:country
|
13
|
+
|
14
|
+
has_relationship :customer_of, multiple: true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Group
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_property :containedResourceType, :description, :memberReferencePage
|
7
|
+
has_relationship :has_child, :in_category, :in_network, :has_customer, multiple: true
|
8
|
+
|
9
|
+
def self.class_id
|
10
|
+
fail TypeError, 'no group resource class_id'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.class_root
|
14
|
+
fail TypeError, 'no group resource class_root'
|
15
|
+
end
|
16
|
+
|
17
|
+
def resource_class_id
|
18
|
+
fail TypeError, 'no group resource class_id'
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.toplevel
|
22
|
+
fail TypeError, 'no top-level group resource reference'
|
23
|
+
end
|
24
|
+
|
25
|
+
def parent_ref
|
26
|
+
@parent_ref
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Location
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 39
|
7
|
+
resource_root '/All Locations/'
|
8
|
+
resource_property :countryCode,
|
9
|
+
:city,
|
10
|
+
:countryName,
|
11
|
+
:description,
|
12
|
+
:latitude,
|
13
|
+
:longitude,
|
14
|
+
:postalCode,
|
15
|
+
:regionCode
|
16
|
+
has_relationship :location_of, multiple: true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Network
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 40
|
7
|
+
resource_root '/All Networks/'
|
8
|
+
resource_property :description
|
9
|
+
|
10
|
+
has_relationship :has_customer, multiple: true
|
11
|
+
has_relationship :has_location
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
class Zone
|
3
|
+
include ArcWeld::Resource
|
4
|
+
include ArcWeld::Relationship
|
5
|
+
|
6
|
+
resource_class_id 29
|
7
|
+
resource_root '/All Zones/'
|
8
|
+
resource_property :description, :dynamicAddressing, :startAddress, :endAddress
|
9
|
+
|
10
|
+
has_relationship :has_location
|
11
|
+
has_relationship :in_network, :in_category, multiple: true
|
12
|
+
|
13
|
+
attr_reader :cidr
|
14
|
+
|
15
|
+
def cidr=(addr)
|
16
|
+
@cidr = case addr
|
17
|
+
when String
|
18
|
+
IPAddr.new(addr)
|
19
|
+
when IPAddr
|
20
|
+
addr
|
21
|
+
else
|
22
|
+
fail ArgumentError, 'must call with either String or IPAddr'
|
23
|
+
end
|
24
|
+
|
25
|
+
@startAddress = cidr.to_range.to_a.first.to_s
|
26
|
+
@endAddress = cidr.to_range.to_a.last.to_s
|
27
|
+
cidr
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_ip
|
31
|
+
IPAddr.new(startAddress)
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_ip
|
35
|
+
IPAddr.new(endAddress)
|
36
|
+
end
|
37
|
+
|
38
|
+
def contains?(addr)
|
39
|
+
comp = case addr
|
40
|
+
when String
|
41
|
+
IPAddr.new(addr)
|
42
|
+
when IPAddr
|
43
|
+
addr
|
44
|
+
else
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
if ([comp, startAddress, endAddress].any? &:nil?)
|
48
|
+
false
|
49
|
+
else
|
50
|
+
start_ip <= comp && end_ip >= comp
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def staticAddressing
|
55
|
+
case self.dynamicAddressing
|
56
|
+
when 'true', true
|
57
|
+
'false'
|
58
|
+
when 'false', false
|
59
|
+
'true'
|
60
|
+
else
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'arc_weld'
|
2
|
+
PROJECT_DIR = File.expand_path(File.dirname(__FILE__))
|
3
|
+
PROJECT_LIB = File.join(PROJECT_DIR, 'lib')
|
4
|
+
PROJECT_THOR = File.join(PROJECT_LIB, 'thor')
|
5
|
+
$LOAD_PATH.push(PROJECT_LIB)
|
6
|
+
|
7
|
+
Dir[File.join(PROJECT_THOR,'*.thor')].each do |tf|
|
8
|
+
Thor::Util.load_thorfile(tf)
|
9
|
+
end
|
@@ -0,0 +1,3 @@
|
|
1
|
+
name,externalID,streetAddress1,streetAddress2,description
|
2
|
+
Staging,weld_customer_stage,,,Customer resource for staging asset model. You will want to reassign resources from here to your actual target customers, or set a different target customer in the project config.
|
3
|
+
Decom,weld_customer_decom,,,Customer resource for decommissioning assets. You can use this resource to disassociate modeled resources from active customers/connectors.
|
@@ -0,0 +1,6 @@
|
|
1
|
+
name,externalID,latitude,longitude,city,description
|
2
|
+
cota,weld_location_001,30.3077609,-97.7534014,Elroy,Circuit of the Americas
|
3
|
+
nurburgring,weld_location_002,50.3460423,6.9660294,Meuspath,Nürburgring Nordschleife
|
4
|
+
laguna seca,weld_location_003,36.5842902,-121.7534634,Salinas,Mazda Raceway Laguna Seca
|
5
|
+
driveway,weld_location_004,36.5842902,-121.7534634,Austin,Driveway Austin Motorsports
|
6
|
+
harris hill,weld_location_005,29.9201124,-97.8744759,San Marcos,Harris Hill Raceway
|
@@ -0,0 +1,3 @@
|
|
1
|
+
name,externalID,description
|
2
|
+
Staging,weld_net_stage,Staging Network for Generated Resources. You will want to move your generated assets out of here to somewhere more useful. You can also retarget the base_model in the config to point to somewhere directly like Local.
|
3
|
+
Decom,weld_net_decom,Decom Network for old resources. You will want to move old/unused resources here to disassociate them from active connectors & customers. This will make deleting them cleaner.
|