1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/opennebula/models/compute/server.rb

93 lines
1.9 KiB
Ruby
Raw Normal View History

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
def save
2014-05-15 07:54:57 -04:00
merge_attributes(service.vm_allocate(attributes))
end
# only for integration in foreman
# needed by formbuilder
# should be handled by foreman and not by fog
def vminterfaces
2014-05-14 03:11:14 -04:00
[]
end
# 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-05-14 03:11:14 -04:00
def vm_ip_address
ip
end
def private_ip_address
2014-05-14 03:11:14 -04:00
ip
end
def public_ip_address
ip
end
2014-05-14 03:11:14 -04:00
def vm_mac_address
mac
end
2014-05-14 03:11:14 -04:00
def start
if status == 4
service.vm_resume(id)
end
true
2014-05-14 03:11:14 -04:00
end
2014-05-14 03:11:14 -04:00
def stop
Fog::Logger.warning("stop VM: ID:#{id}")
service.vm_stop(id)
end
def destroy
service.vm_destroy(id)
end
def ready?
2014-05-14 03:11:14 -04:00
(status == 3)
end
# 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-14 03:11:14 -04:00
end
2014-05-14 03:11:14 -04:00
def console_output
requires :id
service.get_vnc_console(id, "vnc", onevm_object)
end
end
end
end
end