openstudio-aws 0.4.0.alpha1 → 0.4.0.alpha2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0caae029f8b89a624ac2eae705dd9116f6fb73d6
4
- data.tar.gz: 9027677347681dfda91f3b57bdf4266ec4da5822
3
+ metadata.gz: eba77b1f1302604cb57c69a087796ead6aaf2c98
4
+ data.tar.gz: 113a23d7859a8da882a7f5e426098cbf6ed61986
5
5
  SHA512:
6
- metadata.gz: 92220c6aa21ced920173e584686c10546bc92bb2c2d5668dc911668ffd7fb5c38ea34e4c82793f329e2a0d37d19602667afb03a76c81224ac9bfb004244f815b
7
- data.tar.gz: c8b09f832050cc296425ee4a08b1cb95fba8002dd151a794b0fab0895afdf8752b197da29e7a476148ebdb827ae6fc6bd25ce05227ebf66968b93327bd138d58
6
+ metadata.gz: b01c424a5369cddce55c78adfb87b3c330158faa4e0b25f7148106c5947db6f8df7dbd91e4d1e3d4749e6548476743b5edd5865477e3b864b6d034539a3c8bab
7
+ data.tar.gz: 99026903cb962cbb0e8990aa97236ce645336346d1977be7027a4aee58757768d835b4869957dd5965f4629ee0f17dc2da1f62ede3c3fb803873253181e87333
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  OpenStudio AWS Gem Change Log
2
2
  ==================================
3
3
 
4
+ Version 0.4.0.alpha2
5
+ -------------
6
+ * Load worker keys from disk (if they exist) when constructing the OpenStudioAwsWrapper class
7
+ * Have `total_instances_count` return the region and first availability zone
8
+ * Add `describe_all_instances`
9
+
4
10
  Version 0.4.0.alpha1
5
11
  -------------
6
12
  * Add a stable JSON file that can be used to flag which versions of the server are stable (used by OpenStudio PAT).
@@ -294,6 +294,11 @@ module OpenStudio
294
294
  @os_aws.describe_instances
295
295
  end
296
296
 
297
+ # List the description of all instances on AWS in the predefined region
298
+ def describe_all_instances
299
+ @os_aws.describe_all_instances
300
+ end
301
+
297
302
  # Return the list of all the instances that are running on the account in the availablity zone
298
303
  def total_instances_count
299
304
  @os_aws.total_instances_count
@@ -327,7 +332,7 @@ module OpenStudio
327
332
 
328
333
  # Warning, this appears that it terminates all the instances
329
334
  def terminate_instances_by_group_id(group_id)
330
- fail "Group ID not defined" unless group_id
335
+ fail 'Group ID not defined' unless group_id
331
336
 
332
337
  instances = @os_aws.describe_running_instances(group_id)
333
338
  logger.info instances
@@ -1,5 +1,5 @@
1
1
  module OpenStudio
2
2
  module Aws
3
- VERSION = '0.4.0.alpha1'
3
+ VERSION = '0.4.0.alpha2'
4
4
  end
5
5
  end
@@ -122,7 +122,7 @@ class OpenStudioAmis
122
122
  amis = value[:amis]
123
123
  else
124
124
  logger.info "Could not find a stable version for OpenStudio version #{@options[:openstudio_version]}. "\
125
- "Looking up older versions to find the latest stable." unless stable
125
+ 'Looking up older versions to find the latest stable.' unless stable
126
126
 
127
127
  json[:openstudio].each do |os_version, values|
128
128
  next if os_version == :default
@@ -269,8 +269,6 @@ class OpenStudioAwsInstance
269
269
  processors = 1
270
270
  if lookup.key?(instance)
271
271
  processors = lookup[instance]
272
- else
273
- # logger.warn "Could not find the number of processors for instance type of #{instance}" if logger
274
272
  end
275
273
 
276
274
  if @openstudio_instance_type == :server
@@ -59,8 +59,17 @@ class OpenStudioAwsWrapper
59
59
  @security_groups = []
60
60
  @key_pair_name = nil
61
61
  @private_key_file_name = nil
62
+ @region = options[:region] || 'unknown-region'
62
63
 
