mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
- Added concept of nodes (host of domains = node)
- Renamed the shuttingdown to shutting-down mode - fixed the Gem warning on using Gem.find_by_name instead of Gem::Specification
This commit is contained in:
parent
bc08ae712c
commit
12ec8bb178
5 changed files with 96 additions and 2 deletions
|
@ -24,7 +24,14 @@ module Libvirt # deviates from other bin stuff to accomodate gem
|
||||||
end
|
end
|
||||||
|
|
||||||
def available?
|
def available?
|
||||||
availability = !Gem.source_index.find_name('ruby-libvirt').empty?
|
begin
|
||||||
|
availability=true unless Gem::Specification::find_by_name("ruby-libvirt").nil?
|
||||||
|
rescue Gem::LoadError
|
||||||
|
availability=false
|
||||||
|
rescue
|
||||||
|
availability_gem=Gem.available?("ruby-libvirt")
|
||||||
|
end
|
||||||
|
|
||||||
if availability
|
if availability
|
||||||
for service in services
|
for service in services
|
||||||
for collection in self.class_for(service).collections
|
for collection in self.class_for(service).collections
|
||||||
|
|
|
@ -17,6 +17,8 @@ module Fog
|
||||||
collection :volumes
|
collection :volumes
|
||||||
model :pool
|
model :pool
|
||||||
collection :pools
|
collection :pools
|
||||||
|
model :node
|
||||||
|
collection :nodes
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
|
|
||||||
|
|
45
lib/fog/compute/models/libvirt/node.rb
Normal file
45
lib/fog/compute/models/libvirt/node.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
require 'fog/core/model'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Libvirt
|
||||||
|
|
||||||
|
class Node < Fog::Model
|
||||||
|
|
||||||
|
identity :uri
|
||||||
|
|
||||||
|
attribute :model
|
||||||
|
attribute :memory
|
||||||
|
attribute :cpus
|
||||||
|
attribute :mhz
|
||||||
|
attribute :nodes
|
||||||
|
attribute :sockets
|
||||||
|
attribute :cores
|
||||||
|
attribute :threads
|
||||||
|
|
||||||
|
attribute :type
|
||||||
|
attribute :version
|
||||||
|
attribute :uri
|
||||||
|
attribute :node_free_memory
|
||||||
|
attribute :max_vcpus
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def raw
|
||||||
|
@raw
|
||||||
|
end
|
||||||
|
|
||||||
|
def raw=(new_raw)
|
||||||
|
@raw = new_raw
|
||||||
|
|
||||||
|
raw_attributes = new_raw
|
||||||
|
|
||||||
|
merge_attributes(raw_attributes)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
40
lib/fog/compute/models/libvirt/nodes.rb
Normal file
40
lib/fog/compute/models/libvirt/nodes.rb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
require 'fog/core/collection'
|
||||||
|
require 'fog/compute/models/libvirt/node'
|
||||||
|
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class Libvirt
|
||||||
|
|
||||||
|
class Nodes < Fog::Collection
|
||||||
|
|
||||||
|
model Fog::Compute::Libvirt::Node
|
||||||
|
|
||||||
|
def all(filter=nil)
|
||||||
|
data=[]
|
||||||
|
node_info=Hash.new
|
||||||
|
[:model, :memory, :cpus, :mhz, :nodes, :sockets, :cores, :threads].each do |param|
|
||||||
|
begin
|
||||||
|
node_info[param]=connection.node_get_info.send(param)
|
||||||
|
rescue ::Libvirt::RetrieveError
|
||||||
|
node_info[param]=nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
[:type, :version, :node_free_memory, :max_vcpus].each do |param|
|
||||||
|
begin
|
||||||
|
node_info[param] = connection.send(param)
|
||||||
|
rescue ::Libvirt::RetrieveError
|
||||||
|
node_info[param]=nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
node_info[:uri]=connection.connection.uri
|
||||||
|
data << { :raw => node_info }
|
||||||
|
require 'pp'
|
||||||
|
pp node_info
|
||||||
|
load(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end #class
|
||||||
|
end #Class
|
||||||
|
end #module
|
||||||
|
end #Module
|
|
@ -255,7 +255,7 @@ module Fog
|
||||||
when 0 then "nostate"
|
when 0 then "nostate"
|
||||||
when 1 then "running"
|
when 1 then "running"
|
||||||
when 2 then "paused"
|
when 2 then "paused"
|
||||||
when 3 then "shuttingdown"
|
when 3 then "shutting-down"
|
||||||
when 4 then "shutoff"
|
when 4 then "shutoff"
|
||||||
when 5 then "crashed"
|
when 5 then "crashed"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue