On Tue, 26 Jun 2012 12:17:26 -0500, Steve Linabery <slinaber(a)redhat.com> wrote:
Add dc:admin_exists task
We need to query via ActiveRecord to see if a user with
admin privileges already exists. This allows us to replace
the behaviour in aeolus-configure that creates (and checks for)
a file to determine whether an admin has been created. Instead
we will look for an existing type of privilege.
---
src/lib/tasks/dc_tasks.rake | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/lib/tasks/dc_tasks.rake b/src/lib/tasks/dc_tasks.rake
index b3581c0..5993cd4 100644
--- a/src/lib/tasks/dc_tasks.rake
+++ b/src/lib/tasks/dc_tasks.rake
@@ -180,6 +180,13 @@ namespace :dc do
end
end
+ task :admin_exists => :environment do
+ no_admins = BasePermissionObject.general_permission_scope.permissions.includes(:role
=> :privileges).where("privileges.target_type" =>
"BasePermissionObject","privileges.action" =>
Privilege::PERM_SET).empty?
+ if no_admins
+ exit(1)
+ end
+ end
+
def get_account(provider_name, account_name)
unless provider = Provider.find_by_name(provider_name)
raise "There is no provider with '#{provider_name}' name"
--
1.7.6.5
ACK!