63
- @worker_keys = SSHKey.generate
64
+ # If the keys exist in the directory then load those, otherwise create new ones.
65
+ work_dir = options[:save_directory] || '.'
66
+ if File.exist?(File.join(work_dir, 'ec2_worker_key.pem')) && File.exist?(File.join(work_dir, 'ec2_worker_key.pub'))
67
+ logger.info "Worker keys already exist, loading from #{work_dir}"
68
+ @worker_keys = SSHKey.new(File.read(File.join(work_dir, 'ec2_worker_key.pem')))
69
+ else
70
+ logger.info 'Generating new worker keys'
71
+ @worker_keys = SSHKey.generate
72
+ end
64
73
 
65
74
  @private_key = nil # Private key data
66
75
 
@@ -121,9 +130,15 @@ class OpenStudioAwsWrapper
121
130
  def total_instances_count
122
131
  resp = @aws.describe_instance_status
123
132
 
124
- # TODO: make this return the region not the availability zone
125
- region = resp.instance_statuses.length > 0 ? resp.instance_statuses.first.availability_zone : 'no_instances'
126
- { total_instances: resp.instance_statuses.length, region: region }
133
+ availability_zone = resp.instance_statuses.length > 0 ? resp.instance_statuses.first.availability_zone : 'no_instances'
134
+
135
+ { total_instances: resp.instance_statuses.length, region: @region, availability_zone: availability_zone }
136
+ end
137
+
138
+ def describe_all_instances
139
+ resp = @aws.describe_instance_status
140
+
141
+ resp
127
142
  end
128
143
 
129
144
  # describe the instances by group id (this is the default method)
@@ -377,8 +392,7 @@ class OpenStudioAwsWrapper
377
392
  user_id: 'unknown_user',
378
393
  tags: [],
379
394
  ebs_volume_size: nil,
380
- availability_zone: @server.data.availability_zone,
381
- worker_public_key: ''
395
+ availability_zone: @server.data.availability_zone
382
396
  }
383
397
  launch_options = defaults.merge(launch_options)
384
398
 
@@ -69,9 +69,9 @@ describe OpenStudio::Aws::Aws do
69
69
 
70
70
  after :all do
71
71
  if File.exist? 'server_data.json'
72
- j = JSON.parse(File.read('server_data.json'), symbolize_names: true)
72
+ j = JSON.parse(File.read('server_data.json'), symbolize_names: true)
73
73
 
74
- @aws.terminate_instances_by_group_id(j[:group_id])
74
+ @aws.terminate_instances_by_group_id(j[:group_id])
75
75
  end
76
76
  end
77
77
  end
@@ -85,9 +85,9 @@ describe OpenStudio::Aws::Aws do
85
85
  end
86
86
 
87
87
  it 'should create a server' do
88
- options = {
89
- instance_type: 'm3.medium',
90
- image_id: SERVER_AMI
88
+ options = {
89
+ instance_type: 'm3.medium',
90
+ image_id: SERVER_AMI
91
91
  }
92
92
 
93
93
  @aws.create_server(options)
@@ -133,9 +133,9 @@ describe OpenStudio::Aws::Aws do
133
133
 
134
134
  after :all do
135
135
  if File.exist? 'server_data.json'
136
- j = JSON.parse(File.read('server_data.json'), symbolize_names: true)
136
+ j = JSON.parse(File.read('server_data.json'), symbolize_names: true)
137
137
 
138
- @aws.terminate_instances_by_group_id(j[:group_id])
138
+ @aws.terminate_instances_by_group_id(j[:group_id])
139
139
  end
140
140
  end
141
141
  end
@@ -279,5 +279,15 @@ describe OpenStudio::Aws::Aws do
279
279
 
280
280
  # verify that the instances are dead -- how?
281
281
  end
282
+
283
+ it 'should load in the worker keys if exist on disk' do
284
+ options = {
285
+ save_directory: 'spec/output/save_path'
286
+ }
287
+ @aws_2 = OpenStudio::Aws::Aws.new(options)
288
+
289
+ expect(@aws_2.os_aws.worker_keys.private_key).not_to be_nil
290
+ expect(@aws_2.os_aws.worker_keys.public_key).not_to be_nil
291
+ end
282
292
  end
283
293
  end
@@ -5,7 +5,7 @@ describe OpenStudioAwsWrapper do
5
5
  context 'unauthenticated session' do
6
6
  it 'should fail to authenticate' do
7
7
  options = {
8
- credentials: {
8
+ credentials: {
9
9
  access_key_id: 'some_random_access_key_id',
10
10
  secret_access_key: 'some_super_secret_access_key',
11
11
  region: 'us-east-1',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstudio-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.alpha1
4
+ version: 0.4.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Long
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp