2012-01-22 10:38:02 -05:00
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Ovirt
|
|
|
|
|
|
|
|
class Template < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
|
2012-03-12 06:25:03 -04:00
|
|
|
attr_accessor :raw
|
|
|
|
|
2012-01-22 10:38:02 -05:00
|
|
|
attribute :name
|
|
|
|
attribute :description
|
|
|
|
attribute :profile
|
|
|
|
attribute :display
|
|
|
|
attribute :storage, :aliases => 'disk_size'
|
|
|
|
attribute :creation_time
|
|
|
|
attribute :os
|
|
|
|
attribute :status
|
|
|
|
attribute :cores, :aliases => 'cpus'
|
|
|
|
attribute :memory
|
|
|
|
attribute :cluster
|
2012-03-12 06:25:03 -04:00
|
|
|
attribute :interfaces
|
2012-04-09 09:42:58 -04:00
|
|
|
attribute :volumes
|
2012-03-12 06:25:03 -04:00
|
|
|
|
|
|
|
def interfaces
|
|
|
|
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
|
2012-12-22 18:24:20 -05:00
|
|
|
:service => service,
|
2012-03-12 06:25:03 -04:00
|
|
|
:vm => self
|
|
|
|
)
|
|
|
|
end
|
2012-01-22 10:38:02 -05:00
|
|
|
|
2012-04-09 09:42:58 -04:00
|
|
|
def volumes
|
|
|
|
attributes[:volumes] ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
|
2012-12-22 18:24:20 -05:00
|
|
|
:service => service,
|
2012-04-09 09:42:58 -04:00
|
|
|
:vm => self
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-01-22 10:38:02 -05:00
|
|
|
def ready?
|
|
|
|
!(status =~ /down/i)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy(options = {})
|
2012-12-22 18:24:20 -05:00
|
|
|
service.client.destroy_template(id)
|
2012-01-22 10:38:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
2012-12-22 21:45:05 -05:00
|
|
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
2012-12-22 18:24:20 -05:00
|
|
|
service.client.create_template(attributes)
|
2012-01-22 10:38:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
name
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|