class Rollo::Commands::Main

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/rollo/commands/main.rb, line 11
def self.exit_on_failure?
  true
end

Public Instance Methods

roll(region, asg_name, ecs_cluster_name) click to toggle source
# File lib/rollo/commands/main.rb, line 47
def roll(region, asg_name, ecs_cluster_name)
  host_cluster = Rollo::Model::HostCluster.new(asg_name, region)
  service_cluster = Rollo::Model::ServiceCluster
      .new(ecs_cluster_name, region)

  initial_hosts = host_cluster.hosts

  say(
      "Rolling instances in host cluster #{host_cluster.name} for " +
          "service cluster #{service_cluster.name}...")
  with_padding do
    unless host_cluster.has_desired_capacity?
      say('ERROR: Host cluster is not in stable state.')
      say('This may be due to scaling above or below the desired')
      say('capacity or because hosts are not in service or are ')
      say('unhealthy. Cowardly refusing to roll instances.')
      exit 1
    end

    invoke(
        "hosts:expand",
        [
            region, asg_name, ecs_cluster_name,
            host_cluster
        ])

    invoke(
        "services:expand",
        [
            region, asg_name, ecs_cluster_name,
            service_cluster
        ],
        maximum_instances: options[:maximum_service_instances])

    invoke(
        "hosts:terminate",
        [
            region, asg_name, ecs_cluster_name, initial_hosts.map(&:id),
            host_cluster, service_cluster
        ])

    invoke(
        "hosts:contract",
        [
            region, asg_name, ecs_cluster_name,
            host_cluster, service_cluster
        ])

    invoke(
        "services:contract",
        [
            region, asg_name, ecs_cluster_name,
            service_cluster
        ],
        minimum_instances: options[:minimum_service_instances])
  end

  say("Instances in host cluster #{host_cluster.name} rolled " +
      "successfully.")
end
version() click to toggle source
# File lib/rollo/commands/main.rb, line 22
def version
  say Rollo::VERSION
end