mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ovirt|compute] Updates reference to service
This commit is contained in:
parent
9d3a27f10a
commit
9c6e17bd6c
8 changed files with 31 additions and 31 deletions
|
@ -10,7 +10,7 @@ module Fog
|
|||
attribute :raw
|
||||
|
||||
def networks
|
||||
connection.list_networks(id)
|
||||
service.list_networks(id)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -10,11 +10,11 @@ module Fog
|
|||
model Fog::Compute::Ovirt::Cluster
|
||||
|
||||
def all(filters = {})
|
||||
load connection.list_clusters(filters)
|
||||
load service.list_clusters(filters)
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new connection.get_cluster(id)
|
||||
new service.get_cluster(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,16 +14,16 @@ module Fog
|
|||
def all(filters = {})
|
||||
requires :vm
|
||||
if vm.is_a? Fog::Compute::Ovirt::Server
|
||||
load connection.list_vm_interfaces(vm.id)
|
||||
load service.list_vm_interfaces(vm.id)
|
||||
elsif vm.is_a? Fog::Compute::Ovirt::Template
|
||||
load connection.list_template_interfaces(vm.id)
|
||||
load service.list_template_interfaces(vm.id)
|
||||
else
|
||||
raise 'interfaces should have vm or template'
|
||||
end
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new connection.get_interface(id)
|
||||
new service.get_interface(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,51 +46,51 @@ module Fog
|
|||
|
||||
def interfaces
|
||||
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:vm => self
|
||||
)
|
||||
end
|
||||
|
||||
def add_interface attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
connection.add_interface(id, attrs)
|
||||
service.add_interface(id, attrs)
|
||||
end
|
||||
|
||||
def update_interface attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
connection.update_interface(id, attrs)
|
||||
service.update_interface(id, attrs)
|
||||
end
|
||||
|
||||
def destroy_interface attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
connection.destroy_interface(id, attrs)
|
||||
service.destroy_interface(id, attrs)
|
||||
end
|
||||
|
||||
def volumes
|
||||
attributes[:volumes] ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:vm => self
|
||||
)
|
||||
end
|
||||
|
||||
def add_volume attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
connection.add_volume(id, attrs)
|
||||
service.add_volume(id, attrs)
|
||||
end
|
||||
|
||||
def destroy_volume attrs
|
||||
wait_for { stopped? } if attrs[:blocking]
|
||||
connection.destroy_volume(id, attrs)
|
||||
service.destroy_volume(id, attrs)
|
||||
end
|
||||
|
||||
def start(options = {})
|
||||
wait_for { stopped? } if options[:blocking]
|
||||
connection.vm_action(:id =>id, :action => :start)
|
||||
service.vm_action(:id =>id, :action => :start)
|
||||
reload
|
||||
end
|
||||
|
||||
def stop(options = {})
|
||||
connection.vm_action(:id =>id, :action => :stop)
|
||||
service.vm_action(:id =>id, :action => :stop)
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -100,26 +100,26 @@ module Fog
|
|||
end
|
||||
|
||||
def suspend(options = {})
|
||||
connection.vm_action(:id =>id, :action => :suspend)
|
||||
service.vm_action(:id =>id, :action => :suspend)
|
||||
reload
|
||||
end
|
||||
|
||||
def destroy(options = {})
|
||||
(stop unless stopped?) rescue nil #ignore failure, destroy the machine anyway.
|
||||
wait_for { stopped? }
|
||||
connection.destroy_vm(:id => id)
|
||||
service.destroy_vm(:id => id)
|
||||
end
|
||||
|
||||
def ticket(options = {})
|
||||
raise "Can not set console ticket, Server is not ready. Server status: #{status}" unless ready?
|
||||
connection.vm_ticket(id, options)
|
||||
service.vm_ticket(id, options)
|
||||
end
|
||||
|
||||
def save
|
||||
if persisted?
|
||||
connection.update_vm(attributes)
|
||||
service.update_vm(attributes)
|
||||
else
|
||||
self.id = connection.create_vm(attributes).id
|
||||
self.id = service.create_vm(attributes).id
|
||||
end
|
||||
reload
|
||||
end
|
||||
|
|
|
@ -10,11 +10,11 @@ module Fog
|
|||
model Fog::Compute::Ovirt::Server
|
||||
|
||||
def all(filters = {})
|
||||
load connection.list_virtual_machines(filters)
|
||||
load service.list_virtual_machines(filters)
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new connection.get_virtual_machine(id)
|
||||
new service.get_virtual_machine(id)
|
||||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
|
|
|
@ -24,14 +24,14 @@ module Fog
|
|||
|
||||
def interfaces
|
||||
attributes[:interfaces] ||= id.nil? ? [] : Fog::Compute::Ovirt::Interfaces.new(
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:vm => self
|
||||
)
|
||||
end
|
||||
|
||||
def volumes
|
||||
attributes[:volumes] ||= id.nil? ? [] : Fog::Compute::Ovirt::Volumes.new(
|
||||
:connection => connection,
|
||||
:service => service,
|
||||
:vm => self
|
||||
)
|
||||
end
|
||||
|
@ -41,12 +41,12 @@ module Fog
|
|||
end
|
||||
|
||||
def destroy(options = {})
|
||||
connection.client.destroy_template(id)
|
||||
service.client.destroy_template(id)
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
|
||||
connection.client.create_template(attributes)
|
||||
service.client.create_template(attributes)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -10,11 +10,11 @@ module Fog
|
|||
model Fog::Compute::Ovirt::Template
|
||||
|
||||
def all(filters = {})
|
||||
load connection.list_templates(filters)
|
||||
load service.list_templates(filters)
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new connection.get_template(id)
|
||||
new service.get_template(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,16 +14,16 @@ module Fog
|
|||
def all(filters = {})
|
||||
requires :vm
|
||||
if vm.is_a? Fog::Compute::Ovirt::Server
|
||||
load connection.list_vm_volumes(vm.id)
|
||||
load service.list_vm_volumes(vm.id)
|
||||
elsif vm.is_a? Fog::Compute::Ovirt::Template
|
||||
load connection.list_template_volumes(vm.id)
|
||||
load service.list_template_volumes(vm.id)
|
||||
else
|
||||
raise 'volumes should have vm or template'
|
||||
end
|
||||
end
|
||||
|
||||
def get(id)
|
||||
new connection.get_volume(id)
|
||||
new service.get_volume(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue