ConnectionError connecting to IBM Analytics Engine

140 views Asked by At

I'm trying to use the python-ambariclient with IBM Analytics Engine:

$ pip install --quiet python-ambariclient

Then

from future.standard_library import install_aliases
install_aliases()
from urllib.parse import urlparse

import json
vcap = json.load(open('vcap.json'))

USER         = vcap['cluster']['user']
PASSWORD     = vcap['cluster']['password']
AMBARI_URL   = vcap['cluster']['service_endpoints']['ambari_console']
CLUSTER_ID   = vcap['cluster']['cluster_id']

url = urlparse(AMBARI_URL)

HOST = url.hostname
PORT = url.port

from ambariclient.client import Ambari
ambari = Ambari(HOST, port=PORT, username=USER, password=PASSWORD)

for cluster in ambari.clusters:
    print('> ' + cluster.cluster_name)

However, I'm getting a connection issue:

ConnectionError: HTTPConnectionPool(host='XXXXXX.bi.services.us-south.bluemix.net', port=9443): Max retries exceeded with url: /api/v1/clusters (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)))

1

There are 1 answers

0
Chris Snow On BEST ANSWER

I was missing the protocol:

...
url = urlparse(AMBARI_URL)

HOST = url.hostname
PORT = url.port
PROTOCOL = url.scheme  
...

ambari = Ambari(HOST, ... , protocol=PROTOCOL)

The full code:

from future.standard_library import install_aliases
install_aliases()
from urllib.parse import urlparse

import json
vcap = json.load(open('vcap.json'))

USER         = vcap['cluster']['user']
PASSWORD     = vcap['cluster']['password']
AMBARI_URL   = vcap['cluster']['service_endpoints']['ambari_console']
CLUSTER_ID   = vcap['cluster']['cluster_id']

url = urlparse(AMBARI_URL)

HOST = url.hostname
PORT = url.port
PROTOCOL = url.scheme

from ambariclient.client import Ambari
ambari = Ambari(HOST, port=PORT, username=USER, password=PASSWORD, protocol=PROTOCOL)

for cluster in ambari.clusters:
    print('> ' + cluster.cluster_name)