ironfan 6.0.6 → 6.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,10 +24,9 @@ Gem::Specification.new do |gem|
24
24
  gem.add_dependency('unf', '0.1.3')
25
25
  gem.add_dependency('excon', '0.32.1')
26
26
  gem.add_dependency('formatador', '0.2.4')
27
- gem.add_dependency('gorillib', '0.5.0')
27
+ gem.add_dependency('gorillib', '~> 0.5.2')
28
28
  gem.add_dependency('rbvmomi', '1.8.1')
29
29
  gem.add_dependency('diff-lcs', '1.2.5')
30
- gem.add_dependency('json', '1.5.4')
31
30
 
32
31
  gem.add_development_dependency('bundler', '~> 1.0')
33
32
 
@@ -40,37 +40,37 @@ module Ironfan
40
40
  "Gemfile.#{realm_or_cluster_name}"
41
41
  end
42
42
 
43
+
44
+ #
45
+ # Common code for calling broker.discover with an appropriately
46
+ # trimmed list of clusters to discover.
47
+ #
48
+ def discover_computers(realm_name, cluster_name, facet_name, slice_indexes)
49
+ realm = Ironfan.load_realm(realm_name)
50
+ realm.clusters.each{ |cluster| Ironfan.load_cluster cluster.name }
51
+ realm.resolve!
52
+ clusters = cluster_name ? Array(realm.clusters[cluster_name.to_sym]) : realm.clusters.to_a
53
+ return broker.discover!(clusters, config[:cloud])
54
+ end
55
+
43
56
  #
44
57
  # A slice of a cluster:
45
58
  #
46
- # @param [String] cluster_name -- cluster to slice
47
- # @param [String] facet_name -- facet to slice (or nil for all in cluster)
48
- # @param [Array, String] slice_indexes -- servers in that facet (or nil for all in facet).
49
- # You must specify a facet if you use slice_indexes.
50
59
  #
51
60
  # @return [Ironfan::ServerSlice] the requested slice
52
61
  def get_slice(slice_string, *args)
53
62
  realm_name, cluster_name, facet_name, slice_indexes = pick_apart(slice_string, *args)
54
63
  desc = predicate_str(realm_name, cluster_name, facet_name, slice_indexes)
55
- #
56
64
  ui.info("Inventorying servers in #{desc}")
57
- realm = Ironfan.load_realm(realm_name)
58
- realm.clusters.each{ |cluster| Ironfan.load_cluster cluster.name }
59
- realm.resolve!
60
- Chef::Config[:knife][:region] = realm.clusters.to_a.first.servers.to_a.first.cloud(:ec2).region
61
- computers = broker.discover!(realm.clusters.to_a, config[:cloud])
62
- Chef::Log.info("Inventoried #{computers.size} computers")
63
- #
64
- computers.slice(cluster_name, facet_name, slice_indexes)
65
+ computers = discover_computers(realm_name, cluster_name, facet_name, slice_indexes)
66
+
67
+ Chef::Log.info("Inventoried #{computers.size} computers")
68
+ return computers.slice(cluster_name, facet_name, slice_indexes)
65
69
  end
66
70
 
67
71
  def all_computers(slice_string, *args)
68
72
  realm_name, cluster_name, facet_name, slice_indexes = pick_apart(slice_string, *args)
69
- realm = Ironfan.load_realm(realm_name)
70
- realm.clusters.each{ |cluster| Ironfan.load_cluster cluster.name }
71
- realm.resolve!
72
- clusters = cluster_name ? Array(realm.clusters[cluster_name.to_sym]) : realm.clusters.to_a
73
- computers = broker.discover!(clusters, config[:cloud])
73
+ computers = discover_computers(realm_name, cluster_name, facet_name, slice_indexes)
74
74
  ui.info("Loaded information for #{computers.size} computer(s) in cluster #{cluster_name}")
75
75
  computers
76
76
  end
@@ -13,11 +13,17 @@ module Ironfan
13
13
  # unrecognizable resources are labeled as bogus.
14
14
  def discover!(clusters, with_cloud = true)
15
15
 
16
+
16
17
  # Get fully resolved servers, and build Computers using them
17
18
  computers = Computers.new(clusters: Array(clusters))
18
19
  #
19
20
  if with_cloud
20
21
  providers = computers.map{|c| c.providers.values }.flatten.uniq
22
+
23
+ providers.each do |p|
24
+ p.forget!
25
+ end
26
+
21
27
  Ironfan.parallel(providers) do |provider|
22
28
  clusters.each do |cluster|
23
29
  Ironfan.step cluster.name, "Loading #{provider.handle}", :cyan
@@ -170,10 +170,10 @@ module Ironfan
170
170
  hsh.delete(:_type)
171
171
  hsh.delete(:ssh_user)
172
172
  #hsh[:security_groups] = Hash[hsh[:security_groups].map{|x| [x.fetch(:name), x]}]
