[Ovirt-devel] [PATCH client 01/11] Indent with 2 spaces

David Lutterkort lutter at redhat.com
Mon Jan 26 21:20:31 UTC 2009


Only whitespace changes, no functional changes
---
 examples/script.rb |   50 ++++++++++----------
 lib/ovirt.rb       |  126 ++++++++++++++++++++++++++--------------------------
 2 files changed, 88 insertions(+), 88 deletions(-)

diff --git a/examples/script.rb b/examples/script.rb
index 1485535..f6f6839 100755
--- a/examples/script.rb
+++ b/examples/script.rb
@@ -10,27 +10,27 @@ require 'optparse'
 require 'ovirt'
 
 def move_random_host(hosts, pool)
-    host = hosts[rand(hosts.size)]
-    puts "Move #{host.hostname} to #{pool.name}"
-    pool.hosts << host
-    pool.save
+  host = hosts[rand(hosts.size)]
+  puts "Move #{host.hostname} to #{pool.name}"
+  pool.hosts << host
+  pool.save
 end
 
 def element_path(obj)
-    "[#{obj.class.element_path(obj.id)}]"
+  "[#{obj.class.element_path(obj.id)}]"
 end
 
 def print_pool(pool)
-    puts "\n\nPool #{pool.name}: #{pool.hosts.size} hosts, #{pool.storage_pools.size} storage pools #{element_path(pool)} "
-    puts "=" * 75
-    pool.hosts.each do |h|
-        printf "%-36s %s\n", h.hostname, element_path(h)
-    end
-    pool.storage_pools.each do |sp|
-        type = sp.nfs? ? "NFS" : "iSCSI"
-        printf "%-5s %-30s %s\n", type, sp.label, element_path(sp)
-    end
-    puts "-" * 75
+  puts "\n\nPool #{pool.name}: #{pool.hosts.size} hosts, #{pool.storage_pools.size} storage pools #{element_path(pool)} "
+  puts "=" * 75
+  pool.hosts.each do |h|
+    printf "%-36s %s\n", h.hostname, element_path(h)
+  end
+  pool.storage_pools.each do |sp|
+    type = sp.nfs? ? "NFS" : "iSCSI"
+    printf "%-5s %-30s %s\n", type, sp.label, element_path(sp)
+  end
+  puts "-" * 75
 end
 
 # Plumbing so we can find the OVirt server
@@ -45,17 +45,17 @@ opts.separator "Global options:"
 opts.on("-s", "--server=URL", "The OVirt server. Since there is no auth\n" +
         "#{" "*37}yet, must be the mongrel server port.\n" +
         "#{" "*37}Overrides env var OVIRT_SERVER") do |val|
-    OVirt::Base.site = val
+  OVirt::Base.site = val
 end
 
 opts.order(ARGV)
 
 unless OVirt::Base.site
-    $stderr.puts <<EOF
+  $stderr.puts <<EOF
 You must specify the OVirt server to connect to, either with the
 --server option or through the OVIRT_SERVER environment variable
 EOF
-    exit 1
+  exit 1
 end
 
 OVirt::Base.login
@@ -71,23 +71,23 @@ print_pool(defpool)
 # Create a new hardware pool
 mypool = OVirt::HardwarePool.find_by_path("/default/mypool")
 unless mypool
-    puts "Create mypool"
-    mypool = OVirt::HardwarePool.create( { :parent_id => defpool.id,
-                                             :name => "mypool" } )
+  puts "Create mypool"
+  mypool = OVirt::HardwarePool.create( { :parent_id => defpool.id,
+                                         :name => "mypool" } )
 end
 
 # Move some hosts around
 puts
 if defpool.hosts.size > 1
-    move_random_host(defpool.hosts, mypool)
+  move_random_host(defpool.hosts, mypool)
 elsif mypool.hosts.size > 0
-    move_random_host(mypool.hosts, defpool)
+  move_random_host(mypool.hosts, defpool)
 end
 
 # Delete all storage pools for mypool and add a new one
 mypool.storage_pools.each do |sp|
