tengine_resource_ec2 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ require 'tengine_resource'
2
+
3
+ module Tengine
4
+ autoload :ResourceEc2, 'tengine/resource_ec2'
5
+ end
@@ -0,0 +1,177 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ class GokuAtEc2ApNortheast
4
+ # # memoize については http://wota.jp/ac/?date=20081025#p11 などを参照してください
5
+ # extend ActiveSupport::Memoizable
6
+
7
+ def provider
8
+ Tengine::ResourceEc2::Provider.find_or_create_by_name!({
9
+ :name => "goku_at_ec2_ap-northeast-1",
10
+ :connection_settings => {
11
+ :access_key => '12345',
12
+ :secret_access_key => '1234567',
13
+ :default_region => 'ap-northeast-1',
14
+ }
15
+ })
16
+ end
17
+
18
+ def goku_ssh_pw
19
+ Tengine::Resource::Credential.find_or_create_by_name!(
20
+ :name => "goku_ssh_pw",
21
+ :auth_type_key => :ssh_password,
22
+ :auth_values => {
23
+ :username => 'goku',
24
+ :password => 'dragonball'
25
+ })
26
+ end
27
+
28
+ def gohan_ssh_pk
29
+ Tengine::Resource::Credential.find_or_create_by_name!(
30
+ :name => "gohan_ssh_pk",
31
+ :auth_type_key => :ssh_public_key,
32
+ :auth_values => {
33
+ :username => 'gohan',
34
+ :private_keys => "1234567890",
35
+ :passphrase => 'dragonball'
36
+ })
37
+ end
38
+
39
+ def physical_servers
40
+ [availability_zone(1), availability_zone(2)]
41
+ end
42
+
43
+ def availability_zone(idx)
44
+ name = "ap-notrheast-1" + ("a".ord - 1 + idx).chr
45
+ Tengine::Resource::PhysicalServer.find_or_create_by_name!(
46
+ :provider_id => provider.id,
47
+ :name => name, :provided_id => name, :status => "available")
48
+ end
49
+
50
+ def virtual_server_images
51
+ [
52
+ hadoop_image,
53
+ mysql_image,
54
+ rails_image
55
+ ]
56
+ end
57
+
58
+ def hadoop_image
59
+ Tengine::Resource::VirtualServerImage.find_or_create_by_name!(
60
+ :provider_id => provider.id,
61
+ :name => "hadoop_image1",
62
+ :provided_id => "ami-10000001")
63
+ end
64
+
65
+ def mysql_image
66
+ Tengine::Resource::VirtualServerImage.find_or_create_by_name!(
67
+ :provider_id => provider.id,
68
+ :name => "mysql_image1",
69
+ :provided_id => "ami-10000002")
70
+ end
71
+
72
+ def rails_image
73
+ Tengine::Resource::VirtualServerImage.find_or_create_by_name!(
74
+ :provider_id => provider.id,
75
+ :name => "rails_image1",
76
+ :provided_id => "ami-10000003")
77
+ end
78
+
79
+ def virtual_server_types
80
+ [
81
+ m1_small,
82
+ m1_large,
83
+ m1_xlarge,
84
+ t1_micro,
85
+ ]
86
+ end
87
+
88
+ def m1_small
89
+ Tengine::Resource::VirtualServerType.find_or_create_by(:provider_id => provider.id,
90
+ :caption => "m1.small", :provided_id => "m1.small", :cpu_cores => 1, :memory_size => 17 * (10 ** 8))
91
+ end
92
+
93
+ def m1_large
94
+ Tengine::Resource::VirtualServerType.find_or_create_by(:provider_id => provider.id,
95
+ :caption => "m1.large", :provided_id => "m1.large", :cpu_cores => 4, :memory_size => 75 * (10 ** 8))
96
+ end
97
+
98
+ def m1_xlarge
99
+ Tengine::Resource::VirtualServerType.find_or_create_by(:provider_id => provider.id,
100
+ :caption => "m1.xlarge", :provided_id => "m1.xlarge", :cpu_cores => 8, :memory_size => 15 * (10 ** 9))
101
+ end
102
+
103
+ def t1_micro
104
+ Tengine::Resource::VirtualServerType.find_or_create_by(:provider_id => provider.id,
105
+ :caption => "t1.micro", :provided_id => "t1.micro", :cpu_cores => 2, :memory_size => 613 * (10 ** 6))
106
+ end
107
+
108
+
109
+ def virtual_servers
110
+ [
111
+ hadoop_master_node,
112
+ hadoop_slave_node(1),
113
+ hadoop_slave_node(2),
114
+ hadoop_slave_node(3),
115
+ mysql_master,
116
+ mysql_slave(1),
117
+ mysql_slave(2),
118
+ rails_server(1)
119
+ ]
120
+ end
121
+
122
+ def hadoop_master_node
123
+ Tengine::Resource::VirtualServer.find_or_create_by_name!(
124
+ :addresses => hostnames_and_ips(1),
125
+ :provider_id => provider.id,
126
+ :provided_image_id => hadoop_image.provided_id,
127
+ :host_server_id => availability_zone(1).id, :status => "available",
128
+ :name => "hadoop_master_node", :provided_id => "i-10000001")
129
+ end
130
+
131
+ def hadoop_slave_node(idx)
132
+ Tengine::Resource::VirtualServer.find_or_create_by_name!(
133
+ :addresses => hostnames_and_ips(idx + 10),
134
+ :provider_id => provider.id,
135
+ :provided_image_id => hadoop_image.provided_id,
136
+ :host_server_id => availability_zone(1).id, :status => "available",
137
+ :name => "hadoop_slave_node#{idx}", :provided_id => "i-1000001#{idx}")
138
+ end
139
+
140
+ def mysql_master
141
+ Tengine::Resource::VirtualServer.find_or_create_by_name!(
142
+ :addresses => hostnames_and_ips(20),
143
+ :provider_id => provider.id,
144
+ :provided_image_id => mysql_image.provided_id,
145
+ :host_server_id => availability_zone(1).id, :status => "available",
146
+ :name => "mysql_master", :provided_id => "i-10000020")
147
+ end
148
+
149
+ def mysql_slave(idx)
150
+ Tengine::Resource::VirtualServer.find_or_create_by_name!(
151
+ :addresses => hostnames_and_ips(idx + 20),
152
+ :provider_id => provider.id,
153
+ :provided_image_id => mysql_image.provided_id,
154
+ :host_server_id => availability_zone(1).id, :status => "available",
155
+ :name => "mysql_slave#{idx}", :provided_id => "i-1000002#{idx}")
156
+ end
157
+
158
+ def rails_server(idx)
159
+ Tengine::Resource::VirtualServer.find_or_create_by_name!(
160
+ :addresses => hostnames_and_ips(idx + 30),
161
+ :provider_id => provider.id,
162
+ :provided_image_id => rails_image.provided_id,
163
+ :host_server_id => availability_zone(1).id, :status => "available",
164
+ :name => "rails#{idx}", :provided_id => "i-1000003#{idx}")
165
+ end
166
+
167
+ private
168
+ def hostnames_and_ips(idx)
169
+ {
170
+ 'dns_name' => "ec2-184-72-20-#{idx}.ap-northeast-1.compute.amazonaws.com",
171
+ 'ip_address' => "184.72.20.#{idx}",
172
+ 'private_dns_name' => "ip-10-162-153-#{idx}.ap-northeast-1.compute.internal",
173
+ 'private_ip_address' => "10.162.153.#{idx}",
174
+ }
175
+ end
176
+
177
+ end
data/tmp/.gitkeep ADDED
File without changes
metadata ADDED
@@ -0,0 +1,231 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tengine_resource_ec2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - taigou
8
+ - totty
9
+ - g-morita
10
+ - shyouhei
11
+ - akm
12
+ - hiroshinakao
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+ date: 2013-04-30 00:00:00.000000000 Z
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: tengine_resource
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.2.0
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: 1.2.0
32
+ - !ruby/object:Gem::Dependency
33
+ name: right_aws
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 2.1.0
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.1.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ type: :development
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ - !ruby/object:Gem::Dependency
61
+ name: rake
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ - !ruby/object:Gem::Dependency
75
+ name: rspec
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ~>
79
+ - !ruby/object:Gem::Version
80
+ version: 2.10.0
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 2.10.0
88
+ - !ruby/object:Gem::Dependency
89
+ name: yard
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ - !ruby/object:Gem::Dependency
103
+ name: simplecov
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ type: :development
110
+ prerelease: false
111
+ version_requirements: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ - !ruby/object:Gem::Dependency
117
+ name: autotest
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ - !ruby/object:Gem::Dependency
131
+ name: pry
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ - !ruby/object:Gem::Dependency
145
+ name: pry-doc
146
+ requirement: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: pry-debugger
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ! '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ - !ruby/object:Gem::Dependency
173
+ name: ZenTest
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ~>
177
+ - !ruby/object:Gem::Version
178
+ version: 4.9.0
179
+ type: :development
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ~>
184
+ - !ruby/object:Gem::Version
185
+ version: 4.9.0
186
+ description: tengine_resource_ec2 provides physical/virtual server management for
187
+ EC2
188
+ email: tengine-info@groovenauts.jp
189
+ executables: []
190
+ extensions: []
191
+ extra_rdoc_files:
192
+ - README.rdoc
193
+ files:
194
+ - Gemfile
195
+ - Gemfile.lock
196
+ - README.rdoc
197
+ - lib/tengine/resource_ec2/dummy_connection.rb
198
+ - lib/tengine/resource_ec2/dummy_connection.rb~
199
+ - lib/tengine/resource_ec2/launch_options.rb
200
+ - lib/tengine/resource_ec2/launch_options.rb~
201
+ - lib/tengine/resource_ec2/provider.rb
202
+ - lib/tengine/resource_ec2/provider.rb~
203
+ - lib/tengine/resource_ec2.rb
204
+ - lib/tengine_resource_ec2.rb
205
+ - spec/fixtures/goku_at_ec2_ap_northeast.rb
206
+ - tmp/.gitkeep
207
+ homepage: http://github.com/tengine/tengine
208
+ licenses:
209
+ - MPL2.0/LGPLv3
210
+ metadata: {}
211
+ post_install_message:
212
+ rdoc_options: []
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ! '>='
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ! '>='
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ requirements: []
226
+ rubyforge_project:
227
+ rubygems_version: 2.0.3
228
+ signing_key:
229
+ specification_version: 4
230
+ summary: tengine_resource_ec2 provides physical/virtual server management for EC2
231
+ test_files: []