lib/rvc/modules/role.rb in rvc-1.5.0 vs lib/rvc/modules/role.rb in rvc-1.6.0

- old
+ new

@@ -1,5 +1,25 @@ +# Copyright (c) 2011 VMware, Inc. All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + def cur_auth_mgr conn = $shell.fs.cur._connection conn.serviceContent.authorizationManager end @@ -19,11 +39,11 @@ arg :role, "Role", :type => :string end def get name role = cur_auth_mgr.roleList.find { |x| x.name == name } - err "no such role #{role_name.inspect}" unless role + err "no such role #{name.inspect}" unless role puts "label: #{role.info.label}" puts "summary: #{role.info.summary}" puts "privileges: #{role.privilege.sort * ' '}" end @@ -33,11 +53,11 @@ arg :role, "Role", :type => :string end def permissions name role = cur_auth_mgr.roleList.find { |x| x.name == name } - err "no such role #{role_name.inspect}" unless role + err "no such role #{name.inspect}" unless role cur_auth_mgr.RetrieveRolePermissions(:roleId => role.roleId).each do |perm| flags = [] flags << 'group' if perm[:group] flags << 'propagate' if perm[:propagate] puts " #{perm[:principal]}#{flags.empty? ? '' : " (#{flags * ', '})"}: #{perm.entity.name}" @@ -62,10 +82,10 @@ opt :force, "Don't fail if the role is in use" end def delete name, opts role = cur_auth_mgr.roleList.find { |x| x.name == name } - err "no such role #{role_name.inspect}" unless role + err "no such role #{name.inspect}" unless role cur_auth_mgr.RemoveAuthorizationRole :roleId => role.roleId, :failIfUsed => opts[:force] end opts :rename do