1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[Libvirt] renamed 'raw' connection to raw in the Fog Connection

Because the initial provider was copied from the virtualbox example we ended up with a notation
connection.connection for the raw provider

The function of the raw are injected on the connection object. Still in analogy with the raw
for server , volume, ... it makes sense to rename connection.connection to connection.raw

Also all calls to the raw connection are now explicit
This commit is contained in:
Patrick Debois 2011-09-13 07:34:18 +02:00
parent 3d7adcf7ca
commit 4740174f12
8 changed files with 36 additions and 36 deletions

View file

@ -33,7 +33,7 @@ module Fog
class Real
attr_reader :connection
attr_reader :raw
attr_reader :uri
attr_reader :ip_command
@ -47,7 +47,7 @@ module Fog
begin
if options[:libvirt_username] and options[:libvirt_password]
@connection = ::Libvirt::open_auth(@uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred|
@raw = ::Libvirt::open_auth(@uri.uri, [::Libvirt::CRED_AUTHNAME, ::Libvirt::CRED_PASSPHRASE]) do |cred|
if cred['type'] == ::Libvirt::CRED_AUTHNAME
res = options[:libvirt_username]
elsif cred["type"] == ::Libvirt::CRED_PASSPHRASE
@ -56,7 +56,7 @@ module Fog
end
end
else
@connection = ::Libvirt::open(@uri.uri)
@raw = ::Libvirt::open(@uri.uri)
end
rescue ::Libvirt::ConnectionError
@ -91,8 +91,8 @@ module Fog
# hack to provide 'requests'
def method_missing(method_sym, *arguments, &block)
if @connection.respond_to?(method_sym)
@connection.send(method_sym, *arguments)
if @raw.respond_to?(method_sym)
@raw.send(method_sym, *arguments)
else
super
end

View file

@ -12,12 +12,12 @@ module Fog
def all(filter=nil)
data=[]
if filter.nil?
connection.list_interfaces.each do |ifname|
interface=connection.lookup_interface_by_name(ifname)
connection.raw.list_interfaces.each do |ifname|
interface=connection.raw.lookup_interface_by_name(ifname)
data << { :raw => interface }
end
connection.list_defined_interfaces.each do |ifname|
interface=connection.lookup_interface_by_name(ifname)
connection.raw.list_defined_interfaces.each do |ifname|
interface=connection.raw.lookup_interface_by_name(ifname)
data << { :raw => interface }
end
@ -42,14 +42,14 @@ module Fog
#private # Making these private, screws up realod
# Retrieve the interface by name
def get_by_name(name)
interface=connection.lookup_interface_by_name(name)
interface=connection.raw.lookup_interface_by_name(name)
return interface
# new(:raw => interface)
end
# Retrieve the interface by name
def get_by_mac(mac)
interface=connection.lookup_interface_by_mac(mac)
interface=connection.raw.lookup_interface_by_mac(mac)
return interface
# new(:raw => interface)
end

View file

@ -26,9 +26,9 @@ module Fog
unless xml.nil?
pool=nil
if self.create_persistent
pool=connection.connection.define_storage_pool_xml(xml)
pool=connection.raw.define_storage_pool_xml(xml)
else
pool=connection.connection.create_storage_pool_xml(xml)
pool=connection.raw.create_storage_pool_xml(xml)
end
self.raw=pool
true

View file

@ -12,13 +12,13 @@ module Fog
def all(filter=nil)
data=[]
if filter.nil?
connection.list_storage_pools.each do |poolname|
pool=connection.lookup_storage_pool_by_name(poolname)
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
data << { :raw => pool }
end
connection.list_defined_storage_pools.each do |poolname|
connection.raw.list_defined_storage_pools.each do |poolname|
data << {
:raw => connection.lookup_storage_pool_by_name(poolname)
:raw => connection.raw.lookup_storage_pool_by_name(poolname)
}
end
else
@ -42,13 +42,13 @@ module Fog
#private # Making these private, screws up realod
# Retrieve the pool by uuid
def get_by_uuid(uuid)
pool=connection.lookup_storage_pool_by_uuid(uuid)
pool=connection.raw.lookup_storage_pool_by_uuid(uuid)
return pool
end
# Retrieve the pool by name
def get_by_name(name)
pool=connection.lookup_storage_pool_by_name(name)
pool=connection.raw.lookup_storage_pool_by_name(name)
return pool
# new(:raw => pool)
end

View file

@ -94,9 +94,9 @@ module Fog
if !xml.nil?
domain=nil
if self.persistent
domain=connection.define_domain_xml(xml)
domain=connection.raw.define_domain_xml(xml)
else
domain=connection.create_domain_xml(xml)
domain=connection.raw.create_domain_xml(xml)
end
self.raw=domain
end

View file

@ -17,13 +17,13 @@ module Fog
unless filter.has_key?(:name) || filter.has_key?(:uuid)
if include_defined
connection.list_defined_domains.map do |domain|
data << { :raw => connection.lookup_domain_by_name(domain) }
connection.raw.list_defined_domains.map do |domain|
data << { :raw => connection.raw.lookup_domain_by_name(domain) }
end
end
if include_active
connection.list_domains.each do |domain|
data << { :raw => connection.lookup_domain_by_id(domain) }
connection.raw.list_domains.each do |domain|
data << { :raw => connection.raw.lookup_domain_by_id(domain) }
end
end
else
@ -60,14 +60,14 @@ module Fog
# Retrieve the server by uuid
def get_by_uuid(uuid)
server=connection.lookup_domain_by_uuid(uuid)
server=connection.raw.lookup_domain_by_uuid(uuid)
return server
# new(:raw => machine)
end
# Retrieve the server by name
def get_by_name(name)
server=connection.lookup_domain_by_name(name)
server=connection.raw.lookup_domain_by_name(name)
return server
# new(:raw => machine)
end

View file

@ -70,7 +70,7 @@ module Fog
begin
volume=nil
pool=connection.lookup_storage_pool_by_name(pool_name)
pool=connection.raw.lookup_storage_pool_by_name(pool_name)
volume=pool.create_volume_xml(xml)
self.raw=volume
true

View file

@ -12,8 +12,8 @@ module Fog
def all(filter=nil)
data=[]
if filter.nil?
connection.list_storage_pools.each do |poolname|
pool=connection.lookup_storage_pool_by_name(poolname)
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
pool.list_volumes.each do |volumename|
data << { :raw => pool.lookup_volume_by_name(volumename) }
end
@ -42,8 +42,8 @@ module Fog
# Retrieve the volume by name
def get_by_name(name)
connection.list_storage_pools.each do |poolname|
pool=connection.lookup_storage_pool_by_name(poolname)
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
volume=pool.lookup_volume_by_name(name)
unless volume.nil?
return volume
@ -55,8 +55,8 @@ module Fog
# Retrieve the volume by key
def get_by_key(key)
connection.list_storage_pools.each do |poolname|
pool=connection.lookup_storage_pool_by_name(poolname)
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
volume=pool.lookup_volume_by_key(key)
unless volume.nil?
return volume
@ -68,8 +68,8 @@ module Fog
# Retrieve the volume by key
def get_by_path(path)
connection.list_storage_pools.each do |poolname|
pool=connection.lookup_storage_pool_by_name(poolname)
connection.raw.list_storage_pools.each do |poolname|
pool=connection.raw.lookup_storage_pool_by_name(poolname)
volume=pool.lookup_volume_by_key(path)
unless volume.nil?
return volume