173
- hsh[:components] = Hash[hsh.fetch(:components).map do |component|
174
- [component.fetch(:name), component]
173
+ hsh[:components] = Hash[hsh[:components].to_a.map do |component|
174
+ [component[:name].to_s, component]
175
175
  end]
176
- hsh[:run_list] = hsh.fetch(:run_list).map do |x|
176
+ hsh[:run_list] = hsh[:run_list].to_a.map do |x|
177
177
  x.end_with?(']') ? x : "recipe[#{x}]"
178
178
  end
179
179
  end)
@@ -35,13 +35,19 @@ module Ironfan
35
35
  def self.load(cluster)
36
36
  Ironfan.parallel (resources) do |r|
37
37
  type = r.resource_type.to_s
38
- r.forget!
39
38
  Ironfan.substep(cluster.name, "loading #{type}s")
40
39
  r.load! cluster
41
40
  Ironfan.substep(cluster.name, "loaded #{type}s")
42
41
  end
43
42
  end
44
43
 
44
+
45
+ def self.forget!()
46
+ resources.each do |r|
47
+ r.forget!
48
+ end
49
+ end
50
+
45
51
  def self.validate(computers)
46
52
  resources.each {|r| r.validate_resources! computers }
47
53
  end
@@ -242,6 +248,7 @@ bootcmd:
242
248
  #{computer.private_key.split("\n").map {|l| " "+l}.join("\n")}
243
249
  EOF
244
250
  domainname #{computer.server.fqdn}
251
+ IP=`curl 169.254.169.254/latest/meta-data/local-ipv4`;sed -i -e "s/127\.0\.1\.1/$IP/" /etc/cloud/templates/hosts.tmpl
245
252
 
246
253
  chef:
247
254
  install_type: "packages"
@@ -48,7 +48,12 @@ module Ironfan
48
48
  #
49
49
  # Discovery
50
50
  #
51
- def self.load!(cluster=nil)
51
+ def self.load!(cluster = nil)
52
+ load_once!
53
+ end
54
+
55
+ def self.load_once!
56
+ return if @loaded
52
57
  Ec2.connection.volumes.each do |vol|
53
58
  next if vol.blank?
54
59
  next if %w[deleting deleted error].include?(vol.state.to_s)
@@ -62,6 +67,7 @@ module Ironfan
62
67
  remember ebs
63
68
  end
64
69
  end
70
+ @loaded = true
65
71
  end
66
72
 
67
73
  def receive_adaptee(obj)
@@ -114,7 +114,12 @@ module Ironfan
114
114
  #
115
115
  # Discovery
116
116
  #
117
- def self.load!(cluster=nil)
117
+ def self.load!(cluster = nil)
118
+ load_once!
119
+ end
120
+
121
+ def self.load_once!
122
+ return if @loaded
118
123
  Ec2.connection.servers.each do |fs|
119
124
  machine = new(:adaptee => fs)
120
125
  if (not machine.created?)
@@ -128,6 +133,7 @@ module Ironfan
128
133
  remember machine
129
134
  end
130
135
  end
136
+ @loaded = true
131
137
  end
132
138
 
133
139
  def receive_adaptee(obj)
@@ -1,3 +1,3 @@
1
1
  module Ironfan
2
- VERSION = '6.0.6'
2
+ VERSION = '6.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ironfan
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.6
4
+ version: 6.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-21 00:00:00.000000000 Z
12
+ date: 2014-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -96,17 +96,17 @@ dependencies:
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - '='
99
+ - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 0.5.0
101
+ version: 0.5.2
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - '='
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 0.5.0
109
+ version: 0.5.2
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: rbvmomi
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -139,22 +139,6 @@ dependencies:
139
139
  - - '='
140
140
  - !ruby/object:Gem::Version
141
141
  version: 1.2.5
142
- - !ruby/object:Gem::Dependency
143
- name: json
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - '='
148
- - !ruby/object:Gem::Version
149
- version: 1.5.4
150
- type: :runtime
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - '='
156
- - !ruby/object:Gem::Version
157
- version: 1.5.4
158
142
  - !ruby/object:Gem::Dependency
159
143
  name: bundler
160
144
  requirement: !ruby/object:Gem::Requirement
@@ -334,7 +318,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
334
318
  version: '0'
335
319
  segments:
336
320
  - 0
337
- hash: 4541448457193687507
321
+ hash: 2994755977680562733
338
322
  required_rubygems_version: !ruby/object:Gem::Requirement
339
323
  none: false
340
324
  requirements:
@@ -343,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
343
327
  version: '0'
344
328
  segments:
345
329
  - 0
346
- hash: 4541448457193687507
330
+ hash: 2994755977680562733
347
331
  requirements: []
348
332
  rubyforge_project:
349
333
  rubygems_version: 1.8.25