Ошибка соединения с IBM Analytics Engine
Я пытаюсь использовать python-ambariclient с IBM Analytics Engine:
$ pip install --quiet python-ambariclient
затем
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)
Тем не менее, я получаю проблему с подключением:
ConnectionError: HTTPConnectionPool (host = 'XXXXXX.bi.services.us-south.bluemix.net', port = 9443): превышено максимальное количество повторов с помощью url: /api/v1/cluster (вызвано ProtocolError('Соединение прервано.', RemoteDisconnected("Закрытое соединение удаленного конца без ответа",)))
1 ответ
Решение
Я пропустил протокол:
...
url = urlparse(AMBARI_URL)
HOST = url.hostname
PORT = url.port
PROTOCOL = url.scheme
...
ambari = Ambari(HOST, ... , protocol=PROTOCOL)
Полный код:
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)