Skip to content

Commit

Permalink
Merge 35ba637 into 24cdf4d
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Jul 7, 2014
2 parents 24cdf4d + 35ba637 commit ea25aae
Show file tree
Hide file tree
Showing 74 changed files with 605 additions and 528 deletions.
8 changes: 8 additions & 0 deletions lib/fog/compute/xen_server.rb
Expand Up @@ -69,9 +69,17 @@ class XenServer < Fog::Service
collection :pbds
model :pbd
model :guest_metrics
collection :guests_metrics
model :server_metrics
collection :servers_metrics
model :vbd_metrics
collection :vbds_metrics
model :vif_metrics
collection :vifs_metrics
model :host_metrics
collection :hosts_metrics
model :host_cpu
collection :host_cpus
model :vlan
collection :vlans
model :console
Expand Down
6 changes: 6 additions & 0 deletions lib/fog/compute/xen_server/models.rb
Expand Up @@ -17,12 +17,15 @@ module Models
autoload :GuestMetrics, 'fog/compute/xen_server/models/guest_metrics'
autoload :Host, 'fog/compute/xen_server/models/host'
autoload :HostCpu, 'fog/compute/xen_server/models/host_cpu'
autoload :HostCpus, 'fog/compute/xen_server/models/host_cpus'
autoload :HostCrashDump, 'fog/compute/xen_server/models/host_crash_dump'
autoload :HostCrashDumps, 'fog/compute/xen_server/models/host_crash_dumps'
autoload :HostMetrics, 'fog/compute/xen_server/models/host_metrics'
autoload :HostPatch, 'fog/compute/xen_server/models/host_patch'
autoload :HostPatchs, 'fog/compute/xen_server/models/host_patchs'
autoload :Hosts, 'fog/compute/xen_server/models/hosts'
autoload :HostsMetrics, 'fog/compute/xen_server/models/hosts_metrics'
autoload :Model, 'fog/compute/xen_server/models/model'
autoload :Network, 'fog/compute/xen_server/models/network'
autoload :Networks, 'fog/compute/xen_server/models/networks'
autoload :Pbd, 'fog/compute/xen_server/models/pbd'
Expand Down Expand Up @@ -54,10 +57,13 @@ module Models
autoload :Vbd, 'fog/compute/xen_server/models/vbd'
autoload :VbdMetrics, 'fog/compute/xen_server/models/vbd_metrics'
autoload :Vbds, 'fog/compute/xen_server/models/vbds'
autoload :VbdsMetrics, 'fog/compute/xen_server/models/vbds_metrics'
autoload :Vdi, 'fog/compute/xen_server/models/vdi'
autoload :Vdis, 'fog/compute/xen_server/models/vdis'
autoload :Vif, 'fog/compute/xen_server/models/vif'
autoload :VifMetrics, 'fog/compute/xen_server/models/vif_metrics'
autoload :Vifs, 'fog/compute/xen_server/models/vifs'
autoload :VifsMetrics, 'fog/compute/xen_server/models/vifs_metrics'
autoload :Vlan, 'fog/compute/xen_server/models/vlan'
autoload :Vlans, 'fog/compute/xen_server/models/vlans'
autoload :Vmpp, 'fog/compute/xen_server/models/vmpp'
Expand Down
2 changes: 0 additions & 2 deletions lib/fog/compute/xen_server/models/blob.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand Down
9 changes: 4 additions & 5 deletions lib/fog/compute/xen_server/models/bond.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -11,13 +9,14 @@ class Bond < Fog::Model
identity :reference

attribute :links_up
attribute :__master, :aliases => :master
attribute :mode
attribute :other_config
attribute :__primary_slave, :aliases => :primary_slave
attribute :properties
attribute :__slaves, :aliases => :slaves
attribute :uuid

has_one :master, :pifs
has_one :primary_slave, :pifs
has_many :slaves, :pifs
end
end
end
Expand Down
12 changes: 1 addition & 11 deletions lib/fog/compute/xen_server/models/console.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -14,16 +12,8 @@ class Console < Fog::Model
attribute :other_config
attribute :protocol
attribute :uuid
attribute :__vm, :aliases => :VM

def vm
begin
vm = service.servers.get __vm
rescue Fog::XenServer::RequestFailed => e
vm = nil
end
vm
end
has_one :vm, :servers, :aliases => :VM
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions lib/fog/compute/xen_server/models/crash_dump.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -12,8 +10,9 @@ class CrashDump < Fog::Model

attribute :other_config
attribute :uuid
attribute :__vdi, :aliases => :VDI
attribute :__vm, :aliases => :VM

has_one :vdi, :vdis, :aliases => :VDI
has_one :vm, :servers, :aliases => :VM
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/fog/compute/xen_server/models/dr_task.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -10,8 +8,9 @@ class DrTask < Fog::Model

identity :reference

attribute :__introduced_srs, :aliases => :introduced_SRs
attribute :uuid

has_many :introduced_srs, :storage_repositories, :aliases => :introduced_SRs
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions lib/fog/compute/xen_server/models/gpu_group.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -14,9 +12,10 @@ class GpuGroup < Fog::Model
attribute :gpu_types, :aliases => :GPU_types
attribute :name, :aliases => :name_label
attribute :other_config
attribute :__pgpus, :aliases => :PGPUs
attribute :uuid
attribute :__vgpus, :aliases => :VGPUs

has_many :pgpus, :pgpus, :aliases => :PGPUs
has_many :vgpus, :vgpus, :aliases => :VGPUs
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/fog/compute/xen_server/models/guest_metrics.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand Down
26 changes: 26 additions & 0 deletions lib/fog/compute/xen_server/models/guests_metrics.rb
@@ -0,0 +1,26 @@
require 'fog/core/collection'

