1

In order to uniquely identify the users in Rally we want to update the Display Name field of users so that 2 people with same name can be identified.

e.g. John D(johnd@test.com)
     John G(johng@test.com)

Tried below code snippet to get all the users in Rally and then will use update() OR post() method to change the displyname is above format.

import sys
from pyral import Rally, rallyWorkset
options = [arg for arg in sys.argv[1:] if arg.startswith('--')]
args    = [arg for arg in sys.argv[1:] if arg not in options]
server = "rally1.rallydev.com"
apikey = "<rally_api_key>"
workspace = "<myworkspace>"
#project = "<myproject>"
rally = Rally(server,apikey=apikey, workspace=workspace)
rally.enableLogging('mypyral.log')

all_users = rally.getAllUsers()
for user in all_users:
    tz   = user.UserProfile.TimeZone or 'default'
    role = user.Role or '-No Role-'
    values = (int(user.oid), user.Name, user.UserName, role, tz)
    print("%12.12d %-24.24s %-30.30s %-12.12s" % values)    

Does not give any output - the logic turns into infinite loop

Is there any alternate way to update the Display Name field for all the users.

vpd
  • 234
  • 2
  • 10

2 Answers2

0

Not sure if this helps, but it works in Ruby:

$ cat -n Print-All-Users-short.rb 
 1  #!/usr/bin/env ruby
 2  $my_base_url    = 'http://rally1.rallydev.com'
 3  $my_username    = 'Secret'
 4  $my_password    = 'MoreSecret'
 5  $my_workspace   = 'Integrations'
 6  
 7  require './MyVars.rb' if FileTest.exist?( './MyVars.rb' )
 8  require 'rally_api'
 9  
10  @rallycon = RallyAPI::RallyRestJson.new({
11          :base_url       => $my_base_url,
12          :username       => $my_username,
13          :password       => $my_password,
14          :workspace      => $my_workspace,
15          :version        => 'v2.0',
16          :headers        => RallyAPI::CustomHttpHeader.new(:name=>'Print-All-Users-short.rb', :vendor=>'MySelf', :version=>'3.14159')
17          })
18  
19  all_users = @rallycon.find(RallyAPI::RallyQuery.new(
20                  :type           => :user,
21                  :query_string   => "(ObjectID > 0)",
22                  :fetch          => true))
23  
24  if all_users.count < 1 then     # Did we find too few?
25      print "ERROR: Query returned nothing.\n"
26      exit (-1)
27  end
28  print "Query returned #{all_users.count} users.\n"

$ ./Print-All-Users-short.rb
Query returned 109 users.
JPKole
  • 341
  • 1
  • 6
0

I was able to update the displayname field with below code.

require 'rally_api'
#require 'rally_user_management'
require 'csv'
require './lib/go_update_user_attributes.rb'

$input_filename_arg = ARGV[0]

if $input_filename_arg == nil
# This is the default of the file to be used for uploading user permissions
  $input_filename             = 'update_user_attributes_template.txt'
else
  $input_filename = File.dirname(__FILE__) + "/" + $input_filename_arg
end

begin
  go_update_user_attributes($input_filename)
end

The only thing you need to make sure is the input file which you provide as a parameter should be a text file not a CSV,Excel etc. Your input file - update_user_attributes_template.txt

UserID  LastName    FirstName   DisplayName Role    OfficeLocation  Department  CostCenter  Phone   NetworkID   DefaultWorkspaceName    DefaultProjectName  TimeZone
testuser@cisco.com          dummy name (testuser)

$ update_user_attributes.rb update_user_attributes_template.txt

Darshan Deshmukh
  • 353
  • 1
  • 4
  • 15