Class: RestGearGroup

Inherits:
OpenShift::Model
  • Object
show all
Defined in:
app/models/rest_gear_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_instance, gear_states, url, nolinks = false) ⇒ RestGearGroup

Returns a new instance of RestGearGroup.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/rest_gear_group.rb', line 4

def initialize(group_instance, gear_states, url, nolinks=false)
  app               = group_instance.app
  self.uuid         = group_instance.uuid
  self.name         = group_instance.name
  self.gear_profile = group_instance.node_profile
  self.gears        = group_instance.gears.map{ |gear| {:id => gear.uuid, :state => gear_states[gear.uuid] || 'unknown'} }
  self.cartridges   = group_instance.component_instances.map { |comp_inst| app.comp_instance_map[comp_inst].cart_properties.merge({:name => app.comp_instance_map[comp_inst].parent_cart_name}) }
  self.cartridges.delete_if{ |comp| comp[:name] == app.name }
  storage = group_instance.get_quota
  self.base_gear_storage = storage["base_gear_storage"]
  self.additional_gear_storage = storage["additional_gear_storage"]
  self.scales_to = group_instance.max
  self.scales_from = group_instance.min
  self.links = {
    "GET" => Link.new("Get gear group", "GET", URI::join(url, "domains/#{app.domain.namespace}/applications/#{app.name}/gear_groups/#{uuid}"))
  } unless nolinks
end

Instance Attribute Details

#additional_gear_storageObject

Returns the value of attribute additional_gear_storage.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def additional_gear_storage
  @additional_gear_storage
end

#base_gear_storageObject

Returns the value of attribute base_gear_storage.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def base_gear_storage
  @base_gear_storage
end

#cartridgesObject

Returns the value of attribute cartridges.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def cartridges
  @cartridges
end

#gear_profileObject

Returns the value of attribute gear_profile.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def gear_profile
  @gear_profile
end

#gearsObject

Returns the value of attribute gears.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def gears
  @gears
end

Returns the value of attribute links.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def links
  @links
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def name
  @name
end

#scales_fromObject

Returns the value of attribute scales_from.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def scales_from
  @scales_from
end

#scales_toObject

Returns the value of attribute scales_to.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def scales_to
  @scales_to
end

#uuidObject

Returns the value of attribute uuid.



2
3
4
# File 'app/models/rest_gear_group.rb', line 2

def uuid
  @uuid
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



22
23
24
25
# File 'app/models/rest_gear_group.rb', line 22

def to_xml(options={})
  options[:tag_name] = "gear_group"
  super(options)
end