tengine_resource 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +30 -0
- data/Gemfile.lock +106 -0
- data/README.rdoc +20 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/bin/tengine_resource_watchd +8 -0
- data/config/.gitignore +2 -0
- data/config/watchd.yml.erb.example +52 -0
- data/lib/tengine/resource.rb +29 -0
- data/lib/tengine/resource/config.rb +6 -0
- data/lib/tengine/resource/config/resource.rb +194 -0
- data/lib/tengine/resource/credential.rb +156 -0
- data/lib/tengine/resource/credential/ec2.rb +5 -0
- data/lib/tengine/resource/credential/ec2/dummy.rb +148 -0
- data/lib/tengine/resource/credential/ec2/launch_options.rb +179 -0
- data/lib/tengine/resource/drivers/resource_control_driver.rb +58 -0
- data/lib/tengine/resource/net_ssh.rb +134 -0
- data/lib/tengine/resource/observer.rb +25 -0
- data/lib/tengine/resource/physical_server.rb +7 -0
- data/lib/tengine/resource/provider.rb +82 -0
- data/lib/tengine/resource/provider/ec2.rb +187 -0
- data/lib/tengine/resource/provider/wakame.rb +615 -0
- data/lib/tengine/resource/server.rb +62 -0
- data/lib/tengine/resource/virtual_server.rb +62 -0
- data/lib/tengine/resource/virtual_server_image.rb +34 -0
- data/lib/tengine/resource/virtual_server_type.rb +21 -0
- data/lib/tengine/resource/watcher.rb +121 -0
- data/lib/tengine_resource.rb +4 -0
- data/spec/fixtures/goku_at_ec2_ap_northeast.rb +177 -0
- data/spec/mongoid.yml +35 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/ec2.rb +129 -0
- data/spec/support/mongo_index_key_log.rb +91 -0
- data/spec/tengine/resource/bugfix/watcher_for_wakame_spec.rb +232 -0
- data/spec/tengine/resource/credential_spec.rb +205 -0
- data/spec/tengine/resource/drivers/resource_control_driver_spec.rb +84 -0
- data/spec/tengine/resource/net_ssh_spec.rb +148 -0
- data/spec/tengine/resource/physical_server_spec.rb +47 -0
- data/spec/tengine/resource/provider/ec2_spec.rb +473 -0
- data/spec/tengine/resource/provider/test_files/describe_host_nodes.json +22 -0
- data/spec/tengine/resource/provider/test_files/describe_images.json +23 -0
- data/spec/tengine/resource/provider/test_files/describe_instance_specs.json +23 -0
- data/spec/tengine/resource/provider/test_files/describe_instances.json +56 -0
- data/spec/tengine/resource/provider/test_files/run_instances.json +30 -0
- data/spec/tengine/resource/provider/test_files/terminate_instances.json +3 -0
- data/spec/tengine/resource/provider/wakame/00_describe_host_nodes_0_physical_servers.json +8 -0
- data/spec/tengine/resource/provider/wakame/01_describe_host_nodes_10_physical_servers.json +139 -0
- data/spec/tengine/resource/provider/wakame/02_describe_host_nodes_60_physical_servers.json +795 -0
- data/spec/tengine/resource/provider/wakame/10_describe_instances_0_virtual_servers.json +8 -0
- data/spec/tengine/resource/provider/wakame/11_describe_instances_10_virtual_servers.json +469 -0
- data/spec/tengine/resource/provider/wakame/12_describe_instances_after_run_instances.json +280 -0
- data/spec/tengine/resource/provider/wakame/13_describe_instances_after_terminate_instances.json +279 -0
- data/spec/tengine/resource/provider/wakame/20_describe_images_0_virtual_server_images.json +8 -0
- data/spec/tengine/resource/provider/wakame/21_describe_images_5_virtual_server_images.json +84 -0
- data/spec/tengine/resource/provider/wakame/22_describe_images_60_virtual_server_images.json +856 -0
- data/spec/tengine/resource/provider/wakame/30_describe_instance_specs_0_virtual_server_specs.json +8 -0
- data/spec/tengine/resource/provider/wakame/31_describe_instance_specs_4_virtual_server_specs.json +66 -0
- data/spec/tengine/resource/provider/wakame/40_run_instances_0_virtual_servers.json +1 -0
- data/spec/tengine/resource/provider/wakame/41_run_instances_1_virtual_servers.json +22 -0
- data/spec/tengine/resource/provider/wakame/42_run_instances_5_virtual_servers.json +106 -0
- data/spec/tengine/resource/provider/wakame/50_terminate_instances_0_virtual_servers.json +1 -0
- data/spec/tengine/resource/provider/wakame/51_terminate_instances_3_virtual_servers.json +5 -0
- data/spec/tengine/resource/provider/wakame/sync_physical_servers_spec.rb +114 -0
- data/spec/tengine/resource/provider/wakame/sync_virtual_server_images_spec.rb +116 -0
- data/spec/tengine/resource/provider/wakame/sync_virtual_server_types_spec.rb +116 -0
- data/spec/tengine/resource/provider/wakame/sync_virtual_servers_spec.rb +216 -0
- data/spec/tengine/resource/provider/wakame_api_spec.rb +319 -0
- data/spec/tengine/resource/provider/wakame_spec.rb +339 -0
- data/spec/tengine/resource/provider_spec.rb +252 -0
- data/spec/tengine/resource/server_spec.rb +195 -0
- data/spec/tengine/resource/test_files/.gitignore +6 -0
- data/spec/tengine/resource/test_files/00_describe_host_nodes_0_physical_servers.json +8 -0
- data/spec/tengine/resource/test_files/01_describe_host_nodes_10_physical_servers.json +139 -0
- data/spec/tengine/resource/test_files/02_describe_host_nodes_60_physical_servers.json +795 -0
- data/spec/tengine/resource/test_files/10_describe_instances_0_virtual_servers.json +8 -0
- data/spec/tengine/resource/test_files/11_describe_instances_10_virtual_servers.json +469 -0
- data/spec/tengine/resource/test_files/12_describe_instances_after_run_instances.json +280 -0
- data/spec/tengine/resource/test_files/13_describe_instances_after_terminate_instances.json +279 -0
- data/spec/tengine/resource/test_files/14_describe_instances_after_run_1_instance.json +55 -0
- data/spec/tengine/resource/test_files/20_describe_images_0_virtual_server_images.json +8 -0
- data/spec/tengine/resource/test_files/21_describe_images_5_virtual_server_images.json +84 -0
- data/spec/tengine/resource/test_files/22_describe_images_60_virtual_server_images.json +856 -0
- data/spec/tengine/resource/test_files/30_describe_instance_specs_0_virtual_server_specs.json +8 -0
- data/spec/tengine/resource/test_files/31_describe_instance_specs_4_virtual_server_specs.json +66 -0
- data/spec/tengine/resource/test_files/40_run_instances_0_virtual_servers.json +1 -0
- data/spec/tengine/resource/test_files/41_run_instances_1_virtual_servers.json +22 -0
- data/spec/tengine/resource/test_files/42_run_instances_5_virtual_servers.json +106 -0
- data/spec/tengine/resource/test_files/43_run_instances_1_virtual_servers_without_aws_availability_zone.json +22 -0
- data/spec/tengine/resource/test_files/50_terminate_instances_0_virtual_servers.json +1 -0
- data/spec/tengine/resource/test_files/51_terminate_instances_3_virtual_servers.json +5 -0
- data/spec/tengine/resource/virtual_server_image_spec.rb +94 -0
- data/spec/tengine/resource/virtual_server_spec.rb +116 -0
- data/spec/tengine/resource/virtual_server_type_spec.rb +4 -0
- data/spec/tengine/resource/watcher_spec.rb +1026 -0
- data/spec/tengine_resource_spec.rb +5 -0
- data/tengine_resource.gemspec +171 -0
- data/tmp/log/.gitignore +1 -0
- metadata +286 -0
@@ -0,0 +1,1026 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'amqp'
|
5
|
+
require 'tengine/mq/suite'
|
6
|
+
require 'apis/wakame'
|
7
|
+
require 'controllers/controller'
|
8
|
+
|
9
|
+
describe Tengine::Resource::Watcher do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@mq_config = {
|
13
|
+
:connection => {
|
14
|
+
:host => "localhost", :port => 5672, :vhost => "/",
|
15
|
+
:user => "guest", :pass => "guest", :logging => false,
|
16
|
+
:insist => false, :auto_reconnect_delay => 1
|
17
|
+
},
|
18
|
+
:exchange => {
|
19
|
+
:name => "tengine_event_exchange", :type => "direct", :durable => true
|
20
|
+
},
|
21
|
+
:queue => {
|
22
|
+
:name => "tengine_event_queue", :durable => true
|
23
|
+
},
|
24
|
+
:sender => {
|
25
|
+
:keep_connection => true
|
26
|
+
},
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
after :all do
|
31
|
+
Mongoid.instance_eval do
|
32
|
+
observers.each do |i|
|
33
|
+
i.instance.send(:observed_classes).each do |j|
|
34
|
+
Mongoid::Callbacks::CALLBACKS.each do |k|
|
35
|
+
x, y = k.to_s.split '_', 2
|
36
|
+
j.send :reset_callbacks, y#, x
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe :initialize do
|
44
|
+
it "default" do
|
45
|
+
Tengine::Core::MethodTraceable.stub(:disabled=)
|
46
|
+
watcher = Tengine::Resource::Watcher.new(%w[--log-common-level warn])
|
47
|
+
watcher.config[:process]['daemon'].should == false
|
48
|
+
watcher.config[:process][:daemon].should == false
|
49
|
+
watcher.config[:event_queue][:connection][:host].should == "localhost"
|
50
|
+
watcher.config['event_queue']['connection']['host'].should == "localhost"
|
51
|
+
watcher.config[:event_queue][:queue][:name].should == "tengine_event_queue"
|
52
|
+
watcher.config['event_queue']['queue']['name'].should == "tengine_event_queue"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe :sender do
|
57
|
+
before do
|
58
|
+
@watcher = Tengine::Resource::Watcher.new(%w[--log-common-level warn])
|
59
|
+
EM.should_receive(:run).and_yield
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
it "生成したmq_suiteが設定されている" do
|
64
|
+
mock_mq = Tengine::Mq::Suite.new(@mq_config)
|
65
|
+
Tengine::Mq::Suite.should_receive(:new).
|
66
|
+
with(@mq_config).and_return(mock_mq)
|
67
|
+
|
68
|
+
@watcher.sender.should_receive(:wait_for_connection)
|
69
|
+
@watcher.start
|
70
|
+
@watcher.mq_suite.should == mock_mq
|
71
|
+
end
|
72
|
+
|
73
|
+
it "生成したsenderが設定されている" do
|
74
|
+
mock_mq = Tengine::Mq::Suite.new(@mq_config)
|
75
|
+
Tengine::Mq::Suite.should_receive(:new).
|
76
|
+
with(@mq_config).and_return(mock_mq)
|
77
|
+
|
78
|
+
mock_sender = mock(:sender)
|
79
|
+
Tengine::Event::Sender.should_receive(:new).with(mock_mq).and_return(mock_sender)
|
80
|
+
|
81
|
+
@watcher.sender.should_receive(:wait_for_connection)
|
82
|
+
@watcher.start
|
83
|
+
@watcher.sender.should == mock_sender
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe :start do
|
88
|
+
before do
|
89
|
+
@watcher = Tengine::Resource::Watcher.new(%w[--log-common-level warn])
|
90
|
+
EM.should_receive(:run).and_yield
|
91
|
+
EM.stub(:schedule).and_yield
|
92
|
+
|
93
|
+
# コネクションの mock を生成
|
94
|
+
@mock_mq = Tengine::Mq::Suite.new(@mq_config)
|
95
|
+
Tengine::Mq::Suite.should_receive(:new).
|
96
|
+
with(@mq_config).and_return(@mock_mq)
|
97
|
+
|
98
|
+
Tengine::Resource::Provider.delete_all
|
99
|
+
@provider_ec2 = Tengine::Resource::Provider::Ec2.create!({
|
100
|
+
:name => "amazon-ec2",
|
101
|
+
:description => "",
|
102
|
+
:properties => {
|
103
|
+
},
|
104
|
+
:polling_interval => 5,
|
105
|
+
:connection_settings => {
|
106
|
+
:access_key => "",
|
107
|
+
:secret_access_key => "",
|
108
|
+
:options => {
|
109
|
+
:server => "ec2.amazonaws.com",
|
110
|
+
:port => 443,
|
111
|
+
:protocol => "https",
|
112
|
+
:multi_thread => false,
|
113
|
+
:logger => nil,
|
114
|
+
:signature_version => '1',
|
115
|
+
:cache => false,
|
116
|
+
}
|
117
|
+
}
|
118
|
+
})
|
119
|
+
@provider_wakame = Tengine::Resource::Provider::Wakame.create!({
|
120
|
+
:name => "wakame-vdc",
|
121
|
+
:description => "",
|
122
|
+
:properties => {
|
123
|
+
:key_name => "ssh-xxxxx"
|
124
|
+
},
|
125
|
+
:polling_interval => 5,
|
126
|
+
:connection_settings => {
|
127
|
+
:account => "tama_account1",
|
128
|
+
:ec2_host => "10.10.10.10",
|
129
|
+
:ec2_port => 80,
|
130
|
+
:ec2_protocol => "https",
|
131
|
+
:wakame_host => "192.168.0.10",
|
132
|
+
:wakame_port => 8080,
|
133
|
+
:wakame_protocol => "http",
|
134
|
+
},
|
135
|
+
})
|
136
|
+
end
|
137
|
+
|
138
|
+
it "flow" do
|
139
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
140
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame, @provider_ec2])
|
141
|
+
|
142
|
+
@provider_wakame.should_receive(:virtual_server_type_watch)
|
143
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
144
|
+
# EM.should_receive(:defer).twice.and_yield
|
145
|
+
@provider_wakame.should_receive(:physical_server_watch)
|
146
|
+
@provider_wakame.should_receive(:virtual_server_watch)
|
147
|
+
@provider_wakame.should_receive(:virtual_server_image_watch)
|
148
|
+
|
149
|
+
@provider_ec2.should_receive(:virtual_server_type_watch)
|
150
|
+
EM.should_receive(:add_periodic_timer).with(@provider_ec2.polling_interval).and_yield
|
151
|
+
@provider_ec2.should_receive(:physical_server_watch)
|
152
|
+
@provider_ec2.should_receive(:virtual_server_watch)
|
153
|
+
@provider_ec2.should_receive(:virtual_server_image_watch)
|
154
|
+
|
155
|
+
@watcher.start
|
156
|
+
end
|
157
|
+
|
158
|
+
# 仮想サーバタイプ
|
159
|
+
describe :virtual_server_type_watch do
|
160
|
+
before do
|
161
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
162
|
+
"Tengine::Resource::VirtualServerType.created.tengine_resource_watchd",
|
163
|
+
anything())
|
164
|
+
|
165
|
+
Tengine::Resource::VirtualServerType.delete_all
|
166
|
+
@virtual_server_type_wakame = @provider_wakame.virtual_server_types.create!({
|
167
|
+
:provided_id => "is-demospec",
|
168
|
+
:caption => "is-demospec",
|
169
|
+
:cpu_cores => 2,
|
170
|
+
:memory_size => 512,
|
171
|
+
:properties => {
|
172
|
+
:arch => "x86_64",
|
173
|
+
:hypervisor => "kvm",
|
174
|
+
:account_id => "a-shpoolxx",
|
175
|
+
:vifs => "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
176
|
+
:quota_weight => "1.0",
|
177
|
+
:drives => "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n",
|
178
|
+
:created_at => "2011-10-28T02:58:57Z",
|
179
|
+
:updated_at => "2011-10-28T02:58:57Z",
|
180
|
+
}
|
181
|
+
})
|
182
|
+
|
183
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
184
|
+
end
|
185
|
+
|
186
|
+
context "wakame" do
|
187
|
+
before do
|
188
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
189
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval)
|
190
|
+
|
191
|
+
@tama_controller_factory = mock(::Tama::Controllers::ControllerFactory.allocate)
|
192
|
+
::Tama::Controllers::ControllerFactory.
|
193
|
+
should_receive(:create_controller).
|
194
|
+
with("tama_account1", "10.10.10.10", 80, "https", "192.168.0.10", 8080, "http").
|
195
|
+
and_return(@tama_controller_factory)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
199
|
+
@tama_controller_factory.
|
200
|
+
should_receive(:describe_instance_specs).with([]).
|
201
|
+
and_return(UPDATE_WAKAME_INSTANCE_SPECS)
|
202
|
+
|
203
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
204
|
+
"Tengine::Resource::VirtualServerType.updated.tengine_resource_watchd",
|
205
|
+
anything())
|
206
|
+
|
207
|
+
@virtual_server_type_wakame.cpu_cores.should == 2
|
208
|
+
@virtual_server_type_wakame.memory_size.should == 512
|
209
|
+
|
210
|
+
@watcher.start
|
211
|
+
|
212
|
+
@provider_wakame.reload
|
213
|
+
new_server_type = @provider_wakame.virtual_server_types.first
|
214
|
+
new_server_type.cpu_cores.should == 1
|
215
|
+
new_server_type.memory_size.should == 256
|
216
|
+
end
|
217
|
+
|
218
|
+
it "更新対象がなかったらイベントは発火しない" do
|
219
|
+
@tama_controller_factory.
|
220
|
+
should_receive(:describe_instance_specs).with([]).
|
221
|
+
and_return(ORIGINAL_WAKAME_INSTANCE_SPECS)
|
222
|
+
|
223
|
+
Tengine::Event.default_sender.should_not_receive(:fire)
|
224
|
+
|
225
|
+
@virtual_server_type_wakame.cpu_cores.should == 2
|
226
|
+
@virtual_server_type_wakame.memory_size.should == 512
|
227
|
+
|
228
|
+
@watcher.start
|
229
|
+
|
230
|
+
@provider_wakame.reload
|
231
|
+
new_server_type = @provider_wakame.virtual_server_types.first
|
232
|
+
new_server_type.cpu_cores.should == 2
|
233
|
+
new_server_type.memory_size.should == 512
|
234
|
+
end
|
235
|
+
|
236
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
237
|
+
@tama_controller_factory.
|
238
|
+
should_receive(:describe_instance_specs).with([]).
|
239
|
+
and_return(CREATE_WAKAME_INSTANCE_SPECS)
|
240
|
+
|
241
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
242
|
+
"Tengine::Resource::VirtualServerType.created.tengine_resource_watchd",
|
243
|
+
anything())
|
244
|
+
|
245
|
+
expect { @watcher.start }.should change(
|
246
|
+
@provider_wakame.virtual_server_types, :count).by(1)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
250
|
+
@tama_controller_factory.
|
251
|
+
should_receive(:describe_instance_specs).with([]).
|
252
|
+
and_return([])
|
253
|
+
|
254
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
255
|
+
"Tengine::Resource::VirtualServerType.destroyed.tengine_resource_watchd",
|
256
|
+
anything())
|
257
|
+
|
258
|
+
expect { @watcher.start }.should change(
|
259
|
+
@provider_wakame.virtual_server_types, :size).by(-1)
|
260
|
+
end
|
261
|
+
end # end to wakame
|
262
|
+
|
263
|
+
context "ec2" do
|
264
|
+
before do
|
265
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_ec2])
|
266
|
+
EM.should_receive(:add_periodic_timer).with(@provider_ec2.polling_interval)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "実行されない" do
|
270
|
+
@provider_ec2.should_not_receive(:describe_instance_specs_for_api)
|
271
|
+
@watcher.start
|
272
|
+
end
|
273
|
+
end # end to ec2
|
274
|
+
end # end to :virtual_server_type_watch
|
275
|
+
|
276
|
+
# 物理サーバ
|
277
|
+
describe :physical_server_watch do
|
278
|
+
before do
|
279
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
280
|
+
"Tengine::Resource::PhysicalServer.created.tengine_resource_watchd",
|
281
|
+
anything())
|
282
|
+
|
283
|
+
Tengine::Resource::PhysicalServer.delete_all
|
284
|
+
@physical_server_wakame = @provider_wakame.physical_servers.create!({
|
285
|
+
:name => "demohost",
|
286
|
+
:description => "",
|
287
|
+
:provided_id => "hp-demohost",
|
288
|
+
:status => "online",
|
289
|
+
:addresses => {},
|
290
|
+
:address_order => [],
|
291
|
+
:cpu_cores => 100,
|
292
|
+
:memory_size => 400000,
|
293
|
+
:properties => {
|
294
|
+
:uuid => "hp-demohost",
|
295
|
+
:account_id => "a-shpoolxx",
|
296
|
+
:arch => "x86_64",
|
297
|
+
:hypervisor => "kvm",
|
298
|
+
:created_at => "2011-10-18T03:53:24Z",
|
299
|
+
:updated_at => "2011-10-18T03:53:24Z",
|
300
|
+
}
|
301
|
+
})
|
302
|
+
|
303
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
304
|
+
end
|
305
|
+
|
306
|
+
context "wakame" do
|
307
|
+
before do
|
308
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
309
|
+
@provider_wakame.should_receive(:virtual_server_type_watch)
|
310
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
311
|
+
# EM.should_receive(:defer).and_yield
|
312
|
+
@provider_wakame.should_receive(:virtual_server_watch)
|
313
|
+
@provider_wakame.should_receive(:virtual_server_image_watch)
|
314
|
+
|
315
|
+
@tama_controller_factory = mock(::Tama::Controllers::ControllerFactory.allocate)
|
316
|
+
::Tama::Controllers::ControllerFactory.
|
317
|
+
should_receive(:create_controller).
|
318
|
+
with("tama_account1", "10.10.10.10", 80, "https", "192.168.0.10", 8080, "http").
|
319
|
+
and_return(@tama_controller_factory)
|
320
|
+
end
|
321
|
+
|
322
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
323
|
+
@tama_controller_factory.
|
324
|
+
should_receive(:describe_host_nodes).and_return(UPDATE_WAKAME_HOST_NODES)
|
325
|
+
|
326
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
327
|
+
"Tengine::Resource::PhysicalServer.updated.tengine_resource_watchd",
|
328
|
+
anything())
|
329
|
+
|
330
|
+
@physical_server_wakame.cpu_cores.should == 100
|
331
|
+
@physical_server_wakame.memory_size.should == 400000
|
332
|
+
|
333
|
+
@watcher.start
|
334
|
+
|
335
|
+
@provider_wakame.reload
|
336
|
+
new_server = @provider_wakame.physical_servers.first
|
337
|
+
new_server.cpu_cores.should == 75
|
338
|
+
new_server.memory_size.should == 350000
|
339
|
+
end
|
340
|
+
|
341
|
+
it "更新対象がなかったらイベントは発火しない" do
|
342
|
+
@tama_controller_factory.
|
343
|
+
should_receive(:describe_host_nodes).and_return(ORIGINAL_WAKAME_HOST_NODES)
|
344
|
+
|
345
|
+
Tengine::Event.default_sender.should_not_receive(:fire)
|
346
|
+
|
347
|
+
@physical_server_wakame.cpu_cores.should == 100
|
348
|
+
@physical_server_wakame.memory_size.should == 400000
|
349
|
+
|
350
|
+
@watcher.start
|
351
|
+
|
352
|
+
@provider_wakame.reload
|
353
|
+
new_server = @provider_wakame.physical_servers.first
|
354
|
+
new_server.cpu_cores.should == 100
|
355
|
+
new_server.memory_size.should == 400000
|
356
|
+
end
|
357
|
+
|
358
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
359
|
+
@tama_controller_factory.
|
360
|
+
should_receive(:describe_host_nodes).and_return(CREATE_WAKAME_HOST_NODES)
|
361
|
+
|
362
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
363
|
+
"Tengine::Resource::PhysicalServer.created.tengine_resource_watchd",
|
364
|
+
anything())
|
365
|
+
|
366
|
+
expect { @watcher.start }.should change(
|
367
|
+
@provider_wakame.physical_servers, :count).by(1)
|
368
|
+
end
|
369
|
+
|
370
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
371
|
+
@tama_controller_factory.
|
372
|
+
should_receive(:describe_host_nodes).and_return([])
|
373
|
+
|
374
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
375
|
+
"Tengine::Resource::PhysicalServer.destroyed.tengine_resource_watchd",
|
376
|
+
anything())
|
377
|
+
|
378
|
+
expect { @watcher.start }.should change(
|
379
|
+
@provider_wakame.physical_servers, :size).by(-1)
|
380
|
+
end
|
381
|
+
end # end to :wakame
|
382
|
+
|
383
|
+
context "ec2" do
|
384
|
+
before do
|
385
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_ec2])
|
386
|
+
@provider_ec2.should_receive(:virtual_server_type_watch)
|
387
|
+
EM.should_receive(:add_periodic_timer).with(@provider_ec2.polling_interval).and_yield
|
388
|
+
# EM.should_receive(:defer).and_yield
|
389
|
+
# @provider_ec2.should_receive(:physical_server_watch)
|
390
|
+
# @provider_ec2.should_receive(:virtual_server_image_watch)
|
391
|
+
end
|
392
|
+
|
393
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
394
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
395
|
+
end
|
396
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
397
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
398
|
+
end
|
399
|
+
it "更新対象がなかったらイベントは発火しない" do
|
400
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
401
|
+
end
|
402
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
403
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
404
|
+
end
|
405
|
+
end # end to ec2
|
406
|
+
end # end to :phyical_server_watch
|
407
|
+
|
408
|
+
# 仮想サーバ
|
409
|
+
describe :virtual_server_watch do
|
410
|
+
before do
|
411
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
412
|
+
"Tengine::Resource::PhysicalServer.created.tengine_resource_watchd",
|
413
|
+
anything())
|
414
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
415
|
+
"Tengine::Resource::VirtualServer.created.tengine_resource_watchd",
|
416
|
+
anything())
|
417
|
+
|
418
|
+
Tengine::Resource::PhysicalServer.delete_all
|
419
|
+
@physical_server_wakame = @provider_wakame.physical_servers.create!({
|
420
|
+
:name => "demohost",
|
421
|
+
:description => "",
|
422
|
+
:provided_id => "hp-demohost",
|
423
|
+
:status => "online",
|
424
|
+
:addresses => {},
|
425
|
+
:address_order => [],
|
426
|
+
:cpu_cores => 100,
|
427
|
+
:memory_size => 400000,
|
428
|
+
:properties => {
|
429
|
+
:uuid => "hp-demohost",
|
430
|
+
:account_id => "a-shpoolxx",
|
431
|
+
:arch => "x86_64",
|
432
|
+
:hypervisor => "kvm",
|
433
|
+
:created_at => "2011-10-18T03:53:24Z",
|
434
|
+
:updated_at => "2011-10-18T03:53:24Z",
|
435
|
+
}
|
436
|
+
})
|
437
|
+
Tengine::Resource::VirtualServer.delete_all
|
438
|
+
@virtual_server_wakame = @provider_wakame.virtual_servers.create!({
|
439
|
+
:name => "vhost",
|
440
|
+
:description => "",
|
441
|
+
:provided_id => "i-jria301q",
|
442
|
+
:provided_image_id => "wmi-lucid5",
|
443
|
+
:provided_type_id => "is-demospec",
|
444
|
+
:host_server => @physical_server_wakame,
|
445
|
+
:status => "running",
|
446
|
+
:addresses => {
|
447
|
+
"private_ip_address" => "192.168.2.188",
|
448
|
+
"nw-data" => "192.168.2.188",
|
449
|
+
},
|
450
|
+
:address_order => ["private_ip_address"],
|
451
|
+
:properties => {
|
452
|
+
:aws_kernel_id => "",
|
453
|
+
:aws_launch_time => "2011-10-18T06:51:16Z",
|
454
|
+
:tags => {},
|
455
|
+
:aws_reservation_id => "",
|
456
|
+
:aws_owner => "a-shpoolxx",
|
457
|
+
:instance_lifecycle => "",
|
458
|
+
:block_device_mappings => [{
|
459
|
+
:ebs_volume_id => "",
|
460
|
+
:ebs_status => "",
|
461
|
+
:ebs_attach_time => "",
|
462
|
+
:ebs_delete_on_termination => false,
|
463
|
+
:device_name => ""
|
464
|
+
}],
|
465
|
+
:ami_launch_index => "",
|
466
|
+
:root_device_name => "",
|
467
|
+
:aws_ramdisk_id => "",
|
468
|
+
:aws_availability_zone => "hp-demohost",
|
469
|
+
:aws_groups => nil,
|
470
|
+
:spot_instance_request_id => "",
|
471
|
+
:ssh_key_name => nil,
|
472
|
+
:virtualization_type => "",
|
473
|
+
:placement_group_name => "",
|
474
|
+
:requester_id => "",
|
475
|
+
:aws_product_codes => [],
|
476
|
+
:client_token => "",
|
477
|
+
:architecture => "x86_64",
|
478
|
+
:aws_state_code => 0,
|
479
|
+
:root_device_type => "",
|
480
|
+
:monitoring_state => "",
|
481
|
+
:aws_reason => ""
|
482
|
+
}
|
483
|
+
})
|
484
|
+
|
485
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
486
|
+
end
|
487
|
+
|
488
|
+
context "wakame" do
|
489
|
+
before do
|
490
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
491
|
+
@provider_wakame.should_receive(:virtual_server_type_watch)
|
492
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
493
|
+
# EM.should_receive(:defer).and_yield
|
494
|
+
@provider_wakame.should_receive(:physical_server_watch)
|
495
|
+
@provider_wakame.should_receive(:virtual_server_image_watch)
|
496
|
+
|
497
|
+
@tama_controller_factory = mock(::Tama::Controllers::ControllerFactory.allocate)
|
498
|
+
::Tama::Controllers::ControllerFactory.
|
499
|
+
should_receive(:create_controller).
|
500
|
+
with("tama_account1", "10.10.10.10", 80, "https", "192.168.0.10", 8080, "http").
|
501
|
+
and_return(@tama_controller_factory)
|
502
|
+
end
|
503
|
+
|
504
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
505
|
+
@tama_controller_factory.
|
506
|
+
should_receive(:describe_instances).with([]).
|
507
|
+
and_return(UPDATE_WAKAME_INSTANCES)
|
508
|
+
|
509
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
510
|
+
"Tengine::Resource::VirtualServer.updated.tengine_resource_watchd",
|
511
|
+
anything())
|
512
|
+
|
513
|
+
@virtual_server_wakame.status.should == "running"
|
514
|
+
|
515
|
+
@watcher.start
|
516
|
+
|
517
|
+
@provider_wakame.reload
|
518
|
+
new_server = @provider_wakame.virtual_servers.first
|
519
|
+
new_server.status.should == "terminated"
|
520
|
+
end
|
521
|
+
|
522
|
+
it "更新対象がなかったらイベントは発火しない" do
|
523
|
+
@tama_controller_factory.
|
524
|
+
should_receive(:describe_instances).with([]).
|
525
|
+
and_return(ORIGINAL_WAKAME_INSTANCES)
|
526
|
+
|
527
|
+
Tengine::Event.default_sender.should_not_receive(:fire)
|
528
|
+
|
529
|
+
@watcher.start
|
530
|
+
end
|
531
|
+
|
532
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
533
|
+
@tama_controller_factory.
|
534
|
+
should_receive(:describe_instances).with([]).
|
535
|
+
and_return(CREATE_WAKAME_INSTANCES)
|
536
|
+
|
537
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
538
|
+
"Tengine::Resource::VirtualServer.created.tengine_resource_watchd",
|
539
|
+
anything())
|
540
|
+
|
541
|
+
expect {
|
542
|
+
@watcher.start
|
543
|
+
new_virtual_server = (@provider_wakame.virtual_servers - [@virtual_server_wakame]).first
|
544
|
+
new_virtual_server.host_server.provided_id.should == CREATE_WAKAME_INSTANCES[0][:aws_availability_zone]
|
545
|
+
new_virtual_server.host_server.provided_id.should == "hp-demohost"
|
546
|
+
new_virtual_server.hostname_or_ipv4.should == "192.168.2.189"
|
547
|
+
new_virtual_server.host_server.should == @physical_server_wakame
|
548
|
+
}.should change(@provider_wakame.virtual_servers, :count).by(1)
|
549
|
+
end
|
550
|
+
|
551
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
552
|
+
@tama_controller_factory.
|
553
|
+
should_receive(:describe_instances).with([]).
|
554
|
+
and_return([])
|
555
|
+
|
556
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
557
|
+
"Tengine::Resource::VirtualServer.destroyed.tengine_resource_watchd",
|
558
|
+
anything())
|
559
|
+
|
560
|
+
expect { @watcher.start }.should change(
|
561
|
+
@provider_wakame.virtual_servers, :size).by(-1)
|
562
|
+
end
|
563
|
+
end # end to wakame
|
564
|
+
|
565
|
+
context "ec2" do
|
566
|
+
before do
|
567
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_ec2])
|
568
|
+
@provider_ec2.should_receive(:virtual_server_type_watch)
|
569
|
+
EM.should_receive(:add_periodic_timer).with(@provider_ec2.polling_interval).and_yield
|
570
|
+
# EM.should_receive(:defer).and_yield
|
571
|
+
# @provider_ec2.should_receive(:virtual_server_watch)
|
572
|
+
# @provider_ec2.should_receive(:virtual_server_image_watch)
|
573
|
+
end
|
574
|
+
|
575
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
576
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
577
|
+
end
|
578
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
579
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
580
|
+
end
|
581
|
+
it "更新対象がなかったらイベントは発火しない" do
|
582
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
583
|
+
end
|
584
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
585
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
586
|
+
end
|
587
|
+
end # end to ec2
|
588
|
+
end # end to :virtual_server_watch
|
589
|
+
|
590
|
+
# 仮想サーバイメージ
|
591
|
+
describe :virtual_server_image_watch do
|
592
|
+
before do
|
593
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
594
|
+
"Tengine::Resource::VirtualServerImage.created.tengine_resource_watchd",
|
595
|
+
anything())
|
596
|
+
|
597
|
+
Tengine::Resource::VirtualServerImage.delete_all
|
598
|
+
@virtual_server_image_wakame = @provider_wakame.virtual_server_images.create!({
|
599
|
+
:name => "vimage",
|
600
|
+
:description => "",
|
601
|
+
:provided_id => "wmi-lucid6",
|
602
|
+
:provided_description => "ubuntu-10.04_with-metadata_kvm_i386.raw volume",
|
603
|
+
})
|
604
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
605
|
+
end
|
606
|
+
|
607
|
+
context "wakame" do
|
608
|
+
before do
|
609
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
610
|
+
@provider_wakame.should_receive(:virtual_server_type_watch)
|
611
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
612
|
+
# EM.should_receive(:defer).and_yield
|
613
|
+
@provider_wakame.should_receive(:physical_server_watch)
|
614
|
+
@provider_wakame.should_receive(:virtual_server_watch)
|
615
|
+
|
616
|
+
@tama_controller_factory = mock(::Tama::Controllers::ControllerFactory.allocate)
|
617
|
+
::Tama::Controllers::ControllerFactory.
|
618
|
+
should_receive(:create_controller).
|
619
|
+
with("tama_account1", "10.10.10.10", 80, "https", "192.168.0.10", 8080, "http").
|
620
|
+
and_return(@tama_controller_factory)
|
621
|
+
end
|
622
|
+
|
623
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
624
|
+
@tama_controller_factory.
|
625
|
+
should_receive(:describe_images).with([]).
|
626
|
+
and_return(UPDATE_WAKAME_IMAGES)
|
627
|
+
|
628
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
629
|
+
"Tengine::Resource::VirtualServerImage.updated.tengine_resource_watchd",
|
630
|
+
anything())
|
631
|
+
|
632
|
+
@virtual_server_image_wakame.provided_description.should ==
|
633
|
+
"ubuntu-10.04_with-metadata_kvm_i386.raw volume"
|
634
|
+
|
635
|
+
@watcher.start
|
636
|
+
|
637
|
+
@provider_wakame.reload
|
638
|
+
new_image = @provider_wakame.virtual_server_images.first
|
639
|
+
new_image.provided_description.should ==
|
640
|
+
"ubuntu-10.04_with-metadata_kvm_i386.raw"
|
641
|
+
end
|
642
|
+
|
643
|
+
it "更新対象がなかったらイベントは発火しない" do
|
644
|
+
@tama_controller_factory.
|
645
|
+
should_receive(:describe_images).with([]).
|
646
|
+
and_return(ORIGINAL_WAKAME_IMAGES)
|
647
|
+
|
648
|
+
Tengine::Event.default_sender.should_not_receive(:fire)
|
649
|
+
|
650
|
+
@watcher.start
|
651
|
+
end
|
652
|
+
|
653
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
654
|
+
@tama_controller_factory.
|
655
|
+
should_receive(:describe_images).with([]).
|
656
|
+
and_return(CREATE_WAKAME_IMAGES)
|
657
|
+
|
658
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
659
|
+
"Tengine::Resource::VirtualServerImage.created.tengine_resource_watchd",
|
660
|
+
anything())
|
661
|
+
|
662
|
+
expect { @watcher.start }.should change(
|
663
|
+
@provider_wakame.virtual_server_images, :count).by(1)
|
664
|
+
end
|
665
|
+
|
666
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
667
|
+
@tama_controller_factory.
|
668
|
+
should_receive(:describe_images).with([]).
|
669
|
+
and_return([])
|
670
|
+
|
671
|
+
Tengine::Event.default_sender.should_receive(:fire).with(
|
672
|
+
"Tengine::Resource::VirtualServerImage.destroyed.tengine_resource_watchd",
|
673
|
+
anything())
|
674
|
+
|
675
|
+
expect { @watcher.start }.should change(
|
676
|
+
@provider_wakame.virtual_server_images, :size).by(-1)
|
677
|
+
end
|
678
|
+
end # end to wakame
|
679
|
+
|
680
|
+
context "ec2" do
|
681
|
+
before do
|
682
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_ec2])
|
683
|
+
@provider_ec2.should_receive(:virtual_server_type_watch)
|
684
|
+
EM.should_receive(:add_periodic_timer).with(@provider_ec2.polling_interval).and_yield
|
685
|
+
# EM.should_receive(:defer).and_yield
|
686
|
+
# @provider_ec2.should_receive(:physical_server_watch)
|
687
|
+
# @provider_ec2.should_receive(:virtual_server_watch)
|
688
|
+
end
|
689
|
+
|
690
|
+
it "更新対象があったら更新完了後イベントを発火する" do
|
691
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
692
|
+
end
|
693
|
+
it "削除対象があったら削除完了後イベントを発火する" do
|
694
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
695
|
+
end
|
696
|
+
it "更新対象がなかったらイベントは発火しない" do
|
697
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
698
|
+
end
|
699
|
+
it "登録対象があったら登録完了後イベントを発火する" do
|
700
|
+
expect { @watcher.start }.should raise_error(NotImplementedError)
|
701
|
+
end
|
702
|
+
end # end to ec2
|
703
|
+
end # end to :virtual_server_image_watch
|
704
|
+
|
705
|
+
# polling_interval
|
706
|
+
describe :polling_interval do
|
707
|
+
it 'polling_intervalが0より大きい場合は、問い合わせを行う', :current => true do
|
708
|
+
@provider_wakame.polling_interval = 1
|
709
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
710
|
+
|
711
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
712
|
+
@provider_wakame.should_receive(:virtual_server_type_watch)
|
713
|
+
EM.should_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
714
|
+
@provider_wakame.should_receive(:physical_server_watch)
|
715
|
+
@provider_wakame.should_receive(:virtual_server_watch)
|
716
|
+
@provider_wakame.should_receive(:virtual_server_image_watch)
|
717
|
+
@watcher.start
|
718
|
+
end
|
719
|
+
|
720
|
+
it 'polling_intervalが0の場合は、問い合わせを行わない', :current => true do
|
721
|
+
@provider_wakame.polling_interval = 0
|
722
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
723
|
+
|
724
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
725
|
+
@provider_wakame.should_not_receive(:virtual_server_type_watch)
|
726
|
+
EM.should_not_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
727
|
+
@provider_wakame.should_not_receive(:physical_server_watch)
|
728
|
+
@provider_wakame.should_not_receive(:virtual_server_watch)
|
729
|
+
@provider_wakame.should_not_receive(:virtual_server_image_watch)
|
730
|
+
@watcher.start
|
731
|
+
end
|
732
|
+
|
733
|
+
it 'polling_intervalがマイナスの場合は、問い合わせを行わない', :current => true do
|
734
|
+
@provider_wakame.polling_interval = -1
|
735
|
+
Tengine::Resource::Provider.should_receive(:all).and_return([@provider_wakame])
|
736
|
+
|
737
|
+
@watcher.sender.should_receive(:wait_for_connection).and_yield
|
738
|
+
@provider_wakame.should_not_receive(:virtual_server_type_watch)
|
739
|
+
EM.should_not_receive(:add_periodic_timer).with(@provider_wakame.polling_interval).and_yield
|
740
|
+
@provider_wakame.should_not_receive(:physical_server_watch)
|
741
|
+
@provider_wakame.should_not_receive(:virtual_server_watch)
|
742
|
+
@provider_wakame.should_not_receive(:virtual_server_image_watch)
|
743
|
+
@watcher.start
|
744
|
+
end
|
745
|
+
end # end to :polling_interval
|
746
|
+
|
747
|
+
end # end to :start
|
748
|
+
|
749
|
+
ORIGINAL_WAKAME_INSTANCE_SPECS = [{
|
750
|
+
:cpu_cores => 2,
|
751
|
+
:memory_size => 512,
|
752
|
+
:arch => "x86_64",
|
753
|
+
:hypervisor => "kvm",
|
754
|
+
:updated_at => "2011-10-28T02:58:57Z",
|
755
|
+
:account_id => "a-shpoolxx",
|
756
|
+
:vifs => "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
757
|
+
:quota_weight => 1.0,
|
758
|
+
:id => "is-demospec",
|
759
|
+
:created_at => "2011-10-28T02:58:57Z",
|
760
|
+
:drives => "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n",
|
761
|
+
:uuid => "is-demospec"
|
762
|
+
}]
|
763
|
+
UPDATE_WAKAME_INSTANCE_SPECS = [{
|
764
|
+
:cpu_cores => 1,
|
765
|
+
:memory_size => 256,
|
766
|
+
:arch => "x86_64",
|
767
|
+
:hypervisor => "kvm",
|
768
|
+
:updated_at => "2011-10-28T02:58:57Z",
|
769
|
+
:account_id => "a-shpoolxx",
|
770
|
+
:vifs => "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
771
|
+
:quota_weight => 1.0,
|
772
|
+
:id => "is-demospec",
|
773
|
+
:created_at => "2011-10-28T02:58:57Z",
|
774
|
+
:drives => "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n",
|
775
|
+
:uuid => "is-demospec"
|
776
|
+
}]
|
777
|
+
CREATE_WAKAME_INSTANCE_SPECS = [{
|
778
|
+
:cpu_cores => 2,
|
779
|
+
:memory_size => 1024,
|
780
|
+
:arch => "x86_64",
|
781
|
+
:hypervisor => "kvm",
|
782
|
+
:updated_at => "2011-10-28T02:58:57Z",
|
783
|
+
:account_id => "b-shpoolxx",
|
784
|
+
:vifs => "--- \neth0: \n :bandwidth: 100000\n :index: 0\n",
|
785
|
+
:quota_weight => 1.0,
|
786
|
+
:id => "is-demospec2",
|
787
|
+
:created_at => "2011-10-28T02:58:57Z",
|
788
|
+
:drives => "--- \nephemeral1: \n :type: :local\n :size: 100\n :index: 0\n",
|
789
|
+
:uuid => "is-demospec2"
|
790
|
+
}] + ORIGINAL_WAKAME_INSTANCE_SPECS
|
791
|
+
|
792
|
+
ORIGINAL_WAKAME_HOST_NODES = [{
|
793
|
+
:status => "online",
|
794
|
+
:updated_at => "2011-10-18T03:53:24Z",
|
795
|
+
:account_id => "a-shpoolxx",
|
796
|
+
:offering_cpu_cores => 100,
|
797
|
+
:offering_memory_size => 400000,
|
798
|
+
:arch => "x86_64",
|
799
|
+
:hypervisor => "kvm",
|
800
|
+
:created_at => "2011-10-18T03:53:24Z",
|
801
|
+
:name => "demohost",
|
802
|
+
:uuid => "hp-demohost",
|
803
|
+
:id => "hp-demohost"
|
804
|
+
}]
|
805
|
+
UPDATE_WAKAME_HOST_NODES = [{
|
806
|
+
:status => "online",
|
807
|
+
:updated_at => "2011-10-18T03:53:24Z",
|
808
|
+
:account_id => "a-shpoolxx",
|
809
|
+
:offering_cpu_cores => 75,
|
810
|
+
:offering_memory_size => 350000,
|
811
|
+
:arch => "x86_64",
|
812
|
+
:hypervisor => "kvm",
|
813
|
+
:created_at => "2011-10-18T03:53:24Z",
|
814
|
+
:name => "demohost",
|
815
|
+
:uuid => "hp-demohost",
|
816
|
+
:id => "hp-demohost"
|
817
|
+
}]
|
818
|
+
CREATE_WAKAME_HOST_NODES = [{
|
819
|
+
:status => "online",
|
820
|
+
:updated_at => "2011-10-18T03:53:24Z",
|
821
|
+
:account_id => "a-shpoolxx",
|
822
|
+
:offering_cpu_cores => 75,
|
823
|
+
:offering_memory_size => 350000,
|
824
|
+
:arch => "x86_64",
|
825
|
+
:hypervisor => "kvm",
|
826
|
+
:created_at => "2011-10-18T03:53:24Z",
|
827
|
+
:name => "demohost2",
|
828
|
+
:uuid => "hp-demohost2",
|
829
|
+
:id => "hp-demohost2"
|
830
|
+
}] + ORIGINAL_WAKAME_HOST_NODES
|
831
|
+
|
832
|
+
ORIGINAL_WAKAME_INSTANCES = [{
|
833
|
+
:aws_kernel_id => "",
|
834
|
+
:aws_launch_time => "2011-10-18T06:51:16Z",
|
835
|
+
:tags => {},
|
836
|
+
:aws_reservation_id => "",
|
837
|
+
:aws_owner => "a-shpoolxx",
|
838
|
+
:instance_lifecycle => "",
|
839
|
+
:block_device_mappings => [{
|
840
|
+
:ebs_volume_id => "",
|
841
|
+
:ebs_status => "",
|
842
|
+
:ebs_attach_time => "",
|
843
|
+
:ebs_delete_on_termination => false,
|
844
|
+
:device_name => ""
|
845
|
+
}],
|
846
|
+
:ami_launch_index => "",
|
847
|
+
:root_device_name => "",
|
848
|
+
:aws_ramdisk_id => "",
|
849
|
+
:aws_availability_zone => "hp-demohost",
|
850
|
+
#:aws_groups => nil,
|
851
|
+
:spot_instance_request_id => "",
|
852
|
+
#:ssh_key_name => nil,
|
853
|
+
:virtualization_type => "",
|
854
|
+
:placement_group_name => "",
|
855
|
+
:requester_id => "",
|
856
|
+
:aws_instance_id => "i-jria301q",
|
857
|
+
:aws_product_codes => [],
|
858
|
+
:client_token => "",
|
859
|
+
:private_ip_address => "192.168.2.188",
|
860
|
+
:architecture => "x86_64",
|
861
|
+
:aws_state_code => 0,
|
862
|
+
:aws_image_id => "wmi-lucid5",
|
863
|
+
:root_device_type => "",
|
864
|
+
:ip_address => "nw-data=192.168.2.188",
|
865
|
+
:dns_name => "nw-data=jria301q.shpoolxx.vdc.local",
|
866
|
+
:monitoring_state => "",
|
867
|
+
:aws_instance_type => "is-demospec",
|
868
|
+
:aws_state => "running",
|
869
|
+
:private_dns_name => "jria301q.shpoolxx.vdc.local",
|
870
|
+
:aws_reason => ""
|
871
|
+
}]
|
872
|
+
UPDATE_WAKAME_INSTANCES = [{
|
873
|
+
:aws_kernel_id => "",
|
874
|
+
:aws_launch_time => "2011-10-18T06:51:16Z",
|
875
|
+
:tags => {},
|
876
|
+
:aws_reservation_id => "",
|
877
|
+
:aws_owner => "a-shpoolxx",
|
878
|
+
:instance_lifecycle => "",
|
879
|
+
:block_device_mappings => [{
|
880
|
+
:ebs_volume_id => "",
|
881
|
+
:ebs_status => "",
|
882
|
+
:ebs_attach_time => "",
|
883
|
+
:ebs_delete_on_termination => false,
|
884
|
+
:device_name => ""
|
885
|
+
}],
|
886
|
+
:ami_launch_index => "",
|
887
|
+
:root_device_name => "",
|
888
|
+
:aws_ramdisk_id => "",
|
889
|
+
:aws_availability_zone => "hp-demohost",
|
890
|
+
#:aws_groups => nil,
|
891
|
+
:spot_instance_request_id => "",
|
892
|
+
#:ssh_key_name => nil,
|
893
|
+
:virtualization_type => "",
|
894
|
+
:placement_group_name => "",
|
895
|
+
:requester_id => "",
|
896
|
+
:aws_instance_id => "i-jria301q",
|
897
|
+
:aws_product_codes => [],
|
898
|
+
:client_token => "",
|
899
|
+
:private_ip_address => "192.168.2.188",
|
900
|
+
:architecture => "x86_64",
|
901
|
+
:aws_state_code => 1,
|
902
|
+
:aws_image_id => "wmi-lucid5",
|
903
|
+
:root_device_type => "",
|
904
|
+
:ip_address => "nw-data=192.168.2.188",
|
905
|
+
:dns_name => "nw-data=jria301q.shpoolxx.vdc.local",
|
906
|
+
:monitoring_state => "",
|
907
|
+
:aws_instance_type => "is-demospec",
|
908
|
+
:aws_state => "terminated",
|
909
|
+
:private_dns_name => "jria301q.shpoolxx.vdc.local",
|
910
|
+
:aws_reason => ""
|
911
|
+
}]
|
912
|
+
CREATE_WAKAME_INSTANCES = [{
|
913
|
+
:aws_kernel_id => "",
|
914
|
+
:aws_launch_time => "2011-10-18T06:51:16Z",
|
915
|
+
:tags => {},
|
916
|
+
:aws_reservation_id => "",
|
917
|
+
:aws_owner => "a-shpoolxx",
|
918
|
+
:instance_lifecycle => "",
|
919
|
+
:block_device_mappings => [{
|
920
|
+
:ebs_volume_id => "",
|
921
|
+
:ebs_status => "",
|
922
|
+
:ebs_attach_time => "",
|
923
|
+
:ebs_delete_on_termination => false,
|
924
|
+
:device_name => ""
|
925
|
+
}],
|
926
|
+
:ami_launch_index => "",
|
927
|
+
:root_device_name => "",
|
928
|
+
:aws_ramdisk_id => "",
|
929
|
+
:aws_availability_zone => "hp-demohost",
|
930
|
+
#:aws_groups => nil,
|
931
|
+
:spot_instance_request_id => "",
|
932
|
+
#:ssh_key_name => nil,
|
933
|
+
:virtualization_type => "",
|
934
|
+
:placement_group_name => "",
|
935
|
+
:requester_id => "",
|
936
|
+
:aws_instance_id => "i-jria302q",
|
937
|
+
:aws_product_codes => [],
|
938
|
+
:client_token => "",
|
939
|
+
:private_ip_address => "192.168.2.189",
|
940
|
+
:architecture => "x86_64",
|
941
|
+
:aws_state_code => 0,
|
942
|
+
:aws_image_id => "wmi-lucid5",
|
943
|
+
:root_device_type => "",
|
944
|
+
:ip_address => "nw-data=192.168.2.189",
|
945
|
+
:dns_name => "nw-data=jria302q.shpoolxx.vdc.local",
|
946
|
+
:monitoring_state => "",
|
947
|
+
:aws_instance_type => "is-demospec",
|
948
|
+
:aws_state => "running",
|
949
|
+
:private_dns_name => "jria302q.shpoolxx.vdc.local",
|
950
|
+
:aws_reason => ""
|
951
|
+
}] + ORIGINAL_WAKAME_INSTANCES
|
952
|
+
|
953
|
+
ORIGINAL_WAKAME_IMAGES = [{
|
954
|
+
:root_device_name => "",
|
955
|
+
:aws_ramdisk_id => "",
|
956
|
+
:block_device_mappings => [{
|
957
|
+
:ebs_snapshot_id => "",
|
958
|
+
:ebs_volume_size => 0,
|
959
|
+
:ebs_delete_on_termination => false,
|
960
|
+
:device_name => ""
|
961
|
+
}],
|
962
|
+
:aws_is_public => false,
|
963
|
+
:virtualization_type => "",
|
964
|
+
:image_owner_alias => "",
|
965
|
+
:aws_id => "wmi-lucid6",
|
966
|
+
:aws_architecture => "x86",
|
967
|
+
:root_device_type => "",
|
968
|
+
:aws_location => "--- \n:snapshot_id: snap-lucid6\n",
|
969
|
+
:aws_image_type => "",
|
970
|
+
:name => "",
|
971
|
+
:aws_state => "init",
|
972
|
+
:description => "ubuntu-10.04_with-metadata_kvm_i386.raw volume",
|
973
|
+
:aws_kernel_id => "",
|
974
|
+
:tags => {},
|
975
|
+
:aws_owner => "a-shpoolxx"
|
976
|
+
}]
|
977
|
+
UPDATE_WAKAME_IMAGES = [{
|
978
|
+
:root_device_name => "",
|
979
|
+
:aws_ramdisk_id => "",
|
980
|
+
:block_device_mappings => [{
|
981
|
+
:ebs_snapshot_id => "",
|
982
|
+
:ebs_volume_size => 0,
|
983
|
+
:ebs_delete_on_termination => false,
|
984
|
+
:device_name => ""
|
985
|
+
}],
|
986
|
+
:aws_is_public => true,
|
987
|
+
:virtualization_type => "",
|
988
|
+
:image_owner_alias => "",
|
989
|
+
:aws_id => "wmi-lucid6",
|
990
|
+
:aws_architecture => "x86",
|
991
|
+
:root_device_type => "",
|
992
|
+
:aws_location => "--- \n:snapshot_id: snap-lucid6\n",
|
993
|
+
:aws_image_type => "",
|
994
|
+
:name => "",
|
995
|
+
:aws_state => "init",
|
996
|
+
:description => "ubuntu-10.04_with-metadata_kvm_i386.raw",
|
997
|
+
:aws_kernel_id => "",
|
998
|
+
:tags => {},
|
999
|
+
:aws_owner => "a-shpoolxx"
|
1000
|
+
}]
|
1001
|
+
CREATE_WAKAME_IMAGES = [{
|
1002
|
+
:root_device_name => "",
|
1003
|
+
:aws_ramdisk_id => "",
|
1004
|
+
:block_device_mappings => [{
|
1005
|
+
:ebs_snapshot_id => "",
|
1006
|
+
:ebs_volume_size => 0,
|
1007
|
+
:ebs_delete_on_termination => false,
|
1008
|
+
:device_name => ""
|
1009
|
+
}],
|
1010
|
+
:aws_is_public => false,
|
1011
|
+
:virtualization_type => "",
|
1012
|
+
:image_owner_alias => "",
|
1013
|
+
:aws_id => "wmi-lucid7",
|
1014
|
+
:aws_architecture => "x86",
|
1015
|
+
:root_device_type => "",
|
1016
|
+
:aws_location => "--- \n:snapshot_id: snap-lucid7\n",
|
1017
|
+
:aws_image_type => "",
|
1018
|
+
:name => "",
|
1019
|
+
:aws_state => "init",
|
1020
|
+
:description => "ubuntu-10.04_with-metadata_kvm_i386.raw volume",
|
1021
|
+
:aws_kernel_id => "",
|
1022
|
+
:tags => {},
|
1023
|
+
:aws_owner => "a-shpoolxx"
|
1024
|
+
}] + ORIGINAL_WAKAME_IMAGES
|
1025
|
+
|
1026
|
+
end
|