--- .../controllers/hardware_profiles_controller.rb | 39 ++++++++++++++++++++ src/app/controllers/portal_pool_controller.rb | 6 +++ src/app/controllers/provider_controller.rb | 6 +++ src/app/views/hardware_profiles/_list.html.erb | 24 ++++++++++++ src/app/views/hardware_profiles/index.html.erb | 1 + .../views/portal_pool/hardware_profiles.html.erb | 1 + src/app/views/provider/hardware_profiles.html.erb | 1 + 7 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 src/app/controllers/hardware_profiles_controller.rb create mode 100644 src/app/views/hardware_profiles/_list.html.erb create mode 100644 src/app/views/hardware_profiles/index.html.erb create mode 100644 src/app/views/portal_pool/hardware_profiles.html.erb create mode 100644 src/app/views/provider/hardware_profiles.html.erb
diff --git a/src/app/controllers/hardware_profiles_controller.rb b/src/app/controllers/hardware_profiles_controller.rb new file mode 100644 index 0000000..523a72c --- /dev/null +++ b/src/app/controllers/hardware_profiles_controller.rb @@ -0,0 +1,39 @@ +# Copyright (C) 2010 Red Hat, Inc. +# +# 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. + +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +require 'util/taskomatic' + +class HardwareProfilesController < ApplicationController + before_filter :require_user + + def index + @hardware_profiles = HardwareProfile.find(:all) + #require_privilege(Privilege::PROVIDER_VIEW, @hardware_profile) ? + end + + def new + end + + def create + end + + def delete + end +end diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb index 90df8a5..449f96c 100644 --- a/src/app/controllers/portal_pool_controller.rb +++ b/src/app/controllers/portal_pool_controller.rb @@ -38,6 +38,12 @@ class PortalPoolController < ApplicationController @instances = @pool.instances end
+ def hardware_profiles + @pool = PortalPool.find(params[:id]) + @hardware_profiles = @pool.hardware_profiles + require_privilege(Privilege::INSTANCE_VIEW,@pool) + end + def new require_privilege(Privilege::POOL_MODIFY) @portal_pool = PortalPool.new diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb index 53056f5..b676fa7 100644 --- a/src/app/controllers/provider_controller.rb +++ b/src/app/controllers/provider_controller.rb @@ -50,6 +50,12 @@ class ProviderController < ApplicationController redirect_to :action => "index" end
+ def hardware_profiles + @provider = Provider.find(params[:id]) + @hardware_profiles = @provider.hardware_profiles + require_privilege(Privilege::PROVIDER_VIEW, @provider) + end + def accounts @provider = Provider.find(params[:id]) require_privilege(Privilege::ACCOUNT_VIEW, @provider) diff --git a/src/app/views/hardware_profiles/_list.html.erb b/src/app/views/hardware_profiles/_list.html.erb new file mode 100644 index 0000000..6b53194 --- /dev/null +++ b/src/app/views/hardware_profiles/_list.html.erb @@ -0,0 +1,24 @@ +<% if @hardware_profiles.size == 0 %> +<h1>There are no hardware profiles to display</h1> +<% else %> + <table> + <thead> + <tr> + <th scope="col">Name</th> + <th scope="col">Memory</th> + <th scope="col">Storage</th> + <th scope="col">Architecture</th> + </tr> + </thead> + <tbody> + <%@hardware_profiles.each {|hp| %> + <tr> + <td><%= hp.name %></td> + <td><%= hp.memory %></td> + <td><%= hp.storage %></td> + <td><%= hp.architecture %></td> + </tr> + <% } %> + </tbody> + </table> +<% end %> diff --git a/src/app/views/hardware_profiles/index.html.erb b/src/app/views/hardware_profiles/index.html.erb new file mode 100644 index 0000000..c19c3fa --- /dev/null +++ b/src/app/views/hardware_profiles/index.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'list' %> diff --git a/src/app/views/portal_pool/hardware_profiles.html.erb b/src/app/views/portal_pool/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/portal_pool/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %> diff --git a/src/app/views/provider/hardware_profiles.html.erb b/src/app/views/provider/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/provider/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %>
requires "spec fixes and updates" patch to be applied first --- src/app/models/provider.rb | 1 - .../hardware_profiles_controller_spec.rb | 19 +++++++++++++++ .../controllers/portal_pool_controller_spec.rb | 10 ++++++++ src/spec/controllers/provider_controller_spec.rb | 12 +++++++++- src/spec/factories/hardware_profile.rb | 24 ++++++++++++++++++++ src/spec/factories/portal_pool.rb | 1 + src/spec/factories/provider.rb | 3 +- 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/spec/controllers/hardware_profiles_controller_spec.rb create mode 100644 src/spec/factories/hardware_profile.rb
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb index 1170488..70051e5 100644 --- a/src/app/models/provider.rb +++ b/src/app/models/provider.rb @@ -79,7 +79,6 @@ class Provider < ActiveRecord::Base def validate if !nil_or_empty(url) errors.add("url", "must be a valid provider url") unless valid_framework? - puts errors.inspect end end
diff --git a/src/spec/controllers/hardware_profiles_controller_spec.rb b/src/spec/controllers/hardware_profiles_controller_spec.rb new file mode 100644 index 0000000..e4b837d --- /dev/null +++ b/src/spec/controllers/hardware_profiles_controller_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe HardwareProfilesController do + + before(:each) do + @admin_permission = Factory :admin_permission + @admin = @admin_permission.user + activate_authlogic + end + + it "should provide ui to view all hardware profiles" do + UserSession.create(@admin) + get :index + response.should be_success + assigns[:hardware_profiles].size.should == HardwareProfile.count + response.should render_template("index") + end + +end diff --git a/src/spec/controllers/portal_pool_controller_spec.rb b/src/spec/controllers/portal_pool_controller_spec.rb index bc01a31..512127d 100644 --- a/src/spec/controllers/portal_pool_controller_spec.rb +++ b/src/spec/controllers/portal_pool_controller_spec.rb @@ -29,5 +29,15 @@ describe PortalPoolController do response.should redirect_to("http://test.host/portal_pool/show/#%7Bid%7D") end
+ it "should provide ui to view hardware profiles" do + UserSession.create(@admin) + pool = Factory :tpool + + get :hardware_profiles, :id => pool.id + response.should be_success + assigns[:hardware_profiles].size.should == pool.hardware_profiles.size + response.should render_template("hardware_profiles") + end +
end diff --git a/src/spec/controllers/provider_controller_spec.rb b/src/spec/controllers/provider_controller_spec.rb index 9015a00..ed0036f 100644 --- a/src/spec/controllers/provider_controller_spec.rb +++ b/src/spec/controllers/provider_controller_spec.rb @@ -9,7 +9,6 @@ describe ProviderController do activate_authlogic end
- it "should provide ui to view accounts" do UserSession.create(@admin) get :accounts, :id => @provider.id @@ -32,4 +31,15 @@ describe ProviderController do response.should_not be_success end
+ it "should provide ui to view hardware profiles" do + UserSession.create(@admin) + provider = @admin_permission.permission_object + + get :hardware_profiles, :id => provider.id + response.should be_success + assigns[:hardware_profiles].size.should == provider.hardware_profiles.size + response.should render_template("hardware_profiles") + end + + end diff --git a/src/spec/factories/hardware_profile.rb b/src/spec/factories/hardware_profile.rb new file mode 100644 index 0000000..752adac --- /dev/null +++ b/src/spec/factories/hardware_profile.rb @@ -0,0 +1,24 @@ +Factory.define :hardware_profile do |p| + p.sequence(:name) { |n| "hardware_profile#{n}" } +end + +Factory.define :mock_hwp1, :parent => :hardware_profile do |p| + p.memory 1024 + p.storage 100 + p.external_key 'mock_hwp1_key' + p.architecture 'i686' +end + +Factory.define :mock_hwp2, :parent => :hardware_profile do |p| + p.memory 2048 + p.storage 400 + p.external_key 'mock_hwp2_key' + p.architecture 'x86_64' +end + +Factory.define :pool_hwp1, :parent => :hardware_profile do |p| + p.memory 2048 + p.storage 400 + p.external_key 'pool_hwp1_key' + p.architecture 'x86_64' +end diff --git a/src/spec/factories/portal_pool.rb b/src/spec/factories/portal_pool.rb index 0b20647..d0a8e52 100644 --- a/src/spec/factories/portal_pool.rb +++ b/src/spec/factories/portal_pool.rb @@ -5,4 +5,5 @@ end
Factory.define :tpool, :parent => :portal_pool do |p| p.name 'tpool' + p.hardware_profiles { |hp| [hp.association(:pool_hwp1)] } end diff --git a/src/spec/factories/provider.rb b/src/spec/factories/provider.rb index 921d54b..f349be3 100644 --- a/src/spec/factories/provider.rb +++ b/src/spec/factories/provider.rb @@ -1,8 +1,9 @@ Factory.define :provider do |p| + p.sequence(:name) { |n| "provider#{n}" } end
Factory.define :mock_provider, :parent => :provider do |p| - p.name 'mock1' p.cloud_type 'mock' p.url 'http://localhost:3001/api' + p.hardware_profiles { |hp| [hp.association(:mock_hwp1), hp.association(:mock_hwp2)] } end
Mohammed Morsi wrote:
.../controllers/hardware_profiles_controller.rb | 39 ++++++++++++++++++++ src/app/controllers/portal_pool_controller.rb | 6 +++ src/app/controllers/provider_controller.rb | 6 +++ src/app/views/hardware_profiles/_list.html.erb | 24 ++++++++++++ src/app/views/hardware_profiles/index.html.erb | 1 + .../views/portal_pool/hardware_profiles.html.erb | 1 + src/app/views/provider/hardware_profiles.html.erb | 1 + 7 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 src/app/controllers/hardware_profiles_controller.rb create mode 100644 src/app/views/hardware_profiles/_list.html.erb create mode 100644 src/app/views/hardware_profiles/index.html.erb create mode 100644 src/app/views/portal_pool/hardware_profiles.html.erb create mode 100644 src/app/views/provider/hardware_profiles.html.erb
diff --git a/src/app/controllers/hardware_profiles_controller.rb b/src/app/controllers/hardware_profiles_controller.rb new file mode 100644 index 0000000..523a72c --- /dev/null +++ b/src/app/controllers/hardware_profiles_controller.rb @@ -0,0 +1,39 @@ +# Copyright (C) 2010 Red Hat, Inc. +# +# 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.
+# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers.
+require 'util/taskomatic'
+class HardwareProfilesController < ApplicationController
- before_filter :require_user
- def index
- @hardware_profiles = HardwareProfile.find(:all)
- #require_privilege(Privilege::PROVIDER_VIEW, @hardware_profile) ?
- end
Can we get rid of 'index' ? I'm not sure a flat list of all profiles for all providers makes sense -- or maybe 'index' should require a provider ID? Anyway it's not a big deal for this patch -- we just need to decide how to handle this sort of page/request
- def new
- end
- def create
- end
- def delete
- end
+end diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb index 90df8a5..449f96c 100644 --- a/src/app/controllers/portal_pool_controller.rb +++ b/src/app/controllers/portal_pool_controller.rb @@ -38,6 +38,12 @@ class PortalPoolController < ApplicationController @instances = @pool.instances end
- def hardware_profiles
- @pool = PortalPool.find(params[:id])
- @hardware_profiles = @pool.hardware_profiles
- require_privilege(Privilege::INSTANCE_VIEW,@pool)
- end
Change this to POOL_VIEW
def new require_privilege(Privilege::POOL_MODIFY) @portal_pool = PortalPool.new diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb index 53056f5..b676fa7 100644 --- a/src/app/controllers/provider_controller.rb +++ b/src/app/controllers/provider_controller.rb @@ -50,6 +50,12 @@ class ProviderController < ApplicationController redirect_to :action => "index" end
- def hardware_profiles
- @provider = Provider.find(params[:id])
- @hardware_profiles = @provider.hardware_profiles
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def accounts @provider = Provider.find(params[:id]) require_privilege(Privilege::ACCOUNT_VIEW, @provider)
diff --git a/src/app/views/hardware_profiles/_list.html.erb b/src/app/views/hardware_profiles/_list.html.erb new file mode 100644 index 0000000..6b53194 --- /dev/null +++ b/src/app/views/hardware_profiles/_list.html.erb @@ -0,0 +1,24 @@ +<% if @hardware_profiles.size == 0 %> +<h1>There are no hardware profiles to display</h1> +<% else %>
<table>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Memory</th>
<th scope="col">Storage</th>
<th scope="col">Architecture</th>
</tr>
</thead>
<tbody>
- <%@hardware_profiles.each {|hp| %>
<tr>
<td><%= hp.name %></td>
<td><%= hp.memory %></td>
<td><%= hp.storage %></td>
<td><%= hp.architecture %></td>
</tr>
<% } %>
</tbody>
</table>
+<% end %> diff --git a/src/app/views/hardware_profiles/index.html.erb b/src/app/views/hardware_profiles/index.html.erb new file mode 100644 index 0000000..c19c3fa --- /dev/null +++ b/src/app/views/hardware_profiles/index.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'list' %> diff --git a/src/app/views/portal_pool/hardware_profiles.html.erb b/src/app/views/portal_pool/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/portal_pool/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %> diff --git a/src/app/views/provider/hardware_profiles.html.erb b/src/app/views/provider/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/provider/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %>
Conditional ACK. Make the one permission change, add a link to this on the pool show page and push
Scott
On 03/18/2010 03:11 PM, Scott Seago wrote:
Mohammed Morsi wrote:
.../controllers/hardware_profiles_controller.rb | 39 ++++++++++++++++++++ src/app/controllers/portal_pool_controller.rb | 6 +++ src/app/controllers/provider_controller.rb | 6 +++ src/app/views/hardware_profiles/_list.html.erb | 24 ++++++++++++ src/app/views/hardware_profiles/index.html.erb | 1 + .../views/portal_pool/hardware_profiles.html.erb | 1 + src/app/views/provider/hardware_profiles.html.erb | 1 + 7 files changed, 78 insertions(+), 0 deletions(-) create mode 100644 src/app/controllers/hardware_profiles_controller.rb create mode 100644 src/app/views/hardware_profiles/_list.html.erb create mode 100644 src/app/views/hardware_profiles/index.html.erb create mode 100644 src/app/views/portal_pool/hardware_profiles.html.erb create mode 100644 src/app/views/provider/hardware_profiles.html.erb
diff --git a/src/app/controllers/hardware_profiles_controller.rb b/src/app/controllers/hardware_profiles_controller.rb new file mode 100644 index 0000000..523a72c --- /dev/null +++ b/src/app/controllers/hardware_profiles_controller.rb @@ -0,0 +1,39 @@ +# Copyright (C) 2010 Red Hat, Inc. +# +# 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.
+# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers.
+require 'util/taskomatic'
+class HardwareProfilesController < ApplicationController
- before_filter :require_user
- def index
- @hardware_profiles = HardwareProfile.find(:all)
- #require_privilege(Privilege::PROVIDER_VIEW, @hardware_profile) ?
- end
Can we get rid of 'index' ? I'm not sure a flat list of all profiles for all providers makes sense -- or maybe 'index' should require a provider ID? Anyway it's not a big deal for this patch -- we just need to decide how to handle this sort of page/request
- def new
- end
- def create
- end
- def delete
- end
+end diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb index 90df8a5..449f96c 100644 --- a/src/app/controllers/portal_pool_controller.rb +++ b/src/app/controllers/portal_pool_controller.rb @@ -38,6 +38,12 @@ class PortalPoolController < ApplicationController @instances = @pool.instances end
- def hardware_profiles
- @pool = PortalPool.find(params[:id])
- @hardware_profiles = @pool.hardware_profiles
- require_privilege(Privilege::INSTANCE_VIEW,@pool)
- end
Change this to POOL_VIEW
def new require_privilege(Privilege::POOL_MODIFY) @portal_pool = PortalPool.new diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb index 53056f5..b676fa7 100644 --- a/src/app/controllers/provider_controller.rb +++ b/src/app/controllers/provider_controller.rb @@ -50,6 +50,12 @@ class ProviderController < ApplicationController redirect_to :action => "index" end
- def hardware_profiles
- @provider = Provider.find(params[:id])
- @hardware_profiles = @provider.hardware_profiles
- require_privilege(Privilege::PROVIDER_VIEW, @provider)
- end
- def accounts @provider = Provider.find(params[:id]) require_privilege(Privilege::ACCOUNT_VIEW, @provider)
diff --git a/src/app/views/hardware_profiles/_list.html.erb b/src/app/views/hardware_profiles/_list.html.erb new file mode 100644 index 0000000..6b53194 --- /dev/null +++ b/src/app/views/hardware_profiles/_list.html.erb @@ -0,0 +1,24 @@ +<% if @hardware_profiles.size == 0 %> +<h1>There are no hardware profiles to display</h1> +<% else %>
<table>
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Memory</th>
<th scope="col">Storage</th>
<th scope="col">Architecture</th>
</tr>
</thead>
<tbody>
- <%@hardware_profiles.each {|hp| %>
<tr>
<td><%= hp.name %></td>
<td><%= hp.memory %></td>
<td><%= hp.storage %></td>
<td><%= hp.architecture %></td>
</tr>
- <% } %>
</tbody>
</table>
+<% end %> diff --git a/src/app/views/hardware_profiles/index.html.erb b/src/app/views/hardware_profiles/index.html.erb new file mode 100644 index 0000000..c19c3fa --- /dev/null +++ b/src/app/views/hardware_profiles/index.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'list' %> diff --git a/src/app/views/portal_pool/hardware_profiles.html.erb b/src/app/views/portal_pool/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/portal_pool/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %> diff --git a/src/app/views/provider/hardware_profiles.html.erb b/src/app/views/provider/hardware_profiles.html.erb new file mode 100644 index 0000000..579d796 --- /dev/null +++ b/src/app/views/provider/hardware_profiles.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'hardware_profiles/list' %>
Conditional ACK. Make the one permission change, add a link to this on the pool show page and push
Scott
Updated and pushed.
-Mo
deltacloud-devel@lists.fedorahosted.org