Skip to content

Commit

Permalink
Allows the user to optionally override the OpenStudio version, or ser…
Browse files Browse the repository at this point in the history
…ver AMI + worker AMI
  • Loading branch information
axelstudios committed Dec 17, 2013
1 parent 2af591f commit 6cdad8b
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions openstudiocore/ruby/cloud/aws.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ require 'net/ssh'
require 'tempfile'
require 'time'

OPENSTUDIO_VERSION='${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH}'

def error(code, msg)
puts ({:error => {:code => code, :message => msg},
:arguments => ARGV[2..-1]}.to_json)
Expand Down Expand Up @@ -89,21 +87,28 @@ end

if ARGV.length == 6
@params = JSON.parse(ARGV[5])
OPENSTUDIO_VERSION = @params['openstudio_version'] if @params.include?('openstudio_version')
@server_image_id = @params['server_ami'] if @params.include?('server_ami')
@worker_image_id = @params['worker_ami'] if @params.include?('worker_ami')
end

resp = Net::HTTP.get_response('developer.nrel.gov','/downloads/buildings/openstudio/rsrc/amis.json')
if resp.code == '200'
result = JSON.parse(resp.body)
version = result.has_key?(OPENSTUDIO_VERSION) ? OPENSTUDIO_VERSION : 'default'
OPENSTUDIO_VERSION = '${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH}' unless defined?(OPENSTUDIO_VERSION)

if (!defined?(@server_image_id) || !defined?(@worker_image_id))
resp = Net::HTTP.get_response('developer.nrel.gov','/downloads/buildings/openstudio/rsrc/amis.json')
if resp.code == '200'
result = JSON.parse(resp.body)
version = result.has_key?(OPENSTUDIO_VERSION) ? OPENSTUDIO_VERSION : 'default'

@server_image_id = result[version]['server']
if ARGV.length >= 6 && @params['instance_type'] == 'cc2.8xlarge'
@worker_image_id = result[version]['cc2worker']
@server_image_id = result[version]['server']
if ARGV.length >= 6 && @params['instance_type'] == 'cc2.8xlarge'
@worker_image_id = result[version]['cc2worker']
else
@worker_image_id = result[version]['worker']
end
else
@worker_image_id = result[version]['worker']
error(resp.code, 'Unable to download AMI IDs')
end
else
error(resp.code, 'Unable to download AMI IDs')
end

def create_struct(instance, procs)
Expand Down

0 comments on commit 6cdad8b

Please sign in to comment.