Created on 08-03-2018 03:47 AM - edited 09-16-2022 08:50 AM
Hi,
import re from cloudera.director.latest import ClustersApi from cloudera.director.latest import EnvironmentsApi from cloudera.director.latest import DeploymentsApi from cloudera.director.common.client import ApiClient from cloudera.director.latest import AuthenticationApi from cloudera.director.latest.models import Login from cm_api.api_client import ApiResource, ApiException, API_CURRENT_VERSION import ssl from socket import socket from subprocess import Popen, PIPE from time import sleep username='admin' password='admin' client = ApiClient('http://localhost:7189', tls_enabled=False, cafile=None, hostname_verification_enabled=True) auth = AuthenticationApi(client) auth.login(Login(username=username, password=password)) def getClusterInstance( apiclient ): cdhenv=EnvironmentsApi(apiclient) cdhenvName = cdhenv.list()[0] print('CDH Environment '+cdhenvName) cdhdep=DeploymentsApi(apiclient) cdhdepName = cdhdep.list( cdhenvName )[0] c=ClustersApi(apiclient) clName = c.list( cdhenvName, cdhdepName )[0] ci = c.get( cdhenvName , cdhdepName , clName ) return ( ci, clName ) ( ci, clName ) = getClusterInstance( client ) -> Here it fails
Created 08-03-2018 10:08 AM
The problem was that the response contained an unicode string, and client.py from commnon tried to cast it to str.
The hotfix:
awk 'NR==230{print " if objClass in [str]:\n return objClass(obj.encode(\"utf-8\"))"}1' /usr/lib/python2.7/site-packages/cloudera/director/common/client.py | sudo tee /usr/lib/python2.7/site-packages/cloudera/director/common/client.py
Created 08-03-2018 10:08 AM
The problem was that the response contained an unicode string, and client.py from commnon tried to cast it to str.
The hotfix:
awk 'NR==230{print " if objClass in [str]:\n return objClass(obj.encode(\"utf-8\"))"}1' /usr/lib/python2.7/site-packages/cloudera/director/common/client.py | sudo tee /usr/lib/python2.7/site-packages/cloudera/director/common/client.py
Created 08-06-2018 06:16 AM
Hi Tomas79,
Thanks for bringing up this issue! I've filed an internal trouble ticket for this failure to handle Unicode, so that we can address it in a future release.
Created 08-06-2018 07:34 AM