bosh-director 1.2686.0 → 1.2690.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b925415b6577c01836374e361adea28b9f0fc9bc
4
- data.tar.gz: abc3658c8758bdca6a34148463822067e3c4a1f2
3
+ metadata.gz: 1ac6ba90e9a35e9139bfb91e75536ec872cb6dd5
4
+ data.tar.gz: 03d0cd5cff23966e803dd3b8492881a9278d075d
5
5
  SHA512:
6
- metadata.gz: 963428802eb65461667ddd8f4df593a8b35596c4633743df73a7afe47f11da3560c5fd5c98428fc774954e4089da9b36981c084e6159ac1f4cbb7d57a089f410
7
- data.tar.gz: 9946b4c884e4eba0cfc12909815c51626f2d02c3ba910b6bb753d5046b573d33e7701c0fc4e1d34e4e3e3f23ce12e7fdee4a15d654a82b1a871557ecc859708b
6
+ metadata.gz: 2cab0cd501525452b4d283e4b0207a0a352bc8bd4ff045af3dfdf730fe930eec2e6b6335a2ecba513993d81e5912c5b57dd9cdf41088f5fba4b6988e1cbd256c
7
+ data.tar.gz: d86c2b84b29388df2c428b89aee574e05686f40840a85237c8e8a1b0dc77289be383f3c94d830ef09369c9dff496449657f88ff7f56feeda7aef59e1ce75b51f
@@ -469,10 +469,12 @@ module Bosh::Director
469
469
  # @param [Hash<String, NetworkReservation>] reservations
470
470
  # @return [void]
471
471
  def take_network_reservations(reservations)
472
- @logger.debug("Copying job instance `#{self}' network reservations")
473
472
  reservations.each do |name, provided_reservation|
474
473
  reservation = @network_reservations[name]
475
- reservation.take(provided_reservation) if reservation
474
+ if reservation
475
+ @logger.debug("Copying job instance `#{self}' network reservation #{provided_reservation}")
476
+ reservation.take(provided_reservation)
477
+ end
476
478
  end
477
479
  end
478
480
 
@@ -480,10 +482,15 @@ module Bosh::Director
480
482
  resource_pool = @job.resource_pool
481
483
  vm = resource_pool.add_allocated_vm
482
484
 
483
- @logger.debug("Found VM `#{vm_model.cid}' running job instance `#{self}' in resource pool `#{resource_pool.name}'")
485
+ reservation = @network_reservations[vm.resource_pool.network.name]
486
+
487
+ @logger.debug("Found VM '#{vm_model.cid}' running job instance '#{self}'" +
488
+ " in resource pool `#{resource_pool.name}'" +
489
+ " with reservation '#{reservation}'")
484
490
  vm.model = vm_model
485
491
  vm.bound_instance = self
486
492
  vm.current_state = state
493
+ vm.use_reservation(reservation)
487
494
 
488
495
  @vm = vm
489
496
  end
@@ -69,6 +69,10 @@ module Bosh::Director
69
69
  @reserved_errand_capacity = 0
70
70
  end
71
71
 
72
+ def vms
73
+ @allocated_vms + @idle_vms
74
+ end
75
+
72
76
  # Returns resource pools spec as Hash (usually for agent to serialize)
73
77
  # @return [Hash] Resource pool spec
74
78
  def spec
@@ -94,12 +98,24 @@ module Bosh::Director
94
98
  end
95
99
  end
96
100
 
101
+ # Attempts to allocate a dynamic IP addresses for all VMs
102
+ # (unless they already have one).
103
+ def reserve_dynamic_networks
104
+ vms.each do |vm|
105
+ unless vm.has_network_reservation?
106
+ instance = vm.bound_instance
107
+ origin = instance ? "Job instance `#{instance}' in resource pool `#{@name}'" : nil
108
+ vm.network_reservation = reserve_dynamic_network(origin)
109
+ end
110
+ end
111
+ end
112
+
97
113
  # Tries to obtain one dynamic reservation in its own network
98
114
  # @raise [NetworkReservationError]
99
115
  # @return [NetworkReservation] Obtained reservation
100
- def reserve_dynamic_network
116
+ def reserve_dynamic_network(origin="Resource pool `#{@name}'")
101
117
  reservation = NetworkReservation.new_dynamic
102
- @network.reserve!(reservation, "Resource pool `#{@name}'")
118
+ @network.reserve!(reservation, origin)
103
119
  reservation
104
120
  end
105
121
 
@@ -89,7 +89,6 @@ module Bosh::Director
89
89
  # @return void
90
90
  def handle_error(origin)
91
91
  if static?
92
- formatted_ip = ip_to_netaddr(@ip).ip
93
92
  case @error
94
93
  when NetworkReservation::USED
95
94
  raise NetworkReservationAlreadyInUse,
