Class: Fog::Compute::Ovirt::Server

Inherits:
Server show all
Defined in:
lib/fog/ovirt/models/compute/server.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Server

#scp, #scp_download, #ssh

Methods inherited from Model

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

Methods included from Attributes::ClassMethods

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

Methods included from Attributes::InstanceMethods

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

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroy(options = {}) ⇒ Object



62
63
64
65
66
# File 'lib/fog/ovirt/models/compute/server.rb', line 62

def destroy(options = {})
  (stop unless stopped?) rescue nil #ignore failure, destroy the machine anyway.
  wait_for { stopped? }
  connection.destroy_vm(:id => id)
end

#macObject



37
38
39
# File 'lib/fog/ovirt/models/compute/server.rb', line 37

def mac
  raw.interfaces.first.mac if raw.interfaces
end

#ready?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fog/ovirt/models/compute/server.rb', line 29

def ready?
  !(status =~ /down/i)
end

#reboot(options = {}) ⇒ Object



52
53
54
55
# File 'lib/fog/ovirt/models/compute/server.rb', line 52

def reboot(options = {})
  stop unless stopped?
  start options.merge(:blocking => true)
end

#saveObject



68
69
70
71
72
73
74
75
# File 'lib/fog/ovirt/models/compute/server.rb', line 68

def save
  if identity
    connection.update_vm(attributes)
  else
    self.id = connection.create_vm(attributes).id
  end
  reload
end

#start(options = {}) ⇒ Object



41
42
43
44
45
# File 'lib/fog/ovirt/models/compute/server.rb', line 41

def start(options = {})
  wait_for { stopped? } if options[:blocking]
  connection.vm_action(:id =>id, :action => :start)
  reload
end

#stop(options = {}) ⇒ Object



47
48
49
50
# File 'lib/fog/ovirt/models/compute/server.rb', line 47

def stop(options = {})
  connection.vm_action(:id =>id, :action => :stop)
  reload
end

#stopped?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fog/ovirt/models/compute/server.rb', line 33

def stopped?
  !!(status =~ /down/i)
end

#suspend(options = {}) ⇒ Object



57
58
59
60
# File 'lib/fog/ovirt/models/compute/server.rb', line 57

def suspend(options = {})
  connection.vm_action(:id =>id, :action => :suspend)
  reload
end

#to_sObject



77
78
79
# File 'lib/fog/ovirt/models/compute/server.rb', line 77

def to_s
  name
end