APIPythonOpen-Source Solutions

  • 1.  delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-05-2018 07:10:00 PM

    I am getting following Error: "AttributeError: 'list' object has no attribute 'rfind'
    "

    I am trying to connect engine, using delphixpy and get all group name. It is simple code but getting error.  code part is given below.
    --------------------------------------------------------------
       myConnection = DelphixEngine(myEnvironments, LOGIN, PASSWD, "DOMAIN")

        theDBs = database.get_all(myConnection)
        output2 += theDBs

    .

    .

    .

    print output2

    --------------------------------------------------------------

    Traceback (most recent call last):
      File "2.py", line 44, in <module>
        main()
      File "2.py", line 24, in main
        theDBs = database.get_all(myConnection)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/web/database/database.py", line 75, in get_all
        response = engine.get(url)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 280, in get
        lambda: self._http_session.get(path))
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 284, in _authenticate_and_perform
        self._create_session_if_needed()
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 248, in _create_session_if_needed
        self._create_session()
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 266, in _create_session
        self._delphix_session = create_session(EngineProxy())
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 48, in create_session
        return session.set(engine, api_session)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/web/session/session.py", line 36, in set
        response = engine.post(url, api_session.to_dict(dirty=True) if api_session else None)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 263, in post
        (_, _, body) = outer._http_session.post(url, data_to_post)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/delphix_engine.py", line 120, in post
        response = self._client.post(path, jsondata, headers)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/http_client.py", line 153, in post
        response = self._request("POST", path, data, headers)
      File "/usr/lib/python2.7/site-packages/delphixpy/v1_6_0/http_client.py", line 85, in _request
        timeout=HTTP_SOCKET_TIMEOUT * 60)
      File "/usr/lib64/python2.7/httplib.py", line 739, in __init__
        self._set_hostport(host, port)
      File "/usr/lib64/python2.7/httplib.py", line 758, in _set_hostport
        i = host.rfind(':')
    AttributeError: 'list' object has no attribute 'rfind'


    #dxToolkit


  • 2.  RE: delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-05-2018 07:55:00 PM
    Hi Chitranjan, What is “myEnvironments” in your code? The traceback looks like you supplied a list object, but the method is expecting a string (the hostname). Best Regards, Scott.


  • 3.  RE: delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-05-2018 10:31:00 PM
    Hi Scott, Thanks for response, yes “myEnvironments” is hostname.


  • 4.  RE: delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-06-2018 05:08:00 PM


    I see now I am getting connect error:
      File "/usr/lib64/python2.7/httplib.py", line 807, in connect
        self.timeout, self.source_address)
      File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
        raise err
    socket.error: [Errno 111] Connection refused

    =================================
    dxtools.conf
    {
            "data":[
          {
             "hostname" : "xyz@xyz.com",
             "ip_address" : "30.5.216.44",
             "username" : "delphix_admin",
             "password" : "ZZZZZZZ",
             "port" : "80",
             "default" : "false",
             "encrypted" : "false",
             "protocol" : "https",
             "timeout" : "60"
          }
            ]
    }



    =================================



  • 5.  RE: delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-10-2018 03:07:00 PM
    Hi Chitranjan,

    The error implies there is nothing listening on the socket address you have provided, are you certain your connection parameters are correct for your "myEnvironments" string? HTTP/HTTPS, IP Address, Port=80, etc?
    These do not appear to be correct for your server.

    Best Regards,

    Scott.


  • 6.  RE: delphixpy - AttributeError: 'list' object has no attribute 'rfind'

    Posted 09-10-2018 07:15:00 PM

    Hi Scott,
    thanks for response. I tested using hostname/user/password. All seems to be correct:
    ssh delphix_admin@<hostname>
    password:

    elabdelphix> exit

    -------------
    Now I am using port # 443 and protocols : https

    successfully tested with dxtoolkit

    Appliance            Status   Version  Total (GB) Used (GB)  Free (GB)  PctUsed(%) dSource# VDBs#    Total Ob
    -------------------- -------- -------- ---------- ---------- ---------- ---------- -------- -------- --------
    xxxxxxx.nyc-p02 UP       5.2.5.1  191.81     11.12      180.69     0.06       3        11       14
    -------------------
    But with python script , I am getting same:
    -----------------------------
      File "/usr/lib64/python2.7/httplib.py", line 1075, in _send_request
        self.endheaders(body)
      File "/usr/lib64/python2.7/httplib.py", line 1037, in endheaders
        self._send_output(message_body)
      File "/usr/lib64/python2.7/httplib.py", line 881, in _send_output
        self.send(msg)
      File "/usr/lib64/python2.7/httplib.py", line 843, in send
        self.connect()
      File "/usr/lib64/python2.7/httplib.py", line 824, in connect
        self.timeout, self.source_address)
      File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
        raise err
    socket.error: [Errno 111] Connection refused

    -----------------------------
    Please suggest , what else should I test ?
    Does delphixpy needs dxtools.conf file in same directory where my script is located?
    I have given hostname, login, passwd in the script itself...