openstudio-aws 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11aab221e2b60dbd26c91e73c8848e5fcb96ffe4
4
- data.tar.gz: b8372199ce382aac34a9d33367f3bf8d4d9f8140
3
+ metadata.gz: 3ac6b743feca80ea6c1cc34f6ecd9f765504d52b
4
+ data.tar.gz: 19e378e4fc19eb4578e11a010ee4761a7f506d78
5
5
  SHA512:
6
- metadata.gz: 5b1edf97000da8f3801d3521f19199dbb0cd1991d954a3a99c389a8c8c7501a688f5ceb553e10df7979285a0beaa8a70f151ce21924654fe66e0fdbfabcd4f7b
7
- data.tar.gz: 95cfb9e1d72a04a13a9835712609589abfa448941e5338aede76cdb2b591fbc52b709a293af6ff02a28af66f6c0e54e5ed8a9f9835ca7a484e398e0cf0f45716
6
+ metadata.gz: c29dc7caf6cf02f2357a655986a9a1f0a57aaddb717447b037e94c0fb0bef81df919b9678f33317964321b3c837b8a2a4b2e05e3a75dfb0d303b675b9af45e6e
7
+ data.tar.gz: c34a468d431073cf7b69eb50325516152dcf69300242d0de2e4460f003b75b3b5c6288985f1adf3f4e3e7e39ad9b287ffe82287a651c6820a60d9b64b8517be9
@@ -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'
@@ -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[:server]}
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[:worker]}
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
 
@@ -1,6 +1,6 @@
1
1
  module OpenStudio
2
2
  module Aws
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  OPENSTUDIO_VERSION = "1.2.1"
5
5
  end
6
6
  end
@@ -39,7 +39,6 @@ class OpenStudioAmis
39
39
 
40
40
  raise "Could not find any amis for #{@version}" if amis.nil?
41
41
 
42
- puts amis.inspect
43
42
  amis
44
43
  end
45
44
 
@@ -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
- result = @aws.run_instances(
46
- {
47
- :image_id => image_id,
48
- :key_name => @key_pair_name,
49
- :security_groups => [@security_group_name],
50
- :user_data => Base64.encode64(user_data),
51
- :instance_type => instance_type,
52
- :min_count => 1,
53
- :max_count => 1
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
- threads = []
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
- @workers.last.launch_instance(image_id, instance_type, user_data)
233
+ worker.launch_instance(image_id, instance_type, user_data)
227
234
  end
228
235
  end
229
236
  threads.each { |t| t.join }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long