mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
* Added create_vbd and provision_server requests
* Do not provision server when :auto_start is false * Add Server.provisio method * Add VBD.save method
This commit is contained in:
parent
e269f7d6de
commit
9ef0aa59ca
6 changed files with 81 additions and 3 deletions
|
@ -41,6 +41,7 @@ module Fog
|
|||
request :create_server
|
||||
request :create_vif
|
||||
request :create_vdi
|
||||
request :create_vbd
|
||||
request :destroy_vif
|
||||
request :clone_server
|
||||
request :destroy_server
|
||||
|
@ -56,6 +57,7 @@ module Fog
|
|||
request :set_affinity
|
||||
request :set_attribute
|
||||
request :reboot_server
|
||||
request :provision_server
|
||||
|
||||
class Real
|
||||
|
||||
|
|
|
@ -177,6 +177,10 @@ module Fog
|
|||
stop 'clean'
|
||||
end
|
||||
|
||||
def provision
|
||||
connection.provision_server reference
|
||||
end
|
||||
|
||||
# def snapshot
|
||||
# requires :reference, :name_label
|
||||
# data = connection.snapshot_server(@reference, @name_label)
|
||||
|
|
|
@ -28,6 +28,9 @@ module Fog
|
|||
attribute :runtime_properties
|
||||
attribute :unpluggable
|
||||
attribute :bootable
|
||||
attribute :qos_supported_algorithms
|
||||
attribute :qos_algorithm_params
|
||||
attribute :qos_algorithm_type
|
||||
attribute :empty
|
||||
attribute :__metrics, :aliases => :metrics
|
||||
|
||||
|
@ -37,7 +40,7 @@ module Fog
|
|||
def vdi
|
||||
connection.vdis.get __vdi
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# TODO: May it return nil?
|
||||
#
|
||||
|
@ -45,6 +48,12 @@ module Fog
|
|||
connection.servers.get __vm
|
||||
end
|
||||
|
||||
def save
|
||||
requires :vdi, :server
|
||||
ref = connection.create_vbd attributes[:server], attributes[:vdi], attributes
|
||||
merge_attributes connection.vbds.get(ref).attributes
|
||||
end
|
||||
|
||||
def unplug
|
||||
connection.unplug_vbd reference
|
||||
end
|
||||
|
|
|
@ -35,8 +35,10 @@ module Fog
|
|||
networks.each do |n|
|
||||
create_vif ref, n.reference
|
||||
end
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
|
||||
start_vm( ref ) unless extra_args[:auto_start] == false
|
||||
if !extra_args[:auto_start] == false
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
|
||||
start_vm( ref )
|
||||
end
|
||||
|
||||
ref
|
||||
end
|
||||
|
|
40
lib/fog/xenserver/requests/compute/create_vbd.rb
Normal file
40
lib/fog/xenserver/requests/compute/create_vbd.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
class Real
|
||||
|
||||
def create_vbd( vm_ref, vdi_ref, config = {} )
|
||||
raise ArgumentError.new('Invalid config') if config.nil?
|
||||
vm_ref = vm_ref.reference if vm_ref.kind_of? Fog::Compute::XenServer::Server
|
||||
vdi_ref = vdi_ref.reference if vdi_ref.kind_of? Fog::Compute::XenServer::VDI
|
||||
config.reject! { |k,v| (k == :server) or (k == :vdi) }
|
||||
default_config = {
|
||||
:VM => vm_ref,
|
||||
:VDI => vdi_ref,
|
||||
:empty => false,
|
||||
:other_config => {'owner' => ''},
|
||||
:userdevice => "0",
|
||||
:bootable => true,
|
||||
:mode => 'RW',
|
||||
:qos_algorithm_type=> '',
|
||||
:qos_algorithm_params=> {},
|
||||
:qos_supported_algorithms=> [],
|
||||
:type => 'Disk'
|
||||
}.merge config
|
||||
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VBD.create'}, default_config )
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_vbd( config )
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/fog/xenserver/requests/compute/provision_server.rb
Normal file
21
lib/fog/xenserver/requests/compute/provision_server.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
class Real
|
||||
|
||||
def provision_server( ref )
|
||||
@connection.request({:parser => Fog::Parsers::XenServer::Base.new, :method => 'VM.provision'}, ref)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def provision_server( ref )
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue