diff --git a/lib/fog/libvirt/compute.rb b/lib/fog/libvirt/compute.rb index aa9fc7440..2557f1f82 100644 --- a/lib/fog/libvirt/compute.rb +++ b/lib/fog/libvirt/compute.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/interfaces.rb b/lib/fog/libvirt/models/compute/interfaces.rb index 6d765400c..74c9f939a 100644 --- a/lib/fog/libvirt/models/compute/interfaces.rb +++ b/lib/fog/libvirt/models/compute/interfaces.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/pool.rb b/lib/fog/libvirt/models/compute/pool.rb index 5a8726a72..2331aa4d5 100644 --- a/lib/fog/libvirt/models/compute/pool.rb +++ b/lib/fog/libvirt/models/compute/pool.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/pools.rb b/lib/fog/libvirt/models/compute/pools.rb index d33d31443..feaefb223 100644 --- a/lib/fog/libvirt/models/compute/pools.rb +++ b/lib/fog/libvirt/models/compute/pools.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/server.rb b/lib/fog/libvirt/models/compute/server.rb index 565ed1e9b..c6928e8a6 100644 --- a/lib/fog/libvirt/models/compute/server.rb +++ b/lib/fog/libvirt/models/compute/server.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/servers.rb b/lib/fog/libvirt/models/compute/servers.rb index 9a424f2f1..14e3bffa8 100644 --- a/lib/fog/libvirt/models/compute/servers.rb +++ b/lib/fog/libvirt/models/compute/servers.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/volume.rb b/lib/fog/libvirt/models/compute/volume.rb index 1df99aaff..930e8a3eb 100644 --- a/lib/fog/libvirt/models/compute/volume.rb +++ b/lib/fog/libvirt/models/compute/volume.rb @@ -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 diff --git a/lib/fog/libvirt/models/compute/volumes.rb b/lib/fog/libvirt/models/compute/volumes.rb index 334150ad3..18a2b3ca3 100644 --- a/lib/fog/libvirt/models/compute/volumes.rb +++ b/lib/fog/libvirt/models/compute/volumes.rb @@ -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