[Ovirt-devel] [PATCH] initial push of smart pool code. (revised)

Mohammed Morsi mmorsi at redhat.com
Fri Sep 5 12:35:36 UTC 2008


Scott Seago wrote:
> This isn't complete, but I want to get it committed before the repo refactoring. This patch includes the controller refactoring needed for adding the new smart pool controllers, but I have not yet added any code to the new controllers. The models are in place for smart pools, but they aren't used anywhere yet. In addition, I've added a new DirectoryPool pool type that is used solely as a placeholder -- so  that we can have a common root for all hardware and smart pools, and that we can organize smart pools by user.
>
> Since we need this pushed before the repo refactoring, this patch should be acked if it doesn't break anything. Separate review comments are, of course, welcome -- but anything that doesn't break the WUI will be fixed in a subsequent (post-repo-reorg) patch)
>
> diff --git a/wui/src/db/migrate/017_add_smart_pools.rb b/wui/src/db/migrate/017_add_smart_pools.rb
> new file mode 100644
> index 0000000..6d83c02
> --- /dev/null
> +++ b/wui/src/db/migrate/017_add_smart_pools.rb
> @@ -0,0 +1,62 @@
> +#
> +# Copyright (C) 2008 Red Hat, Inc.
> +# Written by Scott Seago <sseago at redhat.com>
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; version 2 of the License.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> +# MA  02110-1301, USA.  A copy of the GNU General Public License is
> +# also available at http://www.gnu.org/copyleft/gpl.html.
> +
> +class AddSmartPools < ActiveRecord::Migration
> +  def self.up
> +    create_table :smart_pool_tags  do |t|
> +      t.integer :smart_pool_id, :null => false
> +      t.integer :tagged_id,     :null => false
> +      t.string :tagged_type,    :null => false
> +    end
> +    execute "alter table smart_pool_tags add constraint
> +             fk_smart_pool_tags_pool_id
> +             foreign key (smart_pool_id) references pools(id)"
> +    execute "alter table smart_pool_tags add constraint
> +             unique_smart_pool_tags
> +             unique (smart_pool_id, tagged_id, tagged_type)"
> +
> +    begin
> +      dir_root = DirectoryPool.get_directory_root
> +      unless dir_root
> +        Pool.transaction do
> +          dir_root = DirectoryPool.create(:name=>DirectoryPool::ROOT_NAME)
> +          hw_root = DirectoryPool.new(:name=>DirectoryPool::HARDWARE_ROOT)
> +          hw_root.create_with_parent(dir_root)
> +          smart_root = DirectoryPool.new(:name=>DirectoryPool::SMART_ROOT)
> +          smart_root.create_with_parent(dir_root)
> +          default_pool = Pool.root(:conditions=>"type='HardwarePool'")
> +          default_pool = HardwarePool.create( :name=>'default') unless default_pool
> +          default_pool.move_to_child_of(hw_root)
> +          default_pool.permissions.each do |permission|
> +            new_permission = Permission.new({:pool_id     => dir_root.id,
> +                                             :uid         => permission.uid,
> +                                             :user_role   => permission.user_role})
> +            new_permission.save!
> +          end
> +        end
> +      end
> +    rescue
> +      puts "Could not create DirectoryPool hierarchy..."
> +    end
> +  end
> +
> +  def self.down
> +    drop_table :smart_pool_tags
> +  end
> +end
>   
Post-push comment: I feel that this is going to break alot of test cases
/ the test suite as the pool test fixtures are now invalid (eg they
don't contain the correct top-level pool heirarchy) and changing these
means we will need to change alot of the validations in the test suite
(unfortunately due to previous problems with the build system and the
new repo setup this is hard to validate currently). Perhaps we can work
together in the near future to refix this.

    -Mo




More information about the ovirt-devel mailing list