module Fog
module Compute
class XenServer
module Models
class GuestMetrics < Fog::Collection
model Fog::Compute::XenServer::Models::GuestMetrics

def all(options={})
data = service.get_records 'VM_guest_metrics'
load(data)
end

def get( guest_metrics_ref )
if guest_metrics_ref && guest_metrics = service.get_record( guest_metrics_ref, 'VM_guest_metrics' )
new(guest_metrics)
else
nil
end
end
end
end
end
end
end
53 changes: 11 additions & 42 deletions lib/fog/compute/xen_server/models/host.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -22,8 +20,6 @@ class Host < Fog::Model
attribute :chipset_info
attribute :cpu_configuration
attribute :cpu_info
attribute :__crashdumps, :aliases => :crashdumps
attribute :__crash_dump_sr, :aliases => :crash_dump_sr
attribute :current_operations
attribute :description, :aliases => :name_description
attribute :edition
Expand All @@ -35,61 +31,34 @@ class Host < Fog::Model
attribute :ha_network_peers
attribute :ha_statefiles
attribute :hostname
attribute :__host_cpus, :aliases => :host_CPUs
attribute :license_params
attribute :license_server
attribute :__local_cache_sr, :aliases => :local_cache_sr
attribute :logging
attribute :memory_overhead
attribute :__metrics, :aliases => :metrics
attribute :name, :aliases => :name_label
attribute :other_config
attribute :patches
attribute :__pbds, :aliases => :PBDs
attribute :__pcis, :aliases => :PCIs
attribute :__pgpus, :aliases => :PGPUs
attribute :__pifs, :aliases => :PIFs
attribute :power_on_config
attribute :power_on_mode
attribute :__resident_vms, :aliases => :resident_VMs
attribute :sched_policy
attribute :software_version
attribute :supported_bootloaders
attribute :suspend_image_sr
attribute :tags
attribute :uuid

def pifs
__pifs.collect { |pif| service.pifs.get pif }
end

def pbds
__pbds.collect { |pbd| service.pbds.get pbd }
end

def resident_servers
__resident_vms.collect { |ref| service.servers.get ref }
end
has_many :crashdumps, :crash_dumps
has_one :crash_dump_sr, :storage_repositories
has_many :host_cpus, :host_cpus, :aliases => :host_CPUs
has_one :local_cache_sr,:storage_repositories
has_one :metrics, :hosts_metrics
has_many :pbds, :pbds, :aliases => :PBDs
has_many :pcis, :pcis, :aliases => :PCIs
has_many :pgpus, :pgpus, :aliases => :PGPUs
has_many :pifs, :pifs, :aliases => :PIFs
has_many :resident_vms, :servers, :aliases => :resident_VMs

def resident_vms
resident_servers
end

def host_cpus
cpus = []
(__host_cpus || []).each do |ref|
cpu_ref = service.get_record(ref, 'host_cpu' )
cpu_ref[:service] = service
cpus << Fog::Compute::XenServer::HostCpu.new(cpu_ref)
end
cpus
end

def metrics
return nil unless __metrics
rec = service.get_record(__metrics, 'host_metrics' )
Fog::Compute::XenServer::HostMetrics.new(rec)
end
alias_method :resident_servers, :resident_vms

#
# Reboot the host disabling it first unless auto_disable is
Expand Down
7 changes: 1 addition & 6 deletions lib/fog/compute/xen_server/models/host_cpu.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -13,7 +11,6 @@ class HostCpu < Fog::Model
attribute :family
attribute :features
attribute :flags
attribute :__host, :aliases => :host
attribute :model
attribute :model_name, :aliases => :modelname
attribute :number
Expand All @@ -24,9 +21,7 @@ class HostCpu < Fog::Model
attribute :uuid
attribute :vendor

def host
service.hosts.get __host
end
has_one :host, :hosts
end
end
end
Expand Down
26 changes: 26 additions & 0 deletions lib/fog/compute/xen_server/models/host_cpus.rb
@@ -0,0 +1,26 @@
require 'fog/core/collection'

module Fog
module Compute
class XenServer
module Models
class HostCpus < Fog::Collection
model Fog::Compute::XenServer::Models::HostCpu

def all(options={})
data = service.get_records 'host_cpu'
load(data)
end

def get( host_cpu_ref )
if host_cpu_ref && host_cpu = service.get_record( host_cpu_ref, 'host_cpu' )
new(host_cpu)
else
nil
end
end
end
end
end
end
end
5 changes: 2 additions & 3 deletions lib/fog/compute/xen_server/models/host_crash_dump.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -10,11 +8,12 @@ class HostCrashDump < Fog::Model

identity :reference

attribute :__host, :aliases => :host
attribute :other_config
attribute :size
attribute :timestamp
attribute :uuid

has_one :host, :hosts
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/fog/compute/xen_server/models/host_metrics.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand Down
7 changes: 3 additions & 4 deletions lib/fog/compute/xen_server/models/host_patch.rb
@@ -1,5 +1,3 @@
require 'fog/core/model'

module Fog
module Compute
class XenServer
Expand All @@ -12,14 +10,15 @@ class HostPatch < Fog::Model

attribute :applied
attribute :description, :aliases => :name_description
attribute :__host, :aliases => :host
attribute :name, :aliases => :name_label
attribute :other_config
attribute :__pool_patch, :aliases => :pool_patch
attribute :size
attribute :timestamp_applied
attribute :uuid
attribute :version

has_one :host, :hosts
has_one :pool_patch, :pool_patchs
end
end
end
Expand Down

0 comments on commit ea25aae

Please sign in to comment.