[PATCH portal 1/2] Add spec for Instance models.
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
---
src/spec/factories/instance.rb | 8 +++
src/spec/models/instance_spec.rb | 113 ++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+), 0 deletions(-)
create mode 100644 src/spec/factories/instance.rb
create mode 100644 src/spec/models/instance_spec.rb
diff --git a/src/spec/factories/instance.rb b/src/spec/factories/instance.rb
new file mode 100644
index 0000000..0cd1ea2
--- /dev/null
+++ b/src/spec/factories/instance.rb
@@ -0,0 +1,8 @@
+Factory.define :instance do |i|
+ i.sequence(:name) { |n| "instance#{n}" }
+ i.sequence(:external_key) { |n| "key#{n}" }
+ i.hardware_profile_id 1
+ i.image_id 1
+ i.pool_id 1
+ i.state "running"
+end
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
new file mode 100644
index 0000000..84cd234
--- /dev/null
+++ b/src/spec/models/instance_spec.rb
@@ -0,0 +1,113 @@
+require 'spec_helper'
+
+describe Instance do
+ before(:each) do
+ @instance = Factory.build(:instance)
+ @actions = ['start', 'stop']
+ end
+
+ it "should require pool to be set" do
+ @instance.pool_id = nil
+ @instance.should_not be_valid
+
+ @instance.pool_id = 1
+ @instance.should be_valid
+ end
+
+ it "should require hardware profile to be set" do
+ @instance.hardware_profile_id = nil
+ @instance.should_not be_valid
+
+ @instance.hardware_profile_id = 1
+ @instance.should be_valid
+ end
+
+ it "should require image to be set" do
+ @instance.image_id = nil
+ @instance.should_not be_valid
+
+ @instance.image_id = 1
+ @instance.should be_valid
+ end
+
+ it "should have a name of reasonable length" do
+ [nil, '', 'x'*1025].each do |invalid_name|
+ @instance.name = invalid_name
+ @instance.should_not be_valid
+ end
+ @instance.name = 'x'*1024
+ @instance.should be_valid
+
+ end
+
+ it "should have unique name" do
+ @instance.save!
+ second_instance = Factory.build(:instance,
+ :pool_id => @instance.pool_id,
+ :name => @instance.name)
+ second_instance.should_not be_valid
+
+ second_instance.name = 'unique name'
+ second_instance.should be_valid
+ end
+
+ it "should be invalid for unknown states" do
+ ["new", "pending", "running", "shutting_down", "stopped",
+ "create_failed"].each do |valid_state|
+ @instance.state = 'invalid_state'
+ @instance.should_not be_valid
+ @instance.state = valid_state
+ @instance.should be_valid
+ end
+ end
+
+
+ it "should tell apart valid and invalid actions" do
+ @instance.stub!(:get_action_list).and_return(@actions)
+ @instance.valid_action?('invalid action').should == false
+ @instance.valid_action?('start').should == true
+ end
+
+ it "should return action list" do
+ @instance.get_action_list.should eql([])
+
+ InstanceTask.stub!(:valid_actions_for_instance_state).and_return(
+ @actions)
+ @instance.get_action_list.should eql(@actions)
+ end
+
+ it "should be able to queue new actions" do
+ @instance.stub!(:get_action_list).and_return(@actions)
+ user = User.new
+
+ invalid_task = @instance.queue_action(user, 'unknown action')
+ invalid_task.should == false
+ valid_task = @instance.queue_action(user, 'stop')
+ valid_task.should_not == false
+ end
+
+ it "should be able to query and set up frontend realm" do
+ provider = Factory.build(:mock_provider2)
+ provider.stub!(:connect).and_return(mock('DeltaCloud'))
+ provider.save!
+ cloud_account = CloudAccount.new(:provider_id => provider.id,
+ :username => 'john doe',
+ :password => 'asdf')
+ cloud_account.save!
+ @instance = Factory.create(:instance,
+ :cloud_account_id => cloud_account.id)
+ @instance.front_end_realm.should eql('mock2:john doe')
+
+ realm = Factory.create(:realm, :name => 'a realm',
+ :provider_id => provider.id)
+ @instance.realm = realm
+ @instance.front_end_realm.should eql('mock2:john doe/a realm')
+
+ Factory.create(:realm, :name => 'different realm',
+ :provider_id => provider.id)
+ @instance.front_end_realm = 'mock2:john doe/different realm'
+ @instance.front_end_realm.should eql('mock2:john doe/different realm')
+ end
+
+
+end
--
1.6.6.1
14 years, 1 month
Fix HWP and Image model specs for Rails 2.3.4
by Tomas Sedovic
The previous versions of these patches caused errors in the will_paginate
plugin under Rails 2.3.4.
The plugin requires ActiveRecord classes to be saved in the database for array
operations. Which wasn't done for these specs.
This is the fix. Please ignore previous patches for Hardware Profile and
Image specs. Apply on the current HEAD of 'next'.
14 years, 1 month
Replaced XMLConverter by HAML
by Michal Fojtik
Hi,
I replaced xml_converter by HAML templates.
This patch should apply on top of HWP patch posted by David.
- Michal
14 years, 1 month
Replaced RightAws with amazon-ec2 gem (rev 2)
by Michal Fojtik
Hi,
I just updated my previous patch according to hardware profiles patch from
David. Again, this version of EC2 driver is well tested on real EC2
and it works perfectly for me.
You can apply this patch on top of HWP patch.
- Michal
14 years, 1 month
[PATCH core] Hardware profiles
by David Lutterkort
This series of patches adds support for hardware profiles to Deltacloud
core. Hardware profiles describe how instances can be sized, and are more
general than the old flavors, in that each property can either be a fixed
value, a predefined enumeration of values, or a range of values.
To try these patches with the mock driver, you need to stop your server, rm
-rf the mock storage root (usually /var/tmp/deltacloud-core-$USER), and
start the server again once you have the patches applied.
Even if you don't try these patches, I'd highly appreciate feedback on all
this, especially the XML representation of hardware profiles.
XML Representation
==================
The XML representation for hardware profiles looks like
<hardware-profile href="http://localhost:3001/api/hardware_profiles/m1-large">
<id>m1-large</id>
<property kind="range" name="memory" unit="MB" value="10240">
<param href="http://localhost:3001/api/instances" method="post" name="hwp_memory" operation="create"/>
<range first="7680.0" last="15360"/>
</property>
<property kind="enum" name="storage" unit="GB" value="850">
<param href="http://localhost:3001/api/instances" method="post" name="hwp_storage" operation="create"/>
<enum>
<entry value="850"/>
<entry value="1024"/>
</enum>
</property>
<property kind="fixed" name="architecture" unit="label" value="x86_64"/>
<property kind="fixed" name="cpu" unit="count" value="2"/>
</hardware-profile>
That is: a hardware profile has a URL (the href attribute), an <id> child
giving its name, and a list of <property> children. A property can be one
of three kinds; all properties have a name, a (default) value, and a
unit. We will try and not gratuitously change units, i.e. for now memory is
always reported in MB. The three kinds of properties are
* fixed: there's only one possible value for the property, the one in the
value attribute
* range: the property can take on any number between the first and last
number from the <range> child. The range is inclusive of the
first and last value.
* enum: the property can take on one of a fixed set of values. The values
are described inside an <enum> child, as the value attribute of
the <entry> tags
Properties that can have more than one value, i.e. range and enum
properties, also describe what operations are affected by them. Right now,
this is only the create instance operation. The <param> child of the
<property> element explains what parameter to pass to instance creation to
change the value of that property.
Instance creation
=================
When craeting an instance, you now have to pass the parameter hwp_id rather
than flavor_id. The hwp_id has to be the <id> of an existing hardware
profile. It is not necessary to pass any other hardware profile related
parameters, since all proeprties have default values, and those are used
for each property if only a hwp_id is given.
Optionally, additional parameters can be passed to instance creation to
change some properties from their default value. With the above hardware
profile, you could pass hwp_memory=15000 in addition to hwp_id=m1-large to
get an instance with almost 15GB of memory.
Instance representation
=======================
The XML for an instance now lists which properties had explicit values set
when the instance was created; this is indicated in the XML as
<instance href="http://localhost:3001/api/instances/inst0">
<id>inst0</id>
...
<hardware-profile href="http://localhost:3001/api/hardware_profiles/m1-large">
<id>m1-large</id>
<property kind="fixed" name="memory" value="15000" unit="MB"/>
</hardware-profile>
...
</instance>
The 'instance profile' refers to an existing hardware profile by giving its
URL and name, and uses <property> tags to show which properties have values
differing from the hardware profile. The kind attribute on those tags is
always 'fixed'.
Drivers
=======
I've tested this pretty extensively, and at least for the EC2, Rackspace,
and GoGrid drivers everything seems to work. I don't have a way to test the
drivers for RimuHosting, RHEV-M, or OpenNebula. I know that these drivers
need work, and would appreciate it if others could help out.
Patch series
============
The first 3 patches are minor cleanups, not directly related to hardware
profiles. Patches 4-7 mutate hardware profiles to what we need, and add XML
output for them. Patches 8-24 are concerned with integrating hardware
profiles into the existing server and the drivers. Patch 25 removes any
support with flavors - if you need to use flavors for a transitional
period, that should be possible solely by not applying patch 25.
14 years, 1 month
CloudAccount spec and drop dependency on Core for tests
by Tomas Sedovic
This series adds spec for CloudAccount model.
In addition, it fixes the specs for HardwareProfiles and Image model. The
previous specs required deltacloud-core server running. It is no longer
necessary.
Apply them on the fresh 'next' branch -- these patches replace the previous HP
and Image versions.
14 years, 1 month
[PATCH] Added factories for Cloud Account and Image
by Martyn Taylor
---
src/spec/factories/cloud_account.rb | 5 +++++
src/spec/factories/image.rb | 6 ++++++
2 files changed, 11 insertions(+), 0 deletions(-)
create mode 100644 src/spec/factories/cloud_account.rb
create mode 100644 src/spec/factories/image.rb
diff --git a/src/spec/factories/cloud_account.rb b/src/spec/factories/cloud_account.rb
new file mode 100644
index 0000000..b1e4cc4
--- /dev/null
+++ b/src/spec/factories/cloud_account.rb
@@ -0,0 +1,5 @@
+Factory.define :cloud_account do |f|
+ f.sequence(:username) { |n| "testUser#(n)" }
+ f.password "testPassword"
+ f.association :provider
+end
\ No newline at end of file
diff --git a/src/spec/factories/image.rb b/src/spec/factories/image.rb
new file mode 100644
index 0000000..d06807a
--- /dev/null
+++ b/src/spec/factories/image.rb
@@ -0,0 +1,6 @@
+Factory.define :image do |i|
+ i.sequence(:name) { |n| "mock_image#{n}" }
+ i.sequence(:external_key) { |n| "mock_external_key#{n}" }
+ i.architecture "i386"
+ i.association(:portal_pool)
+end
\ No newline at end of file
--
1.6.6.1
14 years, 1 month
[PATCH 1/2] Updated Portal Pool Images Controller/View + config/routes to use default routing :controller/:action/:id to allow mapping of resources for portal_pool. Needed for portal pool cucumber feature
by Martyn Taylor
---
src/app/controllers/portal_pool_controller.rb | 8 +++-----
src/app/views/portal_pool/new.html.erb | 2 +-
src/app/views/portal_pool/show.html.erb | 2 +-
src/config/routes.rb | 8 ++++++--
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/app/controllers/portal_pool_controller.rb b/src/app/controllers/portal_pool_controller.rb
index 69208fa..cacc451 100644
--- a/src/app/controllers/portal_pool_controller.rb
+++ b/src/app/controllers/portal_pool_controller.rb
@@ -84,9 +84,8 @@ class PortalPoolController < ApplicationController
def delete
end
-
def images
- @pool = PortalPool.find(params[:portal_pool])
+ @pool = PortalPool.find(params[:id])
require_privilege(Privilege::POOL_VIEW, @pool)
end
@@ -112,6 +111,5 @@ class PortalPoolController < ApplicationController
end
redirect_to :action => 'show', :id => @portal_pool.id
end
-
-
-end
+
+end
\ No newline at end of file
diff --git a/src/app/views/portal_pool/new.html.erb b/src/app/views/portal_pool/new.html.erb
index e98fc4b..29201f5 100644
--- a/src/app/views/portal_pool/new.html.erb
+++ b/src/app/views/portal_pool/new.html.erb
@@ -7,7 +7,7 @@
<% form_tag :action => 'create' do -%>
<legend>Pool</legend>
<ul>
- <li><label>Name<span>Provide a descriptive name for this pool.</span></label><%= text_field :portal_pool, :name %></li>
+ <li><label>Name<span>Provide a descriptive name for this pool.</span></label><%= text_field :portal_pool, :name %></li>
</ul>
</fieldset>
<%= submit_tag "Save", :class => "submit" %>
diff --git a/src/app/views/portal_pool/show.html.erb b/src/app/views/portal_pool/show.html.erb
index 31e2d7c..cc9b30d 100644
--- a/src/app/views/portal_pool/show.html.erb
+++ b/src/app/views/portal_pool/show.html.erb
@@ -39,5 +39,5 @@
<%= link_to "Back end Accounts", {:action => "accounts", :id => @pool.id}, :class=>"actionlink"%>
<%= link_to "User access", {:controller => "permissions", :action => "list", :portal_pool_id => @pool.id}, :class=>"actionlink" if has_view_perms? %>
<%= link_to "Hardware Profiles", {:action => "hardware_profiles", :id => @pool.id}, :class=>"actionlink"%>
-<%=link_to "View Images", {:controller => "portal_pool", :action => "images", :portal_pool => @pool}, :class => "actionlink" %>
+<%=link_to "View Images", {:controller => "portal_pool", :action => "images", :id => @pool.id}, :class => "actionlink" %>
<%= link_to "Realms", {:action => "realms", :id => @pool.id}, :class=>"actionlink"%>
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 38e9ce4..053d61f 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -31,6 +31,10 @@ ActionController::Routing::Routes.draw do |map|
# You can have the root of your site routed by hooking up ''
# -- just remember to delete public/index.html.
+
+
+ map.resources :portal_pool
+
map.connect '', :controller => 'provider'
map.login 'login', :controller => "user_sessions", :action => "new"
@@ -40,11 +44,11 @@ ActionController::Routing::Routes.draw do |map|
map.resource :account, :controller => "users"
map.resources :users
map.root :login
+
# Temporarily disable this route, provider stuff is not restful yet.
# Will be re-enabled in upcoming patch
# map.resources :provider
-
# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
@@ -52,4 +56,4 @@ ActionController::Routing::Routes.draw do |map|
# Install the default route as the lowest priority.
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'
-end
+end
\ No newline at end of file
--
1.6.6.1
14 years, 1 month
[PATCH portal 2/2] renamed BasePortalObject to BasePermissionObject
by Scott Seago
You will need to drop your database and re-run the migrations after this.
Signed-off-by: Scott Seago <sseago(a)redhat.com>
---
src/app/controllers/permissions_controller.rb | 6 ++--
src/app/models/base_permission_object.rb | 35 ++++++++++++++++++++
src/app/models/base_portal_object.rb | 35 --------------------
src/app/models/permission.rb | 18 +++++-----
src/app/models/permissioned_object.rb | 2 +-
src/app/services/application_service.rb | 4 +-
src/app/views/layouts/_main_nav.html.erb | 4 +-
src/db/migrate/20091008153058_create_roles.rb | 4 +-
...0091019215838_create_base_permission_objects.rb | 14 ++++++++
.../20091019215838_create_base_portal_objects.rb | 14 --------
src/lib/tasks/dc_tasks.rake | 2 +-
src/spec/factories/permission.rb | 2 +-
src/spec/fixtures/base_permission_objects.yml | 2 +
src/spec/fixtures/base_portal_objects.yml | 2 -
src/spec/fixtures/roles.yml | 4 +-
src/test/fixtures/base_permission_objects.yml | 9 +++++
src/test/fixtures/base_portal_objects.yml | 9 -----
src/test/fixtures/permissions.yml | 2 +-
src/test/fixtures/roles.yml | 4 +-
src/test/unit/base_permission_object_test.rb | 8 ++++
src/test/unit/base_portal_object_test.rb | 8 ----
21 files changed, 94 insertions(+), 94 deletions(-)
create mode 100644 src/app/models/base_permission_object.rb
delete mode 100644 src/app/models/base_portal_object.rb
create mode 100644 src/db/migrate/20091019215838_create_base_permission_objects.rb
delete mode 100644 src/db/migrate/20091019215838_create_base_portal_objects.rb
create mode 100644 src/spec/fixtures/base_permission_objects.yml
delete mode 100644 src/spec/fixtures/base_portal_objects.yml
create mode 100644 src/test/fixtures/base_permission_objects.yml
delete mode 100644 src/test/fixtures/base_portal_objects.yml
create mode 100644 src/test/unit/base_permission_object_test.rb
delete mode 100644 src/test/unit/base_portal_object_test.rb
diff --git a/src/app/controllers/permissions_controller.rb b/src/app/controllers/permissions_controller.rb
index 9d9b2a9..c068849 100644
--- a/src/app/controllers/permissions_controller.rb
+++ b/src/app/controllers/permissions_controller.rb
@@ -73,10 +73,10 @@ class PermissionsController < ApplicationController
@permission_object = Provider.find params[:provider_id]
elsif !params[:cloud_account_id].nil?
@permission_object = CloudAccount.find params[:cloud_account_id]
- elsif !params[:base_portal_object_id].nil?
- @permission_object = BasePortalObject.find params[:base_portal_object_id]
+ elsif !params[:base_permission_object_id].nil?
+ @permission_object = BasePermissionObject.find params[:base_permission_object_id]
else
- @permission_object = BasePortalObject.general_permission_scope
+ @permission_object = BasePermissionObject.general_permission_scope
end
raise ActiveRecord::RecordNotFound if @permission_object.nil?
diff --git a/src/app/models/base_permission_object.rb b/src/app/models/base_permission_object.rb
new file mode 100644
index 0000000..5d64613
--- /dev/null
+++ b/src/app/models/base_permission_object.rb
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Written by Scott Seago <sseago(a)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 BasePermissionObject < ActiveRecord::Base
+
+ include PermissionedObject
+ has_many :permissions, :as => :permission_object, :dependent => :destroy,
+ :include => [:role],
+ :order => "permissions.id ASC"
+
+ validates_presence_of :name
+ validates_uniqueness_of :name
+
+ GENERAL_PERMISSION_SCOPE = "general_permission_scope"
+
+ def self.general_permission_scope
+ self.find_by_name(GENERAL_PERMISSION_SCOPE)
+ end
+end
diff --git a/src/app/models/base_portal_object.rb b/src/app/models/base_portal_object.rb
deleted file mode 100644
index 422f5dd..0000000
--- a/src/app/models/base_portal_object.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2009 Red Hat, Inc.
-# Written by Scott Seago <sseago(a)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 BasePortalObject < ActiveRecord::Base
-
- include PermissionedObject
- has_many :permissions, :as => :permission_object, :dependent => :destroy,
- :include => [:role],
- :order => "permissions.id ASC"
-
- validates_presence_of :name
- validates_uniqueness_of :name
-
- GENERAL_PERMISSION_SCOPE = "general_permission_scope"
-
- def self.general_permission_scope
- self.find_by_name(GENERAL_PERMISSION_SCOPE)
- end
-end
diff --git a/src/app/models/permission.rb b/src/app/models/permission.rb
index c77061f..349b6a7 100644
--- a/src/app/models/permission.rb
+++ b/src/app/models/permission.rb
@@ -27,15 +27,15 @@ class Permission < ActiveRecord::Base
validates_uniqueness_of :user_id, :scope => [:permission_object_id,
:permission_object_type]
- belongs_to :permission_object, :polymorphic => true
+ belongs_to :permission_object, :polymorphic => true
# type-specific associations
- belongs_to :pool, :class_name => "Pool",
- :foreign_key => "permission_object_id"
- belongs_to :provider, :class_name => "Provider",
- :foreign_key => "permission_object_id"
- belongs_to :cloud_account, :class_name => "CloudAccount",
- :foreign_key => "permission_object_id"
- belongs_to :base_portal_object, :class_name => "BasePortalObject",
- :foreign_key => "permission_object_id"
+ belongs_to :pool, :class_name => "Pool",
+ :foreign_key => "permission_object_id"
+ belongs_to :provider, :class_name => "Provider",
+ :foreign_key => "permission_object_id"
+ belongs_to :cloud_account, :class_name => "CloudAccount",
+ :foreign_key => "permission_object_id"
+ belongs_to :base_permission_object, :class_name => "BasePermissionObject",
+ :foreign_key => "permission_object_id"
end
diff --git a/src/app/models/permissioned_object.rb b/src/app/models/permissioned_object.rb
index a253410..b4a3037 100644
--- a/src/app/models/permissioned_object.rb
+++ b/src/app/models/permissioned_object.rb
@@ -86,7 +86,7 @@ module PermissionedObject
def self.included(base)
base.class_eval do
def self.list_for_user(user, privilege)
- if BasePortalObject.general_permission_scope.has_privilege(user, privilege)
+ if BasePermissionObject.general_permission_scope.has_privilege(user, privilege)
all
else
find(:all, :include => {:permissions => {:role => :privileges}},
diff --git a/src/app/services/application_service.rb b/src/app/services/application_service.rb
index f72f83d..3315fb1 100644
--- a/src/app/services/application_service.rb
+++ b/src/app/services/application_service.rb
@@ -42,8 +42,8 @@ module ApplicationService
def check_privilege(privilege, perm_obj)
((perm_obj and perm_obj.has_privilege(@current_user, privilege)) or
- BasePortalObject.general_permission_scope.has_privilege(@current_user,
- privilege))
+ BasePermissionObject.general_permission_scope.has_privilege(@current_user,
+ privilege))
end
def authorized?(privilege, perm_obj=nil)
@perm_obj = perm_obj
diff --git a/src/app/views/layouts/_main_nav.html.erb b/src/app/views/layouts/_main_nav.html.erb
index 0e14f4a..0155bd6 100644
--- a/src/app/views/layouts/_main_nav.html.erb
+++ b/src/app/views/layouts/_main_nav.html.erb
@@ -2,8 +2,8 @@
<%=link_to "Add a pool", {:controller => "pool", :action => "new"}, :class => "actionlink" %>
-<%= link_to "Add a user", {:controller => "users", :action => "new"}, :class=>"actionlink" if has_user_modify?(BasePortalObject.general_permission_scope) %>
-<%= link_to "User access", {:controller => "permissions", :action => "list"}, :class=>"actionlink" if has_view_perms?(BasePortalObject.general_permission_scope) %>
+<%= link_to "Add a user", {:controller => "users", :action => "new"}, :class=>"actionlink" if has_user_modify?(BasePermissionObject.general_permission_scope) %>
+<%= link_to "User access", {:controller => "permissions", :action => "list"}, :class=>"actionlink" if has_view_perms?(BasePermissionObject.general_permission_scope) %>
<h3>Providers</h3>
<ul id="providers">
<% cur_id = params[:id].to_i %>
diff --git a/src/db/migrate/20091008153058_create_roles.rb b/src/db/migrate/20091008153058_create_roles.rb
index 3e578c8..5234c90 100644
--- a/src/db/migrate/20091008153058_create_roles.rb
+++ b/src/db/migrate/20091008153058_create_roles.rb
@@ -104,11 +104,11 @@ class CreateRoles < ActiveRecord::Migration
{:role_scope => "CloudAccount",
:privileges => ["account_view"]},
"Provider Creator" =>
- {:role_scope => "BasePortalObject",
+ {:role_scope => "BasePermissionObject",
:privileges => ["provider_modify",
"provider_view"]},
"Administrator" =>
- {:role_scope => "BasePortalObject",
+ {:role_scope => "BasePermissionObject",
:privileges => ["provider_modify",
"provider_view",
"account_modify",
diff --git a/src/db/migrate/20091019215838_create_base_permission_objects.rb b/src/db/migrate/20091019215838_create_base_permission_objects.rb
new file mode 100644
index 0000000..0318ee7
--- /dev/null
+++ b/src/db/migrate/20091019215838_create_base_permission_objects.rb
@@ -0,0 +1,14 @@
+class CreateBasePermissionObjects < ActiveRecord::Migration
+ def self.up
+ create_table :base_permission_objects do |t|
+ t.string :name, :null => false
+ t.timestamps
+ end
+
+ BasePermissionObject.new({:name => "general_permission_scope"}).save!
+ end
+
+ def self.down
+ drop_table :base_permission_objects
+ end
+end
diff --git a/src/db/migrate/20091019215838_create_base_portal_objects.rb b/src/db/migrate/20091019215838_create_base_portal_objects.rb
deleted file mode 100644
index badea5d..0000000
--- a/src/db/migrate/20091019215838_create_base_portal_objects.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class CreateBasePortalObjects < ActiveRecord::Migration
- def self.up
- create_table :base_portal_objects do |t|
- t.string :name, :null => false
- t.timestamps
- end
-
- BasePortalObject.new({:name => "general_permission_scope"}).save!
- end
-
- def self.down
- drop_table :base_portal_objects
- end
-end
diff --git a/src/lib/tasks/dc_tasks.rake b/src/lib/tasks/dc_tasks.rake
index 1621a06..4c1a9e0 100644
--- a/src/lib/tasks/dc_tasks.rake
+++ b/src/lib/tasks/dc_tasks.rake
@@ -20,7 +20,7 @@ namespace :dc do
end
user.permissions << Permission.new(:role => Role.find_by_name('Administrator'),
- :permission_object => BasePortalObject.general_permission_scope
+ :permission_object => BasePermissionObject.general_permission_scope
)
puts "Granting administrator privileges for #{args.login}..."
end
diff --git a/src/spec/factories/permission.rb b/src/spec/factories/permission.rb
index 293f459..0aad3a2 100644
--- a/src/spec/factories/permission.rb
+++ b/src/spec/factories/permission.rb
@@ -4,7 +4,7 @@ end
Factory.define :admin_permission, :parent => :permission do |p|
p.role { |r| Role.find(:first, :conditions => ['name = ?', 'Administrator']) }
- p.permission_object { |r| BasePortalObject.general_permission_scope }
+ p.permission_object { |r| BasePermissionObject.general_permission_scope }
p.user { |u| u.association(:admin_user) }
end
diff --git a/src/spec/fixtures/base_permission_objects.yml b/src/spec/fixtures/base_permission_objects.yml
new file mode 100644
index 0000000..a520969
--- /dev/null
+++ b/src/spec/fixtures/base_permission_objects.yml
@@ -0,0 +1,2 @@
+general_permission_scope:
+ name: 'general_permission_scope'
diff --git a/src/spec/fixtures/base_portal_objects.yml b/src/spec/fixtures/base_portal_objects.yml
deleted file mode 100644
index a520969..0000000
--- a/src/spec/fixtures/base_portal_objects.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-general_permission_scope:
- name: 'general_permission_scope'
diff --git a/src/spec/fixtures/roles.yml b/src/spec/fixtures/roles.yml
index aafe654..5c72efb 100644
--- a/src/spec/fixtures/roles.yml
+++ b/src/spec/fixtures/roles.yml
@@ -47,9 +47,9 @@ account_viewer:
privileges: account_view
provider_creator:
name: Provider Creator
- scope: BasePortalObject
+ scope: BasePermissionObject
privileges: provider_modify, provider_view, stats_view
administrator:
name: Administrator
- scope: BasePortalObject
+ scope: BasePermissionObject
privileges: provider_modify, provider_view, account_modify, account_add, account_view, user_modify, user_view, set_perms, view_perms, pool_modify, pool_view, quota_modify, quota_view, stats_view, instance_modify, instance_control, instance_view
diff --git a/src/test/fixtures/base_permission_objects.yml b/src/test/fixtures/base_permission_objects.yml
new file mode 100644
index 0000000..4cf58b8
--- /dev/null
+++ b/src/test/fixtures/base_permission_objects.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+# one:
+# column: value
+#
+# two:
+# column: value
+base_permission_object:
+ name: general_permission_scope
\ No newline at end of file
diff --git a/src/test/fixtures/base_portal_objects.yml b/src/test/fixtures/base_portal_objects.yml
deleted file mode 100644
index 7e9b357..0000000
--- a/src/test/fixtures/base_portal_objects.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-
-# one:
-# column: value
-#
-# two:
-# column: value
-base_portal_object:
- name: general_permission_scope
\ No newline at end of file
diff --git a/src/test/fixtures/permissions.yml b/src/test/fixtures/permissions.yml
index 2e889db..4fba11c 100644
--- a/src/test/fixtures/permissions.yml
+++ b/src/test/fixtures/permissions.yml
@@ -3,7 +3,7 @@
admin_permission:
role: site_administrator
user: test_admin
- permission_object: base_portal_object (BasePortalObject)
+ permission_object: base_permission_object (BasePermissionObject)
user_permission:
role: instance_creator_and_user
user: test_user
diff --git a/src/test/fixtures/roles.yml b/src/test/fixtures/roles.yml
index 1391546..5ec515b 100644
--- a/src/test/fixtures/roles.yml
+++ b/src/test/fixtures/roles.yml
@@ -39,9 +39,9 @@ account_user:
privileges: account_view
provider_administrator:
name: Provider Administrator
- scope: BasePortalObject
+ scope: BasePermissionObject
privileges: provider_modify, provider_view, stats_view
site_administrator:
name: Site Administrator
- scope: BasePortalObject
+ scope: BasePermissionObject
privileges: provider_modify, provider_view, account_modify, account_view, user_modify, user_view, set_perms, view_perms, pool_modify, pool_view, quota_modify, quota_view, stats_view, instance_modify, instance_control, instance_view
diff --git a/src/test/unit/base_permission_object_test.rb b/src/test/unit/base_permission_object_test.rb
new file mode 100644
index 0000000..1dcd1be
--- /dev/null
+++ b/src/test/unit/base_permission_object_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class BasePermissionObjectTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
diff --git a/src/test/unit/base_portal_object_test.rb b/src/test/unit/base_portal_object_test.rb
deleted file mode 100644
index e6e4b9d..0000000
--- a/src/test/unit/base_portal_object_test.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class BasePortalObjectTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
--
1.6.2.5
14 years, 1 month