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.



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

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

Instance Attribute Details

#instance_idObject

Returns the value of attribute instance_id.



33
34
35
# File 'lib/unit-hosting/group.rb', line 33

def instance_id
  @instance_id
end

#keyObject Also known as: apikey

Returns the value of attribute key.



33
34
35
# File 'lib/unit-hosting/group.rb', line 33

def key
  @key
end

#nameObject

Returns the value of attribute name.



33
34
35
# File 'lib/unit-hosting/group.rb', line 33

def name
  @name
end

#remoteObject

Returns the value of attribute remote.



33
34
35
# File 'lib/unit-hosting/group.rb', line 33

def remote
  @remote
end

#vmsObject

Returns the value of attribute vms.



33
34
35
# File 'lib/unit-hosting/group.rb', line 33

def vms
  @vms
end

Instance Method Details

#tablizeObject



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

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



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

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