2014-04-02 08:57:15 -04:00
|
|
|
require 'fog/compute/models/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenNebula
|
|
|
|
class Server < Fog::Compute::Server
|
|
|
|
identity :id
|
2014-05-14 03:11:14 -04:00
|
|
|
attribute :template_str
|
|
|
|
attribute :name
|
|
|
|
attribute :uuid
|
|
|
|
attribute :state
|
|
|
|
attribute :status
|
|
|
|
attribute :ip
|
|
|
|
attribute :mac
|
|
|
|
attribute :vcpu
|
|
|
|
attribute :cpu
|
|
|
|
attribute :memory
|
|
|
|
attribute :user
|
|
|
|
attribute :gid
|
|
|
|
attribute :group
|
|
|
|
attribute :onevm_object
|
|
|
|
attribute :flavor
|
2014-04-02 08:57:15 -04:00
|
|
|
|
|
|
|
def save
|
|
|
|
#if persisted?
|
|
|
|
# service.update_vm(attributes)
|
|
|
|
#else
|
2014-05-15 07:54:57 -04:00
|
|
|
merge_attributes(service.vm_allocate(attributes))
|
2014-04-02 08:57:15 -04:00
|
|
|
#end
|
|
|
|
#reload
|
|
|
|
end
|
|
|
|
|
2014-05-15 06:05:33 -04:00
|
|
|
# only for integration in foreman
|
|
|
|
# needed by formbuilder
|
|
|
|
# should be handled by foreman and not from by fog
|
|
|
|
def vminterfaces
|
2014-05-14 03:11:14 -04:00
|
|
|
#[] << Fog::Compute::OpenNebula::Interfaces.new
|
|
|
|
[]
|
|
|
|
end
|
2014-04-22 09:29:44 -04:00
|
|
|
|
2014-05-15 06:05:33 -04:00
|
|
|
# only for integration in foreman
|
|
|
|
# needed by formbuilder
|
|
|
|
# should be handled by foreman and not from by fog
|
|
|
|
def vminterfaces_attributes=(attributes)
|
2014-05-14 03:11:14 -04:00
|
|
|
true
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
2014-05-14 03:11:14 -04:00
|
|
|
def vm_ip_address
|
|
|
|
ip
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
|
|
|
def private_ip_address
|
2014-05-14 03:11:14 -04:00
|
|
|
ip
|
|
|
|
end
|
|
|
|
|
|
|
|
def public_ip_address
|
|
|
|
ip
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
2014-05-14 03:11:14 -04:00
|
|
|
def vm_mac_address
|
|
|
|
mac
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
2014-05-14 03:11:14 -04:00
|
|
|
def start
|
|
|
|
if status == 4
|
|
|
|
service.vm_resume(id)
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
2014-05-14 03:11:14 -04:00
|
|
|
def stop
|
|
|
|
Fog::Logger.warning("stop VM: ID:#{id}")
|
|
|
|
service.vm_stop(id)
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
|
|
|
def destroy
|
|
|
|
service.vm_destroy(id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def ready?
|
2014-05-14 03:11:14 -04:00
|
|
|
(status == 3)
|
2014-04-02 08:57:15 -04:00
|
|
|
end
|
|
|
|
|
2014-05-15 06:05:33 -04:00
|
|
|
# only for integration in foreman
|
|
|
|
# needed by formbuilder
|
|
|
|
# should be handled by foreman and not by fog
|
2014-05-14 03:11:14 -04:00
|
|
|
def template_id
|
2014-05-15 06:05:33 -04:00
|
|
|
""
|
2014-05-14 03:11:14 -04:00
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
|
2014-05-14 03:11:14 -04:00
|
|
|
def console_output
|
|
|
|
requires :id
|
|
|
|
service.get_vnc_console(id, "vnc", onevm_object)
|
|
|
|
end
|
2014-04-02 08:57:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|