Class: UnitHosting::Group

Inherits:
Object
  • Object
show all
Includes:
Api
Defined in:
lib/unit-hosting/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api

keypath

Constructor Details

#initialize(instance_id = nil) ⇒ Group

Returns a new instance of Group.



38
39
40
# File 'lib/unit-hosting/group.rb', line 38

def initialize(instance_id = nil)
  @instance_id = instance_id
end

Instance Attribute Details

#instance_idObject

Returns the value of attribute instance_id.



35
36
37
# File 'lib/unit-hosting/group.rb', line 35

def instance_id
  @instance_id
end

#keyObject Also known as: apikey

Returns the value of attribute key.



35
36
37
# File 'lib/unit-hosting/group.rb', line 35

def key
  @key
end

#nameObject

Returns the value of attribute name.



35
36
37
# File 'lib/unit-hosting/group.rb', line 35

def name
  @name
end

#remoteObject

Returns the value of attribute remote.



35
36
37
# File 'lib/unit-hosting/group.rb', line 35

def remote
  @remote
end

#vmsObject

Returns the value of attribute vms.



35
36
37
# File 'lib/unit-hosting/group.rb', line 35

def vms
  @vms
end

Instance Method Details

#tablizeObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/unit-hosting/group.rb', line 48

def tablize
  table = Mutter::Table.new(:delimiter => '|') do
    column :style => :green
    column;column
  end
  return "#{instance_id} has no vms" unless @vms
  @vms.each { |vm|
    table << [vm["instance_id"],vm["status"],vm["display_name"]]
  }
  table.to_s if @vms.length > 0
end

#updateObject



42
43
44
45
46
# File 'lib/unit-hosting/group.rb', line 42

def update
  # STDERR.puts "update #{instance_id}"
  @vms = VmGroup.new(@instance_id,@key).vms
  self
end