bcome 0.6.8 → 0.6.9
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/lib/bcome/version.rb +1 -1
- data/lib/helpers/fog_helper.rb +2 -1
- data/lib/stack/environment.rb +64 -10
- data/lib/stack/instance.rb +5 -2
- 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: f4b9ed597a273b6b2583fdbbe47fcf39e5f364d7
|
4
|
+
data.tar.gz: c1435dd0a9b8c642b5f685bd5d0ca691843ae4ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f31f5fe23d0a3379658c8344f6ff267509d245d83130ea5a21074d6a9a4af66318bc365f37c8325472ccd216459789859a595cae4e32b73765bfe43657c990
|
7
|
+
data.tar.gz: dc8b03b7f322159c2e082df45ebbbbde4dec3f21a813d2af1953317066b974d07dea0ef1096be5753618cfef85ac6130e1eb9dce626f03f2e8faa2469600ef19
|
data/lib/bcome/version.rb
CHANGED
data/lib/helpers/fog_helper.rb
CHANGED
@@ -14,7 +14,8 @@ module ::Bcome::FogHelper
|
|
14
14
|
|
15
15
|
def reload!
|
16
16
|
@unfiltered_servers = fog_client.servers.all(ec2_filters)
|
17
|
-
|
17
|
+
restock_inventory = true
|
18
|
+
@resources = do_load_resources(restock_inventory)
|
18
19
|
@node = construct_node
|
19
20
|
system("clear")
|
20
21
|
list
|
data/lib/stack/environment.rb
CHANGED
@@ -96,21 +96,75 @@ module ::Bcome::Stack
|
|
96
96
|
]
|
97
97
|
end
|
98
98
|
|
99
|
-
def
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
def load_from_static_inventory
|
100
|
+
path = config_path
|
101
|
+
raise "Missing instances.yml configuration for your environment. You've selected a static network lookup, and yet I cannot find #{config_path}".failure unless File.exist?(config_path)
|
102
|
+
config = YAML.load_file(path)
|
103
|
+
return collection_klass.collection_from_config(self, config)
|
104
|
+
end
|
105
|
+
|
106
|
+
def refresh_dynamic_inventory
|
107
|
+
loaded_resources = collection_klass.collection_from_fog_data(self, servers)
|
108
|
+
loaded_resources
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def restock
|
113
|
+
puts "\n/ Refreshing server inventory".menu_item_green
|
114
|
+
take_stock!(collection_klass.collection_from_fog_data(self, servers))
|
115
|
+
puts " Done. Inventory written to: #{config_path}\n".menu_item_green
|
116
|
+
end
|
117
|
+
|
118
|
+
def use_inventory_cache?
|
119
|
+
(dynamic_network_lookup? && self.meta_data[:inventory_cache])
|
120
|
+
end
|
121
|
+
|
122
|
+
def static_inventory_is_set?
|
123
|
+
File.exist?(config_path)
|
124
|
+
end
|
125
|
+
|
126
|
+
def load_and_take_stock
|
127
|
+
loaded_resources = refresh_dynamic_inventory
|
128
|
+
take_stock!(loaded_resources)
|
129
|
+
loaded_resources
|
130
|
+
end
|
131
|
+
|
132
|
+
def do_load_resources(restock_inventory = false)
|
133
|
+
loaded_resources = manage_inventory(restock_inventory)
|
108
134
|
node.set_instances(loaded_resources)
|
109
135
|
return loaded_resources
|
110
136
|
end
|
111
137
|
|
138
|
+
def manage_inventory(restock_inventory = false)
|
139
|
+
return load_from_static_inventory unless dynamic_network_lookup? # No dynamic lookup, load from static
|
140
|
+
return refresh_dynamic_inventory unless use_inventory_cache? # Dynamic lookup, with no cache, just load from dynamic
|
141
|
+
return load_and_take_stock if !static_inventory_is_set? || restock_inventory # Dynamic lookup and stock, if stock not set or we're explicitly re-stocking
|
142
|
+
return load_from_static_inventory # otherwise just load from static.
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
def config_dir
|
147
|
+
"#{CONFIGS_PATH}/static_instances/"
|
148
|
+
end
|
149
|
+
|
112
150
|
def config_path
|
113
|
-
"#{
|
151
|
+
"#{config_dir}#{platform.identifier}_#{identifier}-instances.yml"
|
152
|
+
end
|
153
|
+
|
154
|
+
def take_stock!(resources)
|
155
|
+
`mkdir -p #{config_dir}`
|
156
|
+
inventory = { :instances => [] }
|
157
|
+
resources.each do |resource|
|
158
|
+
inventory[:instances] << {
|
159
|
+
:identifier => resource.identifier,
|
160
|
+
:external_network_interface_address => resource.external_network_interface_address,
|
161
|
+
:public_ip_address => resource.public_ip_address,
|
162
|
+
:role => resource.role
|
163
|
+
}
|
164
|
+
end
|
165
|
+
File.open(config_path, "w") do |file|
|
166
|
+
file.write inventory.to_yaml
|
167
|
+
end
|
114
168
|
end
|
115
169
|
|
116
170
|
def do_describe
|
data/lib/stack/instance.rb
CHANGED
@@ -31,11 +31,14 @@ module ::Bcome::Stack
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
attr_reader :environment, :meta_data
|
35
|
-
|
34
|
+
attr_reader :environment, :meta_data, :external_network_interface_address, :public_ip_address, :role
|
35
|
+
|
36
36
|
def initialize(meta_data, parent)
|
37
37
|
@meta_data = meta_data
|
38
38
|
@environment = parent
|
39
|
+
@external_network_interface_address = meta_data[:external_network_interface_address]
|
40
|
+
@public_ip_address = meta_data[:public_ip_address]
|
41
|
+
@role = meta_data[:role]
|
39
42
|
end
|
40
43
|
|
41
44
|
def identifier
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Roderick (Webzakimbo)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|