0

My organization uses SSO authentication. I am getting error while trying to connect rally using api key from python via pyral. Not sure what i am doing wrong. Any help is appreciated! I am using below code in the sample.py file (only change is I am entering the API key value, workspace name and project name) -

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, user, password, apikey, workspace, project = rallyWorkset(options)
print(server)
rally = Rally('rally1.rallydev.com', apikey='<my api key>', workspace='<workspace name>', project='<project name>')
rally.enableLogging('mypyral.log')
workspaces = rally.getWorkspaces()
for wksp in workspaces:
    print("%s %s" % (wksp.oid, wksp.Name))
    projects = rally.getProjects(workspace=wksp.Name)
    for proj in projects:
        print("%12.12s  %s" % (proj.oid, proj.Name))

ERROR I am getting -

rally1.rallydev.com
Traceback (most recent call last):
  File "sample.py", line 10, in <module>
    rally = Rally('rally1.rallydev.com', apikey='<my api key>', workspace='<workspace name>', project='<project name>')
  File "C:\...\Python\Python36\lib\site-packages\pyral\restapi.py", line 259, in __init__
    self.contextHelper.check(self.server, wksp, proj, self.isolated_workspace)
  File "C:\...\Python\Python36\lib\site-packages\pyral\context.py", line 171, in check
    user_response = self._getUserInfo()
  File "C:\...\Python\Python36\lib\site-packages\pyral\context.py", line 276, in _getUserInfo
    raise RallyRESTAPIError(problem)
pyral.context.RallyRESTAPIError: Target Rally host: 'rally1.rallydev.com' non-existent or unreachable
Sujoy
  • 1,186
  • 1
  • 9
  • 12

2 Answers2

0

I answered on this post also, Rally host is non-existent or unreachable via pyral.

I just had to work through this issue and it was caused by my Python installation not using TLS 1.2. You will need to ensure the version of OpenSSL that is being used by your Python supports TLS 1.2.

To see the TLS version in use you can do this check:

python -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"

To see which OpenSSL is in use:

python -c "import ssl; print(ssl.OPENSSL_VERSION)"

I don't have the resolution to get OpenSSL updated to the right version. I am sure you will be able to find something for your own environment.

Michael B
  • 341
  • 1
  • 5
  • Thanks Michael for your help. But i already had TLS 1.2 and it was not the issue. I was able to resolve it after setting HTTPS proxy. I will post details below. – Sujoy Aug 22 '18 at 22:50
  • Great! I was short-sighted with not adding the Proxy information. Since mine was TLS 1.2 related. Glad it works for you! – Michael B Aug 23 '18 at 09:15
0

the issue was resolved after below steps -

  • go to pyral location
  • edit config.py file to include your rally log in credentials for fields USER_NAME and PASSWORD
  • open command prompt in admin mode and run command set HTTPS_PROXY==http://user:password@proxy.domain.com:port
  • for user id/psw, use your SSO credentials and not Rally credentials (if they are different).
  • Then run the file sample.py and it worked
Sujoy
  • 1,186
  • 1
  • 9
  • 12