bosh_deployer 0.6.0 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -36,16 +36,26 @@ BundlerTask.new
36
36
  if defined?(RSpec)
37
37
  namespace :spec do
38
38
  desc "Run Unit Tests"
39
- rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
39
+ unit_rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
40
40
  t.pattern = "spec/unit/**/*_spec.rb"
41
- t.rspec_opts = %w(--format progress --colour)
41
+ t.rspec_opts = %w(--format progress --color)
42
42
  end
43
43
 
44
44
  CiTask.new do |task|
45
- task.rspec_task = rspec_task
45
+ task.rspec_task = unit_rspec_task
46
+ end
47
+
48
+ desc "Run Integration Tests"
49
+ functional_rspec_task = RSpec::Core::RakeTask.new(:functional) do |t|
50
+ t.pattern = "spec/functional/**/*_spec.rb"
51
+ t.rspec_opts = %w(--format progress --color)
52
+ end
53
+
54
+ CiTask.new do |task|
55
+ task.rspec_task = functional_rspec_task
46
56
  end
47
57
  end
48
58
 
49
59
  desc "Install dependencies and run tests"
50
- task :spec => %w(bundler:install:test spec:unit)
60
+ task :spec => %w(bundler:install:test spec:unit spec:functional)
51
61
  end
@@ -8,6 +8,7 @@ dir:
8
8
 
9
9
  network:
10
10
  type: dynamic
11
+ label: private
11
12
  cloud_properties: {}
12
13
 
13
14
  env:
@@ -48,3 +49,6 @@ cloud:
48
49
 
49
50
  apply_spec:
50
51
  properties: {}
52
+ agent:
53
+ blobstore: {}
54
+ nats: {}
@@ -10,54 +10,61 @@ module Bosh::Cli::Command
10
10
  MICRO_DIRECTOR_PORT = 25555
11
11
  DEFAULT_CONFIG_PATH = File.expand_path("~/.bosh_deployer_config")
12
12
 
13
- command :micro_deployment do
14
- usage "micro deployment [<name>]"
15
- desc "Choose micro deployment to work with"
16
- route { |args| (args.size > 0) ? [:micro, :set_current] : [:micro, :show_current] }
13
+ def initialize(runner)
14
+ super(runner)
15
+ options[:config] ||= DEFAULT_CONFIG_PATH #hijack Cli::Config
17
16
  end
18
17
 
19
- command :micro_status do
20
- usage "micro status"
21
- desc "Display micro BOSH deployment status"
22
- route :micro, :status
18
+ usage "micro deployment"
19
+ desc "Choose micro deployment to work with, or display current deployment"
20
+ def micro_deployment(name=nil)
21
+ if name
22
+ set_current(name)
23
+ else
24
+ show_current
25
+ end
23
26
  end
24
27
 
25
- command :micro_list_deployments do
26
- usage "micro deployments"
27
- desc "Show the list of deployments"
28
- route :micro, :list
29
- end
28
+ def set_current(name)
29
+ manifest_filename = find_deployment(name)
30
30
 
31
- command :micro_deploy do
32
- usage "micro deploy [<stemcell>]"
33
- desc "Deploy a micro BOSH instance to the currently selected deployment"
34
- option "--update", "update existing instance"
35
- route :micro, :perform
36
- end
31
+ if !File.exists?(manifest_filename)
32
+ err "Missing manifest for #{name} (tried '#{manifest_filename}')"
33
+ end
37
34
 
38
- command :micro_delete do
39
- usage "micro delete"
40
- desc "Delete micro BOSH instance (including persistent disk)"
41
- route :micro, :delete
42
- end
35
+ manifest = load_yaml_file(manifest_filename)
43
36
 
44
- command :micro_agent do
45
- usage "micro agent <args>"
46
- desc "Send agent messages"
47
- route :micro, :agent
48
- end
37
+ unless manifest.is_a?(Hash)
38
+ err "Invalid manifest format"
39
+ end
40
+
41
+ if manifest["network"].blank?
42
+ err "network is not defined in deployment manifest"
43
+ end
44
+ ip = deployer(manifest_filename).discover_bosh_ip || name
45
+
46
+ if target
47
+ old_director_ip = URI.parse(target).host
48
+ else
49
+ old_director_ip = nil
50
+ end
49
51
 
50
- command :micro_apply do
51
- usage "micro apply <spec>"
52
- desc "Apply spec"
53
- route :micro, :apply
52
+ if old_director_ip != ip
53
+ set_target(ip)
54
+ say "#{"WARNING!".red} Your target has been changed to `#{target.red}'!"
55
+ end
56
+
57
+ say "Deployment set to '#{manifest_filename.green}'"
58
+ config.set_deployment(manifest_filename)
59
+ config.save
54
60
  end
55
61
 
56
- def initialize(options = {})
57
- options[:config] ||= DEFAULT_CONFIG_PATH #hijack Cli::Config
58
- super(options)
62
+ def show_current
63
+ say(deployment ? "Current deployment is '#{deployment.green}'" : "Deployment not set")
59
64
  end
60
65
 
66
+ usage "micro status"
67
+ desc "Display micro BOSH deployment status"
61
68
  def status
62
69
  stemcell_cid = deployer_state(:stemcell_cid)
63
70
  stemcell_name = deployer_state(:stemcell_name)
@@ -78,9 +85,11 @@ module Bosh::Cli::Command
78
85
  say("Target".ljust(15) + target_name)
79
86
  end
80
87
 
81
- def perform(*options)
82
- update = options.delete("--update")
83
- stemcell = options.shift
88
+ usage "micro deploy"
89
+ desc "Deploy a micro BOSH instance to the currently selected deployment"
90
+ option "--update", "update existing instance"
91
+ def perform(stemcell=nil)
92
+ update = !!options[:update]
84
93
 
85
94
  err "No deployment set" unless deployment
86
95
 
@@ -158,6 +167,8 @@ module Bosh::Cli::Command
158
167
  say("Deployed #{desc}, took #{format_time(duration).green} to complete")
159
168
  end
160
169
 
170
+ usage "micro delete"
171
+ desc "Delete micro BOSH instance (including persistent disk)"
161
172
  def delete
162
173
  unless deployer.exists?
163
174
  err "No existing instance to delete"
@@ -188,44 +199,8 @@ module Bosh::Cli::Command
188
199
  say("Deleted deployment '#{name}', took #{format_time(duration).green} to complete")
189
200
  end
190
201
 
191
- def set_current(name)
192
- manifest_filename = find_deployment(name)
193
-
194
- if !File.exists?(manifest_filename)
195
- err "Missing manifest for #{name} (tried '#{manifest_filename}')"
196
- end
197
-
198
- manifest = load_yaml_file(manifest_filename)
199
-
200
- unless manifest.is_a?(Hash)
201
- err "Invalid manifest format"
202
- end
203
-
204
- if manifest["network"].blank?
205
- err "network is not defined in deployment manifest"
206
- end
207
- ip = deployer(manifest_filename).discover_bosh_ip || name
208
-
209
- if target
210
- old_director_ip = URI.parse(target).host
211
- else
212
- old_director_ip = nil
213
- end
214
-
215
- if old_director_ip != ip
216
- set_target(ip)
217
- say "#{"WARNING!".red} Your target has been changed to `#{target.red}'!"
218
- end
219
-
220
- say "Deployment set to '#{manifest_filename.green}'"
221
- config.set_deployment(manifest_filename)
222
- config.save
223
- end
224
-
225
- def show_current
226
- say(deployment ? "Current deployment is '#{deployment.green}'" : "Deployment not set")
227
- end
228
-
202
+ usage "micro deployments"
203
+ desc "Show the list of deployments"
229
204
  def list
230
205
  file = File.join(work_dir, DEPLOYMENTS_FILE)
231
206
  if File.exists?(file)
@@ -251,6 +226,8 @@ module Bosh::Cli::Command
251
226
  say("Deployments total: %d" % deployments.size)
252
227
  end
253
228
 
229
+ usage "micro agent <args>"
230
+ desc "Send agent messages"
254
231
  def agent(*args)
255
232
  message = args.shift
256
233
  args = args.map do |arg|
@@ -264,6 +241,8 @@ module Bosh::Cli::Command
264
241
  say(deployer.agent.send(message.to_sym, *args).pretty_inspect)
265
242
  end
266
243
 
244
+ usage "micro apply"
245
+ desc "Apply spec"
267
246
  def apply(spec)
268
247
  deployer.apply(load_yaml_file(spec))
269
248
  end
@@ -10,7 +10,7 @@ module Bosh::Deployer
10
10
  include Helpers
11
11
 
12
12
  attr_accessor :logger, :db, :uuid, :resources, :cloud_options,
13
- :spec_properties, :agent_properties, :bosh_ip, :env, :name
13
+ :spec_properties, :agent_properties, :bosh_ip, :env, :name, :net_conf
14
14
 
15
15
  def configure(config)
16
16
  plugin = cloud_plugin(config)
@@ -129,15 +129,20 @@ module Bosh::Deployer
129
129
  def discover_bosh_ip
130
130
  if exists?
131
131
  server = cloud.openstack.servers.get(state.vm_cid)
132
- ip = server.public_ip_address
133
- ip = server.private_ip_address if ip.nil? || ip.empty?
134
- if ip.nil? || ip.empty?
135
- raise "Unable to discover bosh ip"
136
- else
137
- if ip["addr"] != Config.bosh_ip
138
- Config.bosh_ip = ip["addr"]
139
- logger.info("discovered bosh ip=#{Config.bosh_ip}")
140
- end
132
+ # LP OpenStack Nova 185110:
133
+ # Since OS API 1.1, server addresses exposes the network names
134
+ # instead of the network types. so we need to fetch the
135
+ # os-floating-ips and find if any of them is associated to the
136
+ # server in order to get its public address.
137
+ floating_ip = cloud.openstack.addresses.find {
138
+ |addr| addr.instance_id == server.id
139
+ }
140
+ ip = floating_ip.nil? ? service_ip : floating_ip.ip
141
+ raise "Unable to discover bosh ip" if ip.nil?
142
+
143
+ if ip != Config.bosh_ip
144
+ Config.bosh_ip = ip
145
+ logger.info("discovered bosh ip=#{Config.bosh_ip}")
141
146
  end
142
147
  end
143
148
 
@@ -145,8 +150,21 @@ module Bosh::Deployer
145
150
  end
146
151
 
147
152
  def service_ip
148
- ip = cloud.openstack.servers.get(state.vm_cid).private_ip_address
149
- ip["addr"] unless ip.nil? || ip.empty?
153
+ server = cloud.openstack.servers.get(state.vm_cid)
154
+ # LP OpenStack Nova 185110:
155
+ # Since OS API 1.1, server addresses exposes the network names
156
+ # instead of the network types, so we need to known which network
157
+ # label is used in OS (label parm or "private" by default) to fetch
158
+ # the service IP address.
159
+ net_conf = Config.net_conf
160
+ net_label = net_conf["label"].nil? ? "private" : net_conf["label"]
161
+ ip_addresses = server.addresses[net_label]
162
+ unless ip_addresses.nil? || ip_addresses.empty?
163
+ address = ip_addresses.select { |ip| ip["version"] == 4 }.first
164
+ ip = address ? address["addr"] : nil
165
+ end
166
+ raise "Unable to discover service ip" if ip.nil?
167
+ ip
150
168
  end
151
169
 
152
170
  # @return [Integer] size in MiB
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Deployer
5
- VERSION = "0.6.0"
5
+ VERSION = "1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: '1.0'
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: 2012-09-05 00:00:00.000000000 Z
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_cli
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.19.5
21
+ version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.19.5
29
+ version: '1.0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bosh_cpi
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 0.4.9
53
+ version: 0.5.0
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: 0.4.9
61
+ version: 0.5.0
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_aws_cpi
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  segments:
195
195
  - 0
196
- hash: -914290662432326556
196
+ hash: -4201748784491997897
197
197
  required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  none: false
199
199
  requirements:
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  segments:
204
204
  - 0
205
- hash: -914290662432326556
205
+ hash: -4201748784491997897
206
206
  requirements: []
207
207
  rubyforge_project:
208
208
  rubygems_version: 1.8.24