Class: Roca::VirtualMachine

Inherits:
Object
  • Object
show all
Extended by:
ConnectorHelper::ClassMethods
Includes:
ConnectorHelper
Defined in:
lib/roca/virtual_machine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConnectorHelper::ClassMethods

connector, connector=

Methods included from ConnectorHelper

#connector, #connector=

Constructor Details

#initialize(attributes = {}) ⇒ VirtualMachine

Returns a new instance of VirtualMachine.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/roca/virtual_machine.rb', line 34

def initialize(attributes = {})
  @virtual_machine_id = attributes[:virtual_machine_id],
  @user_id            = attributes[:user_id],
  @group_id           = attributes[:group_id],
  @user_name          = attributes[:user_name],
  @group_name         = attributes[:group_name],
  @name               = attributes[:name],
  @last_poll          = attributes[:last_poll],
  @state              = attributes[:state],
  @lcm_state          = attributes[:lcm_state],
  @stime              = attributes[:stime],
  @etime              = attributes[:etime],
  @memory             = attributes[:memory],
  @cpu                = attributes[:cpu],
  @net_tx             = attributes[:net_tx],
  @net_rx             = attributes[:net_rx]
end

Instance Attribute Details

#cpuObject (readonly)

Returns the value of attribute cpu.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def cpu
  @cpu
end

#group_idObject (readonly)

Returns the value of attribute group_id.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def group_id
  @group_id
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def group_name
  @group_name
end

#last_pollObject (readonly)

Returns the value of attribute last_poll.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def last_poll
  @last_poll
end

#memoryObject (readonly)

Returns the value of attribute memory.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def memory
  @memory
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def name
  @name
end

#net_rxObject (readonly)

Returns the value of attribute net_rx.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def net_rx
  @net_rx
end

#net_txObject (readonly)

Returns the value of attribute net_tx.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def net_tx
  @net_tx
end

#stateObject (readonly)

Returns the value of attribute state.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def state
  @state
end

#user_idObject (readonly)

Returns the value of attribute user_id.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def user_id
  @user_id
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def user_name
  @user_name
end

#virtual_machine_idObject (readonly)

Returns the value of attribute virtual_machine_id.



6
7
8
# File 'lib/roca/virtual_machine.rb', line 6

def virtual_machine_id
  @virtual_machine_id
end

Class Method Details

.build_from_hash(attributes = {}) ⇒ Object



8
9
10
# File 'lib/roca/virtual_machine.rb', line 8

def self.build_from_hash(attributes = {})
  VirtualMachine.new(attributes)
end

.build_from_xml(xml_description) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/roca/virtual_machine.rb', line 12

def self.build_from_xml(xml_description)
  doc = Nokogiri::Slop(xml_description)

  VirtualMachine.build_from_hash(
    virtual_machine_id:  doc.VM.ID.content.to_i,
    user_id:             doc.VM.UID.content.to_i,
    group_id:            doc.VM.GID.content.to_i,
    user_name:           doc.VM.UNAME.content,
    group_name:          doc.VM.GNAME.content,
    name:                doc.VM.NAME.content,
    last_poll:           doc.VM.LAST_POLL.content.to_i,
    state:               doc.VM.STATE.content.to_i,
    lcm_state:           doc.VM.LCM_STATE.content.to_i,
    stime:               doc.VM.STIME.content.to_i,
    etime:               doc.VM.ETIME.content.to_i,
    memory:              doc.VM.MEMORY.content.to_i,
    cpu:                 doc.VM.CPU.content.to_i,
    net_tx:              doc.VM.NET_TX.content.to_i,
    net_rx:              doc.VM.NET_RX.content.to_i
  )
end