Class: Fog::Rackspace::AutoScale::GroupBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/rackspace/models/auto_scale/group_builder.rb

Class Method Summary collapse

Class Method Details

.build(service, attributes) ⇒ Object



12
13
14
# File 'lib/fog/rackspace/models/auto_scale/group_builder.rb', line 12

def build(service, attributes)
  service.groups.new :group_config => build_group_config(attributes), :launch_config => build_server_launch_config(attributes)
end

.build_group_config(attributes) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/fog/rackspace/models/auto_scale/group_builder.rb', line 16

def build_group_config(attributes)
  Fog::Rackspace::AutoScale::GroupConfig.new :max_entities => attributes[:max_entities],
    :min_entities => attributes[:min_entities],
    :cooldown => attributes[:cooldown],
    :name => attributes[:name],
    :metadata => attributes[:metadata] || {}
end

.build_server_launch_config(attributes) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/fog/rackspace/models/auto_scale/group_builder.rb', line 24

def build_server_launch_config(attributes)
  return nil unless attributes[:launch_config_type] == :launch_server
  args = {"server" => build_server_template(attributes) }
  args["loadBalancers"] = build_load_balancers(attributes) if attributes[:load_balancers]

  Fog::Rackspace::AutoScale::LaunchConfig.new :type => :launch_server, :args => args
end