class Mstacks

Public Instance Methods

active_mstacks() click to toggle source
# File lib/mstacks.rb, line 17
def active_mstacks()
  a = []
  get_active_stack_summaries.each do |summary|
    stack_identity = parse_stack_identity(summary[:stack_name])
    if stack_identity 
      stack_info = stack_identity.merge(summary)
      a.push(stack_info)
    end
  end
  return a
end
active_mstacks_hash() click to toggle source
# File lib/mstacks.rb, line 5
def active_mstacks_hash()
  stacks = {}
  get_active_stack_summaries.each do |summary|
    stack_identity = parse_stack_identity(summary[:stack_name])
    if stack_identity 
      stack_info = stack_identity.merge(summary)
      stacks[summary[:stack_name]] = stack_info
    end
  end
  return stacks
end
autoupdate_stack_configs(environment_type) click to toggle source
# File lib/mstacks.rb, line 29
def autoupdate_stack_configs(environment_type)
  yr = Ploy::YamlReader.new
  conf = yr.from_http("http://stack-hub/api/configured-stacks?EnvironmentType=#{environment_type}")

  configs = []
  conf.each do |name, conf|
    if conf['stack_autoupdate']
      configs.push(conf)
    end
  end
  return configs
end
get_active_stack_summaries() click to toggle source
# File lib/mstacks.rb, line 60
def get_active_stack_summaries()
  cfn = AWS::CloudFormation.new
  return cfn.stack_summaries.with_status(statuses.to_a)
end
obsolete_statuses() click to toggle source
# File lib/mstacks.rb, line 83
def obsolete_statuses()
  return Set.new [
    :delete_in_progress,
    :delete_complete,
    :create_failed
  ]
end
parse_stack_identity(name) click to toggle source
# File lib/mstacks.rb, line 47
def parse_stack_identity(name)
  p = name.split("--")
  if not p.length == 3
    return nil
  end
  return {
    'StackName'       => name,
    'StackType'       => p[0],
    'EnvironmentName' => p[1],
    'EnvironmentType' => p[2]
  }
end
stack_hub_url(stack_info) click to toggle source
# File lib/mstacks.rb, line 42
def stack_hub_url(stack_info)
  stack_name = stack_info.has_key?(:stack_name) ? stack_info[:stack_name] : stack_info['StackName']
  return "http://stack-hub/api/#{stack_name}"
end
statuses() click to toggle source
# File lib/mstacks.rb, line 65
def statuses()
  return Set.new [
    :create_in_progress,
    :create_complete,
    :rollback_in_progress,
    :rollback_failed,
    :rollback_complete,
    :delete_failed,
    :update_in_progress,
    :update_complete_cleanup_in_progress,
    :update_complete,
    :update_rollback_in_progress,
    :update_rollback_failed,
    :update_rollback_complete_cleanup_in_progress,
    :update_rollback_complete
  ]
end