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

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

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Attribute Details

#idString (readonly)

Returns The autoscale group’s id.

Returns:

  • (String)

    The autoscale group’s id



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

identity :id

Returns group links.

Returns:

  • (Array)

    group links.



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

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:



135
136
137
138
139
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 135

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:



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

def group_config
  if attributes[:group_config].nil?
    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



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

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:



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

def launch_config
  if attributes[:launch_config].nil?
    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



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

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:



168
169
170
171
172
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 168

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.



88
89
90
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 88

def policies
  @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:



185
186
187
188
189
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 185

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:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 104

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:



151
152
153
154
155
# File 'lib/fog/rackspace/models/auto_scale/group.rb', line 151

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