Class: Fog::Rackspace::AutoScale::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idString (readonly)

Returns The autoscale group’s id.

Returns:

  • (String)

    The autoscale group’s id



12
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 12

identity :id

Returns group links.

Returns:

  • (Array)

    group links.



16
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 16

attribute :links

Instance Method Details

#destroyBoolean

Destroy the group

Returns:

  • (Boolean)

    returns true if group has started deleting

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



143
144
145
146
147
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 143

def destroy
  requires :identity
  service.delete_group(identity)
  true
end

#group_configFog::Rackspace::AutoScale::GroupConfiguration

Gets the group configuration for this autoscale group. The configuration describes the minimum number of entities in the group, the maximum number of entities in the group, the global cooldown time for the group, and other metadata.

Returns:

  • (Fog::Rackspace::AutoScale::GroupConfiguration)

    group_config if found

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



30
31
32
33
34
35
36
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 30

def group_config
  if attributes[:group_config].nil? && persisted?
    data = service.get_group_config(identity)
    attributes[:group_config] = load_model('GroupConfig', data.body['groupConfiguration'])
  end
  attributes[:group_config]
end

#group_config=(object = {}) ⇒ Object

Sets the configuration when this object is populated.

Parameters:

  • object (Hash<String, String>) (defaults to: {})

    Object which will stock the object



41
42
43
44
45
46
47
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 41

def group_config=(object = {})
  if object.is_a?(Hash)
    attributes[:group_config] = load_model('GroupConfig', object)
  else
    attributes[:group_config] = object
  end
end

#launch_configFog::Rackspace::AutoScale::LaunchConfiguration

Gets the launch configuration for this autoscale group. The launch configuration describes the details of how to create a server, from what image to create a server, which load balancers to join the server to, which networks to add the server to, and other metadata.

Returns:

  • (Fog::Rackspace::AutoScale::LaunchConfiguration)

    group_config if found

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



61
62
63
64
65
66
67
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 61

def launch_config
  if attributes[:launch_config].nil?  && persisted?
    data = service.get_launch_config(identity)
    attributes[:launch_config] = load_model('LaunchConfig', data.body['launchConfiguration'])
  end
  attributes[:launch_config]
end

#launch_config=(object = {}) ⇒ Object

Sets the configuration when this object is populated.

Parameters:

  • object (Hash<String, String>) (defaults to: {})

    Object which will stock the object



72
73
74
75
76
77
78
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 72

def launch_config=(object={})
  if object.is_a?(Hash)
    attributes[:launch_config] = load_model('LaunchConfig', object)
  else
    attributes[:launch_config] = object
  end
end

#pauseBoolean

Note:

NOT IMPLEMENTED YET

This operation pauses all execution of autoscaling policies.

Returns:

  • (Boolean)

    returns true if paused

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



176
177
178
179
180
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 176

def pause
  requires :identity
  data = service.pause_group_state(identity)
  true
end

#policiesFog::Rackspace::AutoScale::Policies

For the specified autoscaling group, this operation returns a list of the scaling policies that are available to the group. Each policy is described in terms of an ID, name, type, adjustment, cooldown time, and links.



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 87

def policies
  return @policies if @policies
  if persisted?
    @policies = load_model('Policies')
  else
    @policies = Fog::Rackspace::AutoScale::Policies.new(:service => service, :group => self)
    @policies.clear
  end
  @policies
  # return nil unless persisted?
  # @policies ||= load_model('Policies')
end

#resumeBoolean

Note:

NOT IMPLEMENTED YET

This operation resumes all execution of autoscaling policies.

Returns:

  • (Boolean)

    returns true if resumed

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



193
194
195
196
197
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 193

def resume
  requires :identity
  data = service.resume_group_state(identity)
  true
end

#saveBoolean

Creates group

  • requires attributes: :launch_config, :group_config, :policies

Returns:

  • (Boolean)

    returns true if group is being created

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 112

def save
  requires :launch_config, :group_config, :policies
  raise Fog::Errors::Error.new("You should update launch_config and group_config directly") if persisted?

  launch_config_hash = {
    'args' => launch_config.args,
    'type' => launch_config.type
  }
  group_config_hash = {
    'name' => group_config.name,
    'cooldown' => group_config.cooldown,
    'maxEntities' => group_config.max_entities,
    'minEntities' => group_config.min_entities
  }
  group_config_hash['metadata'] = group_config. if group_config.

  data = service.create_group(launch_config_hash, group_config_hash, policies)
  merge_attributes(data.body['group'])
  true
end

#stateString

Get the current state of the autoscale group

Returns:

  • (String)

    the state of the group

Raises:

  • (Fog::Rackspace::AutoScale:::NotFound)
    • HTTP 404

  • (Fog::Rackspace::AutoScale:::BadRequest)
    • HTTP 400

  • (Fog::Rackspace::AutoScale:::InternalServerError)
    • HTTP 500

  • (Fog::Rackspace::AutoScale:::ServiceError)

See Also:



159
160
161
162
163
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 159

def state
  requires :identity
  data = service.get_group_state(identity)
  data.body['group']
end