openstudio-aws 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/openstudio-aws.rb +1 -1
- data/lib/openstudio/aws/aws.rb +9 -9
- data/lib/openstudio/aws/version.rb +1 -1
- data/lib/openstudio/lib/ami_list.rb +0 -1
- data/lib/openstudio/lib/openstudio_aws_instance.rb +12 -12
- data/lib/openstudio/lib/openstudio_aws_wrapper.rb +9 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac6b743feca80ea6c1cc34f6ecd9f765504d52b
|
4
|
+
data.tar.gz: 19e378e4fc19eb4578e11a010ee4761a7f506d78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c29dc7caf6cf02f2357a655986a9a1f0a57aaddb717447b037e94c0fb0bef81df919b9678f33317964321b3c837b8a2a4b2e05e3a75dfb0d303b675b9af45e6e
|
7
|
+
data.tar.gz: c34a468d431073cf7b69eb50325516152dcf69300242d0de2e4460f003b75b3b5c6288985f1adf3f4e3e7e39ad9b287ffe82287a651c6820a60d9b64b8517be9
|
data/lib/openstudio-aws.rb
CHANGED
@@ -13,9 +13,9 @@ rescue LoadError
|
|
13
13
|
exit
|
14
14
|
end
|
15
15
|
|
16
|
-
require 'openstudio/aws/version'
|
17
16
|
require 'openstudio/aws/aws'
|
18
17
|
require 'openstudio/aws/config'
|
18
|
+
require 'openstudio/aws/version'
|
19
19
|
require 'openstudio/lib/openstudio_aws_instance'
|
20
20
|
require 'openstudio/lib/openstudio_aws_wrapper'
|
21
21
|
require 'openstudio/lib/ami_list'
|
data/lib/openstudio/aws/aws.rb
CHANGED
@@ -11,13 +11,13 @@ module OpenStudio
|
|
11
11
|
config = {:access_key_id => @config.access_key, :secret_access_key => @config.secret_key, :region => "us-east-1", :ssl_verify_peer => false}
|
12
12
|
@os_aws = OpenStudioAwsWrapper.new(config)
|
13
13
|
@local_key_file_name = nil
|
14
|
-
|
14
|
+
|
15
15
|
@default_amis = OpenStudioAmis.new(1, "1.1.3").get_amis
|
16
16
|
end
|
17
17
|
|
18
18
|
# command line call to create a new instance. This should be more tightly integrated with teh os-aws.rb gem
|
19
19
|
def create_server(instance_data = {})
|
20
|
-
defaults = {instance_type: "m2.xlarge", image_id: @default_amis[
|
20
|
+
defaults = {instance_type: "m2.xlarge", image_id: @default_amis['server']}
|
21
21
|
instance_data = defaults.merge(instance_data)
|
22
22
|
|
23
23
|
@os_aws.create_or_retrieve_security_group("openstudio-worker-sg-v1")
|
@@ -59,13 +59,13 @@ module OpenStudio
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def create_workers(number_of_instances, instance_data = {})
|
62
|
-
defaults = {instance_type: "m2.4xlarge", image_id: @default_amis[
|
62
|
+
defaults = {instance_type: "m2.4xlarge", image_id: @default_amis['worker']}
|
63
63
|
instance_data = defaults.merge(instance_data)
|
64
64
|
|
65
|
-
|
65
|
+
|
66
66
|
#todo: raise an exception if the instance type and image id don't match
|
67
67
|
raise "Can't create workers without a server instance running" if @os_aws.server.nil?
|
68
|
-
|
68
|
+
|
69
69
|
@os_aws.launch_workers(instance_data[:image_id], instance_data[:instance_type], number_of_instances)
|
70
70
|
|
71
71
|
## append the information to the server_data hash that already exists
|
@@ -80,15 +80,15 @@ module OpenStudio
|
|
80
80
|
#File.open("worker_data.json", "w") { |f| f << JSON.pretty_generate(worker_data) }
|
81
81
|
#
|
82
82
|
## Print out some debugging commands (probably work on mac/linux only)
|
83
|
+
puts ""
|
84
|
+
puts "Worker SSH Command:"
|
83
85
|
@os_aws.workers.each do |worker|
|
84
|
-
puts ""
|
85
|
-
puts "Worker SSH Command:"
|
86
86
|
puts "ssh -i #{@local_key_file_name} ubuntu@#{worker.data[:dns]}"
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
puts ""
|
90
90
|
puts "Waiting for server/worker configurations"
|
91
|
-
|
91
|
+
|
92
92
|
@os_aws.configure_server_and_workers
|
93
93
|
end
|
94
94
|
|
@@ -41,18 +41,18 @@ class OpenStudioAwsInstance
|
|
41
41
|
|
42
42
|
|
43
43
|
def launch_instance(image_id, instance_type, user_data)
|
44
|
-
logger.info("user_data #{user_data.inspect}")
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
)
|
44
|
+
#logger.info("user_data #{user_data.inspect}")
|
45
|
+
instance = {
|
46
|
+
:image_id => image_id,
|
47
|
+
:key_name => @key_pair_name,
|
48
|
+
:security_groups => [@security_group_name],
|
49
|
+
:user_data => Base64.encode64(user_data),
|
50
|
+
:instance_type => instance_type,
|
51
|
+
:min_count => 1,
|
52
|
+
:max_count => 1
|
53
|
+
}
|
54
|
+
#logger.info instance.inspect
|
55
|
+
result = @aws.run_instances(instance)
|
56
56
|
|
57
57
|
# determine how many processors are suppose to be in this image (lookup for now?)
|
58
58
|
processors = find_processors(instance_type)
|
@@ -208,6 +208,9 @@ class OpenStudioAwsWrapper
|
|
208
208
|
def launch_server(image_id, instance_type)
|
209
209
|
user_data = File.read(File.expand_path(File.dirname(__FILE__))+'/server_script.sh')
|
210
210
|
@server = OpenStudioAwsInstance.new(@aws, :server, @key_pair_name, @security_group_name, @group_uuid, @private_key)
|
211
|
+
|
212
|
+
raise "image_id is nil" if not image_id
|
213
|
+
raise "instance type is nil" if not instance_type
|
211
214
|
@server.launch_instance(image_id, instance_type, user_data)
|
212
215
|
end
|
213
216
|
|
@@ -219,11 +222,15 @@ class OpenStudioAwsWrapper
|
|
219
222
|
logger.info("worker user_data #{user_data.inspect}")
|
220
223
|
|
221
224
|
# thread the launching of the workers
|
222
|
-
|
225
|
+
|
223
226
|
num.times do
|
224
227
|
@workers << OpenStudioAwsInstance.new(@aws, :worker, @key_pair_name, @security_group_name, @group_uuid, @private_key)
|
228
|
+
end
|
229
|
+
|
230
|
+
threads = []
|
231
|
+
@workers.each do |worker|
|
225
232
|
threads << Thread.new do
|
226
|
-
|
233
|
+
worker.launch_instance(image_id, instance_type, user_data)
|
227
234
|
end
|
228
235
|
end
|
229
236
|
threads.each { |t| t.join }
|