-    puts "Delete storage pool #{sp.id}"
-    sp.destroy
+  puts "Delete storage pool #{sp.id}"
+  sp.destroy
 end
 
 storage_pool = OVirt::StoragePool.create( { :storage_type => "NFS",
diff --git a/lib/ovirt.rb b/lib/ovirt.rb
index 15dc467..fc3ac2a 100644
--- a/lib/ovirt.rb
+++ b/lib/ovirt.rb
@@ -18,85 +18,85 @@ class ActiveResource::Connection
 end
 
 module OVirt
-    class Base < ActiveResource::Base
-      LOGIN_PATH = "login/login"
-
-      def self.login
-        response = nil
-        begin
-          response = connection.get(prefix + LOGIN_PATH)
-        rescue ActiveResource::Redirection => e
-          response = e.response
-        end
-        unless connection.session = session_cookie(response)
-          raise "Authentication failed"
-        end
+  class Base < ActiveResource::Base
+    LOGIN_PATH = "login/login"
+
+    def self.login
+      response = nil
+      begin
+        response = connection.get(prefix + LOGIN_PATH)
+      rescue ActiveResource::Redirection => e
+        response = e.response
       end
+      unless connection.session = session_cookie(response)
+        raise "Authentication failed"
+      end
+    end
 
-      private
-      def self.session_cookie(response)
-        if cookies = response.get_fields("Set-Cookie")
-          cookies.find { |cookie|
-            cookie.split(";")[0].split("=")[0] == "_ovirt_session_id"
-          }
-        end
+    private
+    def self.session_cookie(response)
+      if cookies = response.get_fields("Set-Cookie")
+        cookies.find { |cookie|
+          cookie.split(";")[0].split("=")[0] == "_ovirt_session_id"
+        }
       end
+    end
+
+  end
+
+  class HardwarePool < Base
+    def self.find_by_path(path)
+      find(:first, :params => { :path => path })
+    end
 
+    def self.default_pool
+      find(:first, :params => { :path => "/default" })
     end
+  end
 
-    class HardwarePool < Base
-        def self.find_by_path(path)
-            find(:first, :params => { :path => path })
-        end
+  class StoragePool < Base
+    def iscsi?
+      attributes["type"] == "IscsiStoragePool"
+    end
 
-        def self.default_pool
-            find(:first, :params => { :path => "/default" })
-        end
+    def nfs?
+      attributes["type"] == "NfsStoragePool"
     end
 
-    class StoragePool < Base
-        def iscsi?
-            attributes["type"] == "IscsiStoragePool"
-        end
-
-        def nfs?
-            attributes["type"] == "NfsStoragePool"
-        end
-
-        def label
-            if iscsi?
-                "#{ip_addr}:#{port}:#{target}"
-            elsif nfs?
-                "#{ip_addr}:#{export_path}"
-            else
-                raise "Unknown type #{attributes["type"]}"
-            end
-        end
+    def label
+      if iscsi?
+        "#{ip_addr}:#{port}:#{target}"
+      elsif nfs?
+        "#{ip_addr}:#{export_path}"
+      else
+        raise "Unknown type #{attributes["type"]}"
+      end
     end
+  end
 
-    class IscsiStoragePool < StoragePool
-        def initialize(attributes = {})
-            super(attributes.update( "type" => "IscsiStoragePool" ))
-        end
+  class IscsiStoragePool < StoragePool
+    def initialize(attributes = {})
+      super(attributes.update( "type" => "IscsiStoragePool" ))
     end
+  end
 
-    class NfsStoragePool < StoragePool
-        def initialize(attributes = {})
-            super(attributes.update( "type" => "NfsStoragePool" ))
-        end
+  class NfsStoragePool < StoragePool
+    def initialize(attributes = {})
+      super(attributes.update( "type" => "NfsStoragePool" ))
     end
+  end
 
-    class Host < Base
-        def self.find_by_uuid(uuid)
-            find(:first, :params => { :uuid => uuid })
-        end
+  class Host < Base
+    def self.find_by_uuid(uuid)
+      find(:first, :params => { :uuid => uuid })
+    end
 
-        def self.find_by_hostname(hostname)
-            find(:first, :params => { :hostname => hostname })
-        end
+    def self.find_by_hostname(hostname)
+      find(:first, :params => { :hostname => hostname })
+    end
 
-        def hardware_pool
-            HardwarePool.find(hardware_pool_id)
-        end
+    def hardware_pool
+      HardwarePool.find(hardware_pool_id)
     end
+  end
 end
-- 
1.6.0.6




More information about the ovirt-devel mailing list