bosh-director 1.5.0.pre.1260 → 1.5.0.pre.1266
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'bosh/director/agent_message_converter'
|
2
|
+
|
1
3
|
module Bosh::Director
|
2
4
|
class AgentClient < Client
|
3
5
|
|
@@ -19,46 +21,6 @@ module Bosh::Director
|
|
19
21
|
super('agent', id, defaults.merge(options))
|
20
22
|
end
|
21
23
|
|
22
|
-
# This converts the old agent response format to the new. This can be taken
|
23
|
-
# out once the agents never reply with the old message format.
|
24
|
-
# The old message format is just to pass the return object as JSON. That
|
25
|
-
# means it could be any type -- array, hash, string, int, etc.
|
26
|
-
# The new format is:
|
27
|
-
# {"state"=>"task_state", "value"=><task_return_object>,
|
28
|
-
# "agent_task_id"=>123}
|
29
|
-
# This is a class method to make testing easier.
|
30
|
-
# @param [Object] msg The agent message to convert to the new format.
|
31
|
-
# @return [Hash] The message in the new message format.
|
32
|
-
def self.convert_old_message_to_new(msg)
|
33
|
-
if msg && msg.is_a?(Hash)
|
34
|
-
if !msg.has_key?('value')
|
35
|
-
# There's no value but there is state and agent_task_id.
|
36
|
-
# Just leave it.
|
37
|
-
if msg.has_key?('state') && msg.has_key?('agent_task_id')
|
38
|
-
return msg
|
39
|
-
end
|
40
|
-
# There's no value and either one or both of state/agent_task_id don't
|
41
|
-
# exist. Assume that the whole message response was meant to be the
|
42
|
-
# value.
|
43
|
-
return { 'value' => msg,
|
44
|
-
'state' => msg['state'] || 'done',
|
45
|
-
'agent_task_id' => msg['agent_task_id'] || nil }
|
46
|
-
elsif !msg.has_key?('state')
|
47
|
-
# The message has a value section but no "state". Mark state as
|
48
|
-
# done.
|
49
|
-
return { 'value' => msg['value'],
|
50
|
-
'state' => 'done',
|
51
|
-
'agent_task_id' => msg['agent_task_id'] || nil }
|
52
|
-
else
|
53
|
-
# The message was good from the start!
|
54
|
-
return msg
|
55
|
-
end
|
56
|
-
end
|
57
|
-
# If the message was anything other than a hash (float, int, string,
|
58
|
-
# array, etc.) then we want to just make that be the "value".
|
59
|
-
{ 'state' => 'done', 'value' => msg, 'agent_task_id' => nil }
|
60
|
-
end
|
61
|
-
|
62
24
|
[
|
63
25
|
:prepare,
|
64
26
|
:apply,
|
@@ -71,10 +33,10 @@ module Bosh::Director
|
|
71
33
|
:unmount_disk,
|
72
34
|
].each do |method|
|
73
35
|
define_method (method) do |*args|
|
74
|
-
task =
|
36
|
+
task = AgentMessageConverter.convert_old_message_to_new(super(*args))
|
75
37
|
while task['state'] == 'running'
|
76
38
|
sleep(DEFAULT_POLL_INTERVAL)
|
77
|
-
task =
|
39
|
+
task = AgentMessageConverter.convert_old_message_to_new(get_task(task['agent_task_id']))
|
78
40
|
end
|
79
41
|
task['value']
|
80
42
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Bosh::Director
|
2
|
+
module AgentMessageConverter
|
3
|
+
# This converts the old agent response format to the new. This can be taken
|
4
|
+
# out once the agents never reply with the old message format.
|
5
|
+
# The old message format is just to pass the return object as JSON. That
|
6
|
+
# means it could be any type -- array, hash, string, int, etc.
|
7
|
+
# The new format is:
|
8
|
+
# {"state"=>"task_state", "value"=><task_return_object>,
|
9
|
+
# "agent_task_id"=>123}
|
10
|
+
# This is a class method to make testing easier.
|
11
|
+
# @param [Object] msg The agent message to convert to the new format.
|
12
|
+
# @return [Hash] The message in the new message format.
|
13
|
+
def self.convert_old_message_to_new(msg)
|
14
|
+
if msg && msg.is_a?(Hash)
|
15
|
+
if !msg.has_key?('value')
|
16
|
+
# There's no value but there is state and agent_task_id.
|
17
|
+
# Just leave it.
|
18
|
+
if msg.has_key?('state') && msg.has_key?('agent_task_id')
|
19
|
+
return msg
|
20
|
+
end
|
21
|
+
# There's no value and either one or both of state/agent_task_id don't
|
22
|
+
# exist. Assume that the whole message response was meant to be the
|
23
|
+
# value.
|
24
|
+
return { 'value' => msg,
|
25
|
+
'state' => msg['state'] || 'done',
|
26
|
+
'agent_task_id' => msg['agent_task_id'] || nil }
|
27
|
+
elsif !msg.has_key?('state')
|
28
|
+
# The message has a value section but no "state". Mark state as
|
29
|
+
# done.
|
30
|
+
return { 'value' => msg['value'],
|
31
|
+
'state' => 'done',
|
32
|
+
'agent_task_id' => msg['agent_task_id'] || nil }
|
33
|
+
else
|
34
|
+
# The message was good from the start!
|
35
|
+
return msg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
# If the message was anything other than a hash (float, int, string,
|
39
|
+
# array, etc.) then we want to just make that be the "value".
|
40
|
+
{ 'state' => 'done', 'value' => msg, 'agent_task_id' => nil }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -11,7 +11,7 @@ module Bosh::Director
|
|
11
11
|
attr_reader :current_state
|
12
12
|
|
13
13
|
# @params [DeploymentPlan::Instance] instance
|
14
|
-
def initialize(instance, event_ticker
|
14
|
+
def initialize(instance, event_ticker)
|
15
15
|
@cloud = Config.cloud
|
16
16
|
@logger = Config.logger
|
17
17
|
@ticker = event_ticker
|
@@ -40,7 +40,7 @@ module Bosh::Director
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def report_progress
|
43
|
-
@ticker.advance(100.0 / update_steps())
|
43
|
+
@ticker.advance(100.0 / update_steps())
|
44
44
|
end
|
45
45
|
|
46
46
|
def update_steps
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-director
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0.pre.
|
4
|
+
version: 1.5.0.pre.1266
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.5.0.pre.
|
37
|
+
version: 1.5.0.pre.1266
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.5.0.pre.
|
45
|
+
version: 1.5.0.pre.1266
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bosh-core
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.5.0.pre.
|
53
|
+
version: 1.5.0.pre.1266
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.5.0.pre.
|
61
|
+
version: 1.5.0.pre.1266
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: bosh_common
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 1.5.0.pre.
|
69
|
+
version: 1.5.0.pre.1266
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.5.0.pre.
|
77
|
+
version: 1.5.0.pre.1266
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: bosh_cpi
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.5.0.pre.
|
85
|
+
version: 1.5.0.pre.1266
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.5.0.pre.
|
93
|
+
version: 1.5.0.pre.1266
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: bosh_openstack_cpi
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.5.0.pre.
|
101
|
+
version: 1.5.0.pre.1266
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.5.0.pre.
|
109
|
+
version: 1.5.0.pre.1266
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: bosh_aws_cpi
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.5.0.pre.
|
117
|
+
version: 1.5.0.pre.1266
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.5.0.pre.
|
125
|
+
version: 1.5.0.pre.1266
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: bosh_vsphere_cpi
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 1.5.0.pre.
|
133
|
+
version: 1.5.0.pre.1266
|
134
134
|
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 1.5.0.pre.
|
141
|
+
version: 1.5.0.pre.1266
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: eventmachine
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -445,7 +445,7 @@ dependencies:
|
|
445
445
|
version: '1.0'
|
446
446
|
description: ! 'BOSH Director
|
447
447
|
|
448
|
-
|
448
|
+
56a379'
|
449
449
|
email: support@cloudfoundry.com
|
450
450
|
executables:
|
451
451
|
- bosh-director
|
@@ -486,6 +486,7 @@ files:
|
|
486
486
|
- db/migrations/dns/20120123234908_initial.rb
|
487
487
|
- lib/bosh/director.rb
|
488
488
|
- lib/bosh/director/agent_client.rb
|
489
|
+
- lib/bosh/director/agent_message_converter.rb
|
489
490
|
- lib/bosh/director/api.rb
|
490
491
|
- lib/bosh/director/api/api_helper.rb
|
491
492
|
- lib/bosh/director/api/backup_manager.rb
|