mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[xenserver|compute] Updates reference to service
This commit is contained in:
parent
e8630a0083
commit
0c674865d6
20 changed files with 162 additions and 162 deletions
|
@ -7,9 +7,9 @@ module Fog
|
|||
class Host < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=host
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :name, :aliases => :name_label
|
||||
attribute :uuid
|
||||
attribute :address
|
||||
|
@ -22,17 +22,17 @@ module Fog
|
|||
attribute :__pbds, :aliases => :PBDs
|
||||
attribute :__pifs, :aliases => :PIFs
|
||||
attribute :__resident_vms, :aliases => :resident_VMs
|
||||
|
||||
|
||||
def pifs
|
||||
__pifs.collect { |pif| connection.pifs.get pif }
|
||||
__pifs.collect { |pif| service.pifs.get pif }
|
||||
end
|
||||
|
||||
def pbds
|
||||
__pbds.collect { |pbd| connection.pbds.get pbd }
|
||||
__pbds.collect { |pbd| service.pbds.get pbd }
|
||||
end
|
||||
|
||||
def resident_servers
|
||||
__resident_vms.collect { |ref| connection.servers.get ref }
|
||||
__resident_vms.collect { |ref| service.servers.get ref }
|
||||
end
|
||||
|
||||
def resident_vms
|
||||
|
@ -41,7 +41,7 @@ module Fog
|
|||
|
||||
def metrics
|
||||
return nil unless __metrics
|
||||
rec = connection.get_record(__metrics, 'host_metrics' )
|
||||
rec = service.get_record(__metrics, 'host_metrics' )
|
||||
Fog::Compute::XenServer::HostMetrics.new(rec)
|
||||
end
|
||||
|
||||
|
@ -107,7 +107,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,26 +4,26 @@ require 'fog/xenserver/models/compute/host'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class Hosts < Fog::Collection
|
||||
|
||||
|
||||
model Fog::Compute::XenServer::Host
|
||||
|
||||
|
||||
def all(options={})
|
||||
data = connection.get_records 'host'
|
||||
data = service.get_records 'host'
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
||||
def get( host_ref )
|
||||
if host_ref && host = connection.get_record( host_ref, 'host' )
|
||||
if host_ref && host = service.get_record( host_ref, 'host' )
|
||||
new(host)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,15 +3,15 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class Network < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=network
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :__vifs, :aliases => :VIFs
|
||||
attribute :__vifs, :aliases => :VIFs
|
||||
attribute :tags
|
||||
attribute :mtu, :aliases => :MTU
|
||||
attribute :bridge
|
||||
|
@ -19,23 +19,23 @@ module Fog
|
|||
attribute :name, :aliases => :name_label
|
||||
attribute :other_config
|
||||
attribute :__pifs, :aliases => :PIFs
|
||||
attribute :allowed_operations
|
||||
attribute :allowed_operations
|
||||
attribute :current_operations
|
||||
attribute :blobs
|
||||
|
||||
|
||||
def refresh
|
||||
data = connection.get_record( reference, 'network' )
|
||||
data = service.get_record( reference, 'network' )
|
||||
merge_attributes( data )
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Return the list of network related PIFs
|
||||
#
|
||||
def pifs
|
||||
p = []
|
||||
__pifs.each do |pif|
|
||||
p << connection.pifs.get(pif)
|
||||
p << service.pifs.get(pif)
|
||||
end
|
||||
p
|
||||
end
|
||||
|
@ -46,13 +46,13 @@ module Fog
|
|||
def vifs
|
||||
v = []
|
||||
__vifs.each do |vif|
|
||||
v << connection.vifs.get(vif)
|
||||
v << service.vifs.get(vif)
|
||||
end
|
||||
v
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,18 +8,18 @@ module Fog
|
|||
class Networks < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::Network
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'network'
|
||||
data = service.get_records 'network'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( ref )
|
||||
if ref && obj = connection.get_record( ref, 'network' )
|
||||
if ref && obj = service.get_record( ref, 'network' )
|
||||
new(obj)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
|
@ -3,20 +3,20 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class PBD < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=PBD
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :__host, :aliases => :host
|
||||
attribute :__sr, :aliases => :SR
|
||||
attribute :currently_attached
|
||||
|
||||
def sr
|
||||
connection.storage_repositories.get __sr
|
||||
service.storage_repositories.get __sr
|
||||
end
|
||||
|
||||
def storage_repository
|
||||
|
@ -24,7 +24,7 @@ module Fog
|
|||
end
|
||||
|
||||
def host
|
||||
connection.hosts.get __host
|
||||
service.hosts.get __host
|
||||
end
|
||||
|
||||
def unplug
|
||||
|
@ -32,7 +32,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,18 +8,18 @@ module Fog
|
|||
class Pbds < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::PBD
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'PBD'
|
||||
data = service.get_records 'PBD'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( ref )
|
||||
if ref && obj = connection.get_record( ref, 'PBD' )
|
||||
if ref && obj = service.get_record( ref, 'PBD' )
|
||||
new(obj)
|
||||
else
|
||||
nil
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class PIF < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=PIF
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :physical
|
||||
attribute :mac, :aliases => :MAC
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
attribute :dns, :aliases => :DNS
|
||||
attribute :gateway
|
||||
attribute :ip, :aliases => :IP
|
||||
attribute :ip_configuration_mode
|
||||
attribute :ip_configuration_mode
|
||||
attribute :mtu, :aliases => :MTU
|
||||
attribute :__network, :aliases => :network
|
||||
attribute :netmask
|
||||
|
@ -30,17 +30,17 @@ module Fog
|
|||
attribute :vlan, :aliases => :VLAN
|
||||
attribute :other_config
|
||||
attribute :__host, :aliases => :host
|
||||
|
||||
|
||||
def network
|
||||
connection.networks.get __network
|
||||
service.networks.get __network
|
||||
end
|
||||
|
||||
def host
|
||||
connection.hosts.get __host
|
||||
service.hosts.get __host
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,18 +8,18 @@ module Fog
|
|||
class Pifs < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::PIF
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'PIF'
|
||||
data = service.get_records 'PIF'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( ref )
|
||||
if ref && obj = connection.get_record( ref, 'PIF' )
|
||||
if ref && obj = service.get_record( ref, 'PIF' )
|
||||
new(obj)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
|
@ -3,27 +3,27 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class Pool < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=pool
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :name, :aliases => :name_label
|
||||
attribute :description, :aliases => :name_description
|
||||
attribute :__default_sr, :aliases => :default_SR
|
||||
attribute :__master, :aliases => :master
|
||||
attribute :tags
|
||||
attribute :tags
|
||||
attribute :restrictions
|
||||
attribute :ha_enabled
|
||||
attribute :vswitch_controller
|
||||
attribute :__suspend_image_sr, :aliases => :suspend_image_SR
|
||||
|
||||
|
||||
|
||||
def default_sr
|
||||
connection.storage_repositories.get __default_sr
|
||||
service.storage_repositories.get __default_sr
|
||||
end
|
||||
|
||||
def default_sr=(sr)
|
||||
|
@ -44,7 +44,7 @@ module Fog
|
|||
end
|
||||
|
||||
def master
|
||||
connection.hosts.get __master
|
||||
service.hosts.get __master
|
||||
end
|
||||
|
||||
def set_attribute(name, *val)
|
||||
|
@ -56,7 +56,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,18 +8,18 @@ module Fog
|
|||
class Pools < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::Pool
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'pool'
|
||||
data = service.get_records 'pool'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( pool_ref )
|
||||
if pool_ref && pool = connection.get_record( pool_ref, 'pool' )
|
||||
if pool_ref && pool = service.get_record( pool_ref, 'pool' )
|
||||
new(pool)
|
||||
else
|
||||
nil
|
||||
|
|
|
@ -7,9 +7,9 @@ module Fog
|
|||
class Server < Fog::Compute::Server
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VM
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :name, :aliases => :name_label
|
||||
attribute :__affinity, :aliases => :affinity
|
||||
|
@ -56,11 +56,11 @@ module Fog
|
|||
end
|
||||
|
||||
def vbds
|
||||
__vbds.collect {|vbd| connection.vbds.get vbd }
|
||||
__vbds.collect {|vbd| service.vbds.get vbd }
|
||||
end
|
||||
|
||||
def affinity
|
||||
connection.hosts.get __affinity
|
||||
service.hosts.get __affinity
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -74,26 +74,26 @@ module Fog
|
|||
if vbd.vdi.allowed_operations.include?("destroy")
|
||||
end
|
||||
end
|
||||
connection.destroy_server( reference )
|
||||
service.destroy_server( reference )
|
||||
true
|
||||
end
|
||||
|
||||
def set_attribute(name, *val)
|
||||
data = connection.set_attribute( 'VM', reference, name, *val )
|
||||
data = service.set_attribute( 'VM', reference, name, *val )
|
||||
# Do not reload automatically for performance reasons
|
||||
# We can set multiple attributes at the same time and
|
||||
# then reload manually
|
||||
#reload
|
||||
end
|
||||
|
||||
|
||||
def refresh
|
||||
data = connection.get_record( reference, 'VM' )
|
||||
data = service.get_record( reference, 'VM' )
|
||||
merge_attributes( data )
|
||||
true
|
||||
end
|
||||
|
||||
def vifs
|
||||
__vifs.collect { |vif| connection.vifs.get vif }
|
||||
__vifs.collect { |vif| service.vifs.get vif }
|
||||
end
|
||||
|
||||
# associations
|
||||
|
@ -102,44 +102,44 @@ module Fog
|
|||
end
|
||||
|
||||
def resident_on
|
||||
connection.hosts.get __resident_on
|
||||
service.hosts.get __resident_on
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# This is not always present in XenServer VMs
|
||||
# Guest needs XenTools installed to report this AFAIK
|
||||
def guest_metrics
|
||||
return nil unless __guest_metrics
|
||||
rec = connection.get_record( __guest_metrics, 'VM_guest_metrics' )
|
||||
rec = service.get_record( __guest_metrics, 'VM_guest_metrics' )
|
||||
Fog::Compute::XenServer::GuestMetrics.new(rec)
|
||||
end
|
||||
|
||||
def tools_installed?
|
||||
!guest_metrics.nil?
|
||||
end
|
||||
|
||||
|
||||
def home_hypervisor
|
||||
connection.hosts.first
|
||||
service.hosts.first
|
||||
end
|
||||
|
||||
|
||||
def mac_address
|
||||
networks.first.MAC
|
||||
end
|
||||
|
||||
|
||||
def running?
|
||||
reload
|
||||
power_state == "Running"
|
||||
end
|
||||
|
||||
|
||||
def halted?
|
||||
reload
|
||||
power_state == "Halted"
|
||||
end
|
||||
|
||||
|
||||
# operations
|
||||
def start
|
||||
return false if running?
|
||||
connection.start_server( reference )
|
||||
service.start_server( reference )
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -149,25 +149,25 @@ module Fog
|
|||
if params[:auto_start].nil?
|
||||
auto_start = true
|
||||
else
|
||||
auto_start = params[:auto_start]
|
||||
auto_start = params[:auto_start]
|
||||
end
|
||||
if template_name
|
||||
attr = connection.get_record(
|
||||
connection.create_server( name, template_name, nets, :auto_start => auto_start),
|
||||
attr = service.get_record(
|
||||
service.create_server( name, template_name, nets, :auto_start => auto_start),
|
||||
'VM'
|
||||
)
|
||||
else
|
||||
attr = connection.get_record(
|
||||
connection.create_server_raw(attributes),
|
||||
attr = service.get_record(
|
||||
service.create_server_raw(attributes),
|
||||
'VM'
|
||||
)
|
||||
end
|
||||
merge_attributes attr
|
||||
merge_attributes attr
|
||||
true
|
||||
end
|
||||
|
||||
def reboot(stype = 'clean')
|
||||
connection.reboot_server(reference, stype)
|
||||
service.reboot_server(reference, stype)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -181,7 +181,7 @@ module Fog
|
|||
|
||||
def stop(stype = 'clean')
|
||||
return false if !running?
|
||||
connection.shutdown_server( reference, stype )
|
||||
service.shutdown_server( reference, stype )
|
||||
wait_for { power_state == 'Halted' }
|
||||
true
|
||||
end
|
||||
|
@ -195,12 +195,12 @@ module Fog
|
|||
end
|
||||
|
||||
def provision
|
||||
connection.provision_server reference
|
||||
service.provision_server reference
|
||||
end
|
||||
|
||||
# def snapshot
|
||||
# requires :reference, :name_label
|
||||
# data = connection.snapshot_server(@reference, @name_label)
|
||||
# data = service.snapshot_server(@reference, @name_label)
|
||||
# merge_attributes(data.body)
|
||||
# true
|
||||
# end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Fog
|
|||
model Fog::Compute::XenServer::Server
|
||||
|
||||
def templates
|
||||
data = connection.get_records 'VM'
|
||||
data = service.get_records 'VM'
|
||||
data.delete_if do |vm|
|
||||
!vm[:is_a_template]
|
||||
end
|
||||
|
@ -18,15 +18,15 @@ module Fog
|
|||
end
|
||||
|
||||
def custom_templates
|
||||
data = connection.get_records 'VM'
|
||||
data = service.get_records 'VM'
|
||||
data.delete_if do |vm|
|
||||
!vm[:is_a_template] or !vm[:other_config]['default_template'].nil?
|
||||
!vm[:is_a_template] or !vm[:other_config]['default_template'].nil?
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
|
||||
def builtin_templates
|
||||
data = connection.get_records 'VM'
|
||||
data = service.get_records 'VM'
|
||||
data.delete_if do |vm|
|
||||
!vm[:is_a_template] or vm[:other_config]['default_template'].nil?
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ module Fog
|
|||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'VM'
|
||||
data = service.get_records 'VM'
|
||||
# Exclude templates
|
||||
data.delete_if { |vm| vm[:is_control_domain] or vm[:is_a_template] }
|
||||
data.delete_if { |vm| vm[:is_a_snapshot] and !options[:include_snapshots] }
|
||||
|
@ -44,12 +44,12 @@ module Fog
|
|||
end
|
||||
|
||||
def get_by_name( name )
|
||||
ref = connection.get_vm_by_name( name )
|
||||
ref = service.get_vm_by_name( name )
|
||||
get ref
|
||||
end
|
||||
|
||||
def get( vm_ref )
|
||||
if vm_ref && vm = connection.get_record( vm_ref, 'VM' )
|
||||
if vm_ref && vm = service.get_record( vm_ref, 'VM' )
|
||||
new(vm)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
|
@ -10,14 +10,14 @@ module Fog
|
|||
model Fog::Compute::XenServer::StorageRepository
|
||||
|
||||
def all
|
||||
data = connection.get_records 'SR'
|
||||
data = service.get_records 'SR'
|
||||
#data.delete_if {|sr| sr[:shared].eql?(false)}
|
||||
#data.delete_if {|sr| sr[:content_type].eql?('iso')}
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( sr_ref )
|
||||
if sr_ref && sr = connection.get_record( sr_ref, 'SR' )
|
||||
if sr_ref && sr = service.get_record( sr_ref, 'SR' )
|
||||
new(sr)
|
||||
else
|
||||
nil
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class StorageRepository < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=SR
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :name, :aliases => :name_label
|
||||
attribute :description, :aliases => :name_description
|
||||
attribute :uuid
|
||||
|
@ -26,17 +26,17 @@ module Fog
|
|||
attribute :physical_utilisation
|
||||
attribute :sm_config
|
||||
attribute :virtual_allocation
|
||||
|
||||
|
||||
def vdis
|
||||
__vdis.collect { |vdi| connection.vdis.get vdi }
|
||||
__vdis.collect { |vdi| service.vdis.get vdi }
|
||||
end
|
||||
|
||||
|
||||
def pbds
|
||||
__pbds.collect { |pbd| connection.pbds.get pbd }
|
||||
__pbds.collect { |pbd| service.pbds.get pbd }
|
||||
end
|
||||
|
||||
def scan
|
||||
connection.scan_sr reference
|
||||
service.scan_sr reference
|
||||
reload
|
||||
end
|
||||
|
||||
|
@ -84,7 +84,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class VBD < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VBD
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :currently_attached
|
||||
attribute :allowed_operations
|
||||
|
@ -23,7 +23,7 @@ module Fog
|
|||
attribute :userdevice
|
||||
attribute :empty
|
||||
attribute :type
|
||||
attribute :mode
|
||||
attribute :mode
|
||||
attribute :storage_lock
|
||||
attribute :runtime_properties
|
||||
attribute :unpluggable
|
||||
|
@ -38,36 +38,36 @@ module Fog
|
|||
# May return nil
|
||||
#
|
||||
def vdi
|
||||
connection.vdis.get __vdi
|
||||
service.vdis.get __vdi
|
||||
end
|
||||
|
||||
#
|
||||
# TODO: May it return nil?
|
||||
#
|
||||
def server
|
||||
connection.servers.get __vm
|
||||
service.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
|
||||
ref = service.create_vbd attributes[:server], attributes[:vdi], attributes
|
||||
merge_attributes service.vbds.get(ref).attributes
|
||||
end
|
||||
|
||||
def unplug
|
||||
connection.unplug_vbd reference
|
||||
service.unplug_vbd reference
|
||||
end
|
||||
|
||||
def unplug_force
|
||||
connection.unplug_force_vbd reference
|
||||
service.unplug_force_vbd reference
|
||||
end
|
||||
|
||||
|
||||
def eject
|
||||
connection.eject_vbd reference
|
||||
service.eject_vbd reference
|
||||
end
|
||||
|
||||
|
||||
def insert(vdi)
|
||||
connection.insert_vbd reference, vdi.reference
|
||||
service.insert_vbd reference, vdi.reference
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -79,12 +79,12 @@ module Fog
|
|||
#
|
||||
def metrics
|
||||
return nil unless currently_attached
|
||||
rec = connection.get_record( __metrics, 'VBD_metrics' )
|
||||
rec = service.get_record( __metrics, 'VBD_metrics' )
|
||||
Fog::Compute::XenServer::VbdMetrics.new(rec)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,18 +8,18 @@ module Fog
|
|||
class Vbds < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::VBD
|
||||
|
||||
|
||||
def initialize(attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'VBD'
|
||||
data = service.get_records 'VBD'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( vbd_ref )
|
||||
if vbd_ref && vbd = connection.get_record( vbd_ref, 'VBD' )
|
||||
if vbd_ref && vbd = service.get_record( vbd_ref, 'VBD' )
|
||||
new(vbd)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class VDI < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VDI
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :uuid
|
||||
attribute :is_a_snapshot
|
||||
attribute :name, :aliases => :name_label
|
||||
|
@ -34,10 +34,10 @@ module Fog
|
|||
attribute :on_boot
|
||||
attribute :sm_config
|
||||
attribute :snapshot_time
|
||||
attribute :__snapshots, :aliases => :snapshots
|
||||
attribute :__snapshots, :aliases => :snapshots
|
||||
attribute :__snapshot_of, :aliases => :snapshot_of
|
||||
attribute :xenstore_data
|
||||
|
||||
|
||||
#
|
||||
# Default VDI type is system
|
||||
# Default size 8GB
|
||||
|
@ -50,45 +50,45 @@ module Fog
|
|||
self.read_only ||= false unless attributes[:read_only]
|
||||
self.sharable ||= false unless attributes[:sharable]
|
||||
self.other_config ||= {} unless attributes[:other_config]
|
||||
super
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def set_attribute(name, *val)
|
||||
data = connection.set_attribute( 'VDI', reference, name, *val )
|
||||
data = service.set_attribute( 'VDI', reference, name, *val )
|
||||
end
|
||||
|
||||
def snapshot_of
|
||||
connection.vdis.get __sr
|
||||
service.vdis.get __sr
|
||||
end
|
||||
|
||||
def parent
|
||||
connection.vdis.get __parent
|
||||
service.vdis.get __parent
|
||||
end
|
||||
|
||||
def snapshots
|
||||
__snapshots.collect do |ref|
|
||||
connection.vdis.get ref
|
||||
service.vdis.get ref
|
||||
end
|
||||
end
|
||||
|
||||
def vbds
|
||||
__vbds.collect do |ref|
|
||||
connection.vbds.get ref
|
||||
service.vbds.get ref
|
||||
end
|
||||
end
|
||||
|
||||
def save
|
||||
requires :name, :storage_repository
|
||||
ref = connection.create_vdi attributes
|
||||
merge_attributes connection.vdis.get(ref).attributes
|
||||
ref = service.create_vdi attributes
|
||||
merge_attributes service.vdis.get(ref).attributes
|
||||
end
|
||||
|
||||
def destroy
|
||||
connection.destroy_vdi reference
|
||||
service.destroy_vdi reference
|
||||
end
|
||||
|
||||
def storage_repository
|
||||
connection.storage_repositories.get __sr
|
||||
service.storage_repositories.get __sr
|
||||
end
|
||||
|
||||
def sr
|
||||
|
@ -96,7 +96,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,14 +8,14 @@ module Fog
|
|||
class Vdis < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::VDI
|
||||
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'VDI'
|
||||
data = service.get_records 'VDI'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( vdi_ref )
|
||||
if vdi_ref && vdi = connection.get_record( vdi_ref, 'VDI' )
|
||||
if vdi_ref && vdi = service.get_record( vdi_ref, 'VDI' )
|
||||
new(vdi)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
|
@ -3,13 +3,13 @@ require 'fog/core/model'
|
|||
module Fog
|
||||
module Compute
|
||||
class XenServer
|
||||
|
||||
|
||||
class VIF < Fog::Model
|
||||
# API Reference here:
|
||||
# http://docs.vmd.citrix.com/XenServer/5.6.0/1.0/en_gb/api/?c=VIF
|
||||
|
||||
|
||||
identity :reference
|
||||
|
||||
|
||||
attribute :mac, :aliases => :MAC
|
||||
attribute :uuid
|
||||
attribute :allowed_operations
|
||||
|
@ -22,30 +22,30 @@ module Fog
|
|||
attribute :status_code
|
||||
attribute :status_detail
|
||||
attribute :__vm, :aliases => :VM
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
connection.destroy_vif reference
|
||||
service.destroy_vif reference
|
||||
end
|
||||
|
||||
def network
|
||||
connection.networks.get __network
|
||||
service.networks.get __network
|
||||
end
|
||||
|
||||
def server
|
||||
connection.servers.get __vm
|
||||
service.servers.get __vm
|
||||
end
|
||||
|
||||
def save
|
||||
requires :server
|
||||
raise ArgumentError.new('network is required for this operation') \
|
||||
unless attributes[:__network]
|
||||
ref = connection.create_vif attributes[:server], attributes[:__network]
|
||||
merge_attributes connection.vifs.get(ref).attributes
|
||||
ref = service.create_vif attributes[:server], attributes[:__network]
|
||||
merge_attributes service.vifs.get(ref).attributes
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,14 +8,14 @@ module Fog
|
|||
class Vifs < Fog::Collection
|
||||
|
||||
model Fog::Compute::XenServer::VIF
|
||||
|
||||
|
||||
def all(options = {})
|
||||
data = connection.get_records 'VIF'
|
||||
data = service.get_records 'VIF'
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get( ref )
|
||||
if ref && obj = connection.get_record( ref, 'VIF' )
|
||||
if ref && obj = service.get_record( ref, 'VIF' )
|
||||
new(obj)
|
||||
end
|
||||
rescue Fog::XenServer::NotFound
|
||||
|
|
Loading…
Add table
Reference in a new issue