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 +14 -4
- data/config/openstack_defaults.yml +4 -0
- data/lib/bosh/cli/commands/micro.rb +56 -77
- data/lib/deployer/config.rb +1 -1
- data/lib/deployer/instance_manager/openstack.rb +29 -11
- data/lib/deployer/version.rb +1 -1
- metadata +8 -8
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
|
-
|
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 --
|
41
|
+
t.rspec_opts = %w(--format progress --color)
|
42
42
|
end
|
43
43
|
|
44
44
|
CiTask.new do |task|
|
45
|
-
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
|
@@ -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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
26
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
57
|
-
|
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
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
192
|
-
|
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
|
data/lib/deployer/config.rb
CHANGED
@@ -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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
149
|
-
|
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
|
data/lib/deployer/version.rb
CHANGED
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:
|
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-
|
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
|
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
|
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.
|
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.
|
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: -
|
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: -
|
205
|
+
hash: -4201748784491997897
|
206
206
|
requirements: []
|
207
207
|
rubyforge_project:
|
208
208
|
rubygems_version: 1.8.24
|