bosh_agent 1.5.0.pre.1215 → 1.5.0.pre.1226

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Agent
4
2
  module ApplyPlan
5
3
  class Plan
@@ -91,6 +89,9 @@ module Bosh::Agent
91
89
  end
92
90
  end
93
91
 
92
+ def has_prepared_spec?(new_spec)
93
+ @spec['prepared_spec'] == new_spec
94
+ end
94
95
  end
95
96
  end
96
97
  end
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Agent
4
2
  module Message
5
3
  class Apply < Base
@@ -110,7 +108,9 @@ module Bosh::Agent
110
108
  end
111
109
 
112
110
  def apply_job
113
- if @new_plan.has_jobs?
111
+ if @old_plan.has_prepared_spec?(@new_spec)
112
+ logger.info("New jobs already installed")
113
+ elsif @new_plan.has_jobs?
114
114
  @new_plan.install_jobs
115
115
  else
116
116
  logger.info("No job")
@@ -118,7 +118,9 @@ module Bosh::Agent
118
118
  end
119
119
 
120
120
  def apply_packages
121
- if @new_plan.has_packages?
121
+ if @old_plan.has_prepared_spec?(@new_spec)
122
+ logger.info("New packages already installed")
123
+ elsif @new_plan.has_packages?
122
124
  @new_plan.install_packages
123
125
  else
124
126
  logger.info("No packages")
@@ -0,0 +1,86 @@
1
+ module Bosh::Agent::Message
2
+ class Prepare < Base
3
+ def initialize(args)
4
+ @platform = Bosh::Agent::Config.platform
5
+
6
+ if args.size < 1
7
+ raise ArgumentError, "not enough arguments"
8
+ end
9
+
10
+ @new_spec = args.first
11
+ unless @new_spec.is_a?(Hash)
12
+ raise ArgumentError, "invalid spec, Hash expected, " +
13
+ "#{@new_spec.class} given"
14
+ end
15
+ end
16
+
17
+ def prepare
18
+ initialize_plans
19
+
20
+ %w(bosh jobs packages monit).each do |dir|
21
+ FileUtils.mkdir_p(File.join(base_dir, dir))
22
+ end
23
+
24
+ logger.info("Preparing: #{@new_spec.inspect}")
25
+
26
+ if @new_plan.configured?
27
+ begin
28
+ apply_job
29
+ apply_packages
30
+ log_bit_download_with_agent_state
31
+ rescue Exception => e
32
+ raise Bosh::Agent::MessageHandlerError,
33
+ "#{e.message}: #{e.backtrace}"
34
+ end
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def initialize_plans
41
+ initialize_networks
42
+
43
+ @old_spec = Bosh::Agent::Config.state.to_hash
44
+
45
+ @old_plan = Bosh::Agent::ApplyPlan::Plan.new(@old_spec)
46
+ @new_plan = Bosh::Agent::ApplyPlan::Plan.new(@new_spec)
47
+ end
48
+
49
+ def initialize_networks
50
+ if @new_spec["networks"]
51
+ @new_spec["networks"].each do |network, properties|
52
+ infrastructure = Bosh::Agent::Config.infrastructure
53
+ network_settings =
54
+ infrastructure.get_network_settings(network, properties)
55
+ logger.debug("current network settings from VM: #{network_settings.inspect}")
56
+ logger.debug("new network settings to be applied: #{properties.inspect}")
57
+ if network_settings
58
+ @new_spec["networks"][network].merge!(network_settings)
59
+ logger.debug("merged network settings: #{@new_spec["networks"].inspect}")
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def apply_job
66
+ if @new_plan.has_jobs?
67
+ @new_plan.install_jobs
68
+ else
69
+ logger.info("No job")
70
+ end
71
+ end
72
+
73
+ def apply_packages
74
+ if @new_plan.has_packages?
75
+ @new_plan.install_packages
76
+ else
77
+ logger.info("No packages")
78
+ end
79
+ end
80
+
81
+ def log_bit_download_with_agent_state
82
+ @old_spec['prepared_spec'] = @new_spec
83
+ Bosh::Agent::Config.state.write(@old_spec)
84
+ end
85
+ end
86
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Bosh
4
4
  module Agent
5
- VERSION = '1.5.0.pre.1215'
5
+ VERSION = '1.5.0.pre.1226'
6
6
  BOSH_PROTOCOL = "1"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre.1215
4
+ version: 1.5.0.pre.1226
5
5
  prerelease: 6
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: 2013-10-31 00:00:00.000000000 Z
12
+ date: 2013-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netaddr
@@ -162,7 +162,7 @@ dependencies:
162
162
  requirements:
163
163
  - - ~>
164
164
  - !ruby/object:Gem::Version
165
- version: 1.5.0.pre.1215
165
+ version: 1.5.0.pre.1226
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ dependencies:
170
170
  requirements:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
- version: 1.5.0.pre.1215
173
+ version: 1.5.0.pre.1226
174
174
  - !ruby/object:Gem::Dependency
175
175
  name: bosh_common
176
176
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +178,7 @@ dependencies:
178
178
  requirements:
179
179
  - - ~>
180
180
  - !ruby/object:Gem::Version
181
- version: 1.5.0.pre.1215
181
+ version: 1.5.0.pre.1226
182
182
  type: :runtime
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
@@ -186,7 +186,7 @@ dependencies:
186
186
  requirements:
187
187
  - - ~>
188
188
  - !ruby/object:Gem::Version
189
- version: 1.5.0.pre.1215
189
+ version: 1.5.0.pre.1226
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: blobstore_client
192
192
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +194,7 @@ dependencies:
194
194
  requirements:
195
195
  - - ~>
196
196
  - !ruby/object:Gem::Version
197
- version: 1.5.0.pre.1215
197
+ version: 1.5.0.pre.1226
198
198
  type: :runtime
199
199
  prerelease: false
200
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -202,7 +202,7 @@ dependencies:
202
202
  requirements:
203
203
  - - ~>
204
204
  - !ruby/object:Gem::Version
205
- version: 1.5.0.pre.1215
205
+ version: 1.5.0.pre.1226
206
206
  - !ruby/object:Gem::Dependency
207
207
  name: rspec-fire
208
208
  requirement: !ruby/object:Gem::Requirement
@@ -222,7 +222,7 @@ dependencies:
222
222
  description: ! 'This agent listens for instructions from the bosh director on each
223
223
  server that bosh manages.
224
224
 
225
- 732bcf'
225
+ 21ba44'
226
226
  email: support@cloudfoundry.com
227
227
  executables:
228
228
  - bosh_agent
@@ -266,6 +266,7 @@ files:
266
266
  - lib/bosh_agent/message/logs.rb
267
267
  - lib/bosh_agent/message/migrate_disk.rb
268
268
  - lib/bosh_agent/message/mount_disk.rb
269
+ - lib/bosh_agent/message/prepare.rb
269
270
  - lib/bosh_agent/message/ssh.rb
270
271
  - lib/bosh_agent/message/state.rb
271
272
  - lib/bosh_agent/message/unmount_disk.rb