@@ -117,5 +116,15 @@ module Bosh::Director
117
116
  end
118
117
  end
119
118
  end
119
+
120
+ def to_s
121
+ "{type=#{@type}, ip=#{formatted_ip.inspect}}"
122
+ end
123
+
124
+ private
125
+
126
+ def formatted_ip
127
+ @ip.nil? ? nil : ip_to_netaddr(@ip).ip
128
+ end
120
129
  end
121
- end
130
+ end
@@ -17,7 +17,7 @@ module Bosh::Director
17
17
  counter = 0
18
18
  vms_to_process = []
19
19
 
20
- each_vm do |vm|
20
+ @resource_pool.vms.each do |vm|
21
21
  next if vm.model
22
22
  if !block_given? || yield(vm)
23
23
  counter += 1
@@ -132,49 +132,13 @@ module Bosh::Director
132
132
  # in case any of resource pools is not big enough to accommodate
133
133
  # those VMs.
134
134
  def reserve_networks
135
- network = @resource_pool.network
136
-
137
- each_vm_with_index do |vm, index|
138
- unless vm.network_reservation
139
- reservation = NetworkReservation.new(
140
- :type => NetworkReservation::DYNAMIC)
141
- network.reserve(reservation)
142
-
143
- unless reservation.reserved?
144
- case reservation.error
145
- when NetworkReservation::CAPACITY
146
- raise NetworkReservationNotEnoughCapacity,
147
- "'#{@resource_pool.name}/#{index}' asked for a dynamic IP " +
148
- "but there were no more available"
149
- else
150
- raise NetworkReservationError,
151
- "'#{@resource_pool.name}/#{index}' failed to reserve " +
152
- "dynamic IP: #{reservation.error}"
153
- end
154
- end
155
-
156
- vm.network_reservation = reservation
157
- end
158
- end
135
+ @resource_pool.reserve_dynamic_networks
159
136
  end
160
137
 
161
138
  def generate_agent_id
162
139
  SecureRandom.uuid
163
140
  end
164
141
 
165
- def each_vm
166
- @resource_pool.allocated_vms.each { |vm| yield vm }
167
- @resource_pool.idle_vms.each { |vm| yield vm }
168
- end
169
-
170
- def each_vm_with_index
171
- index = 0
172
- each_vm do |vm|
173
- yield(vm, index)
174
- index += 1
175
- end
176
- end
177
-
178
142
  def extra_vm_count
179
143
  @resource_pool.extra_vm_count
180
144
  end
@@ -189,7 +153,7 @@ module Bosh::Director
189
153
 
190
154
  def missing_vm_count
191
155
  counter = 0
192
- each_vm do |vm|
156
+ @resource_pool.vms.each do |vm|
193
157
  next if vm.model
194
158
  counter += 1
195
159
  end
@@ -198,7 +162,7 @@ module Bosh::Director
198
162
 
199
163
  def bound_missing_vm_count
200
164
  counter = 0
201
- each_vm do |vm|
165
+ @resource_pool.vms.each do |vm|
202
166
  next if vm.model
203
167
  next if vm.bound_instance.nil?
204
168
  counter += 1
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Director
3
- VERSION = '1.2686.0'
3
+ VERSION = '1.2690.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2686.0
4
+ version: 1.2690.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
@@ -30,140 +30,140 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2686.0
33
+ version: 1.2690.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2686.0
40
+ version: 1.2690.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bosh-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2686.0
47
+ version: 1.2690.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2686.0
54
+ version: 1.2690.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bosh-director-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2686.0
61
+ version: 1.2690.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2686.0
68
+ version: 1.2690.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bosh_common
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.2686.0
75
+ version: 1.2690.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.2686.0
82
+ version: 1.2690.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bosh-template
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.2686.0
89
+ version: 1.2690.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.2686.0
96
+ version: 1.2690.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bosh_cpi
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.2686.0
103
+ version: 1.2690.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.2686.0
110
+ version: 1.2690.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bosh_openstack_cpi
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2686.0
117
+ version: 1.2690.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.2686.0
124
+ version: 1.2690.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bosh_aws_cpi
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.2686.0
131
+ version: 1.2690.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.2686.0
138
+ version: 1.2690.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: bosh_vsphere_cpi
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.2686.0
145
+ version: 1.2690.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.2686.0
152
+ version: 1.2690.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: bosh_warden_cpi
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.2686.0
159
+ version: 1.2690.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.2686.0
166
+ version: 1.2690.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: bosh_vcloud_cpi
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -460,7 +460,7 @@ dependencies:
460
460
  version: '0'
461
461
  description: |-
462
462
  BOSH Director
463
- b748e0
463
+ 03d2f5
464
464
  email: support@cloudfoundry.com
465
465
  executables:
466
466
  - bosh-director