Module: Leeroy::Helpers::Inventory
- Included in:
- Task::Image, Task::Instantiate
- Defined in:
- lib/leeroy/helpers/inventory.rb
Constant Summary
Constants included from Logging
Logging::TRACE_FORMAT, Logging::TRACE_LEVELS, Logging::TRUNCATE_THRESHOLD
Instance Attribute Summary
Attributes included from AWS
Instance Method Summary collapse
- #genImageIndex(state = self.state, env = self.env, ec2 = self.ec2, options = self.options) ⇒ Object
-
#genImageName(phase = nil, state = self.state, options = self.options) ⇒ Object
determine the name of an AMI to use in creating an instance.
Methods included from Logging
Methods included from AWS
#awsRequest, #buildS3ObjectName, #checkSemaphore, #clearSemaphore, #createTags, #destroyInstance, #ec2Request, #filterImages, #genSemaphore, #getApplicationImageIndex, #getApplicationInstanceName, #getGoldMasterImageIndex, #getGoldMasterInstanceName, #getImageByName, #getMaxImageIndex, #getRDSInstanceEndpoint, #getSemaphore, #getSgId, #getSubnetId, #getVpcId, #initialize, #rdsRequest, #s3Request, #setSemaphore
Instance Method Details
#genImageIndex(state = self.state, env = self.env, ec2 = self.ec2, options = self.options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/leeroy/helpers/inventory.rb', line 50 def genImageIndex(state = self.state, env = self.env, ec2 = self.ec2, = self.) begin index = [:index] if index logger.debug "index provided: #{index}" else logger.debug "index not provided, calculating" phase = state.phase.to_s index = case phase when 'gold_master' getGoldMasterImageIndex.to_i + 1 when 'application' getGoldMasterImageIndex.to_i else raise "unable to determine image index for phase '#{phase}'" end end logger.debug "index: #{index}" index rescue StandardError => e raise e end end |
#genImageName(phase = nil, state = self.state, options = self.options) ⇒ Object
determine the name of an AMI to use in creating an instance
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/leeroy/helpers/inventory.rb', line 14 def genImageName(phase = nil, state = self.state, = self.) begin # extract phase from state if not provided phase = state.phase if phase.nil? raise "no phase provided in state data or as param, exiting." if phase.nil? # were we given an app_name? app_name = state.app_name? ? state.app_name : checkEnv('LEEROY_APP_NAME') logger.debug "app_name: #{app_name}" # build target depends on phase build_target = case phase.to_s when 'gold_master' 'master' when 'application' checkEnv('LEEROY_BUILD_TARGET') else raise "unable to build target for phase" end # were we given an image index? index = genImageIndex(state, self.env, self.ec2, ).to_s logger.debug "index: #{index}" image_name = [app_name, build_target, index].join('-') logger.debug "image_name: #{image_name}" image_name rescue StandardError => e raise e end end |