Class: Rollo::Commands::Main

Inherits:
Thor
  • Object
show all
Defined in:
lib/rollo/commands/main.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rollo/commands/main.rb', line 11

def self.exit_on_failure?
  true
end

Instance Method Details

#roll(region, asg_name, ecs_cluster_name) ⇒ Object



47
48
49
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# 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

#versionObject



22
23
24
# File 'lib/rollo/commands/main.rb', line 22

def version
  say Rollo::VERSION
end