Skip to content

Commit 5fe290b

Browse files
author
Donald Hunter
committed
Port to Python 3
CDH support removed due to obsolete cm-api
1 parent ac57d51 commit 5fe290b

File tree

6 files changed

+10
-126
lines changed

6 files changed

+10
-126
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
FROM centos:7.6.1810
22

3-
RUN yum install -y python-devel epel-release
4-
RUN yum install -y python2-pip cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-plain libffi-devel openssl-devel gcc gcc-c++
3+
RUN yum install -y epel-release
4+
RUN yum install -y python36-devel python36-pip cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-plain libffi-devel openssl-devel gcc gcc-c++
55

66
COPY api/src/main/resources /deployment-manager/
77

88
WORKDIR /deployment-manager
99

10-
RUN pip install -r requirements.txt
10+
RUN pip3 install -r requirements.txt

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
NAME=deployment-manager
2-
VERSION=0.1.3
3-
REGISTRY=containers.cisco.com/donaldh
1+
NAME=platform-deployment-manager
2+
VERSION=release5.0
3+
REGISTRY=pnda
44

55
build: ## Build the docker image
66
docker build -t "$(NAME):$(VERSION)" -f Dockerfile .

api/src/main/resources/authorizer_local.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def authorize(self, identity, resource, action):
5757
authorize = True
5858
logging.debug("authorize: %s for %s", authorize, grant_rule)
5959
break
60-
except KeyError, ex:
60+
except KeyError as ex:
6161
logging.warning("missing attribute %s", ex)
6262

6363
if not authorize:

api/src/main/resources/deployer_utils.py

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import os
2424
import tarfile
25-
import StringIO
25+
from io import StringIO
2626
import logging
2727
import traceback
2828
import time
@@ -32,18 +32,6 @@
3232
import spur
3333
from pywebhdfs.webhdfs import PyWebHdfsClient
3434

35-
from cm_api.api_client import ApiResource
36-
37-
38-
def connect_cm(cm_api, cm_username, cm_password):
39-
api = ApiResource(
40-
cm_api,
41-
version=6,
42-
username=cm_username,
43-
password=cm_password)
44-
return api
45-
46-
4735
def get_nameservice(cm_host, cluster_name, service_name, user_name='admin', password='admin'):
4836
request_url = 'http://%s:7180/api/v11/clusters/%s/services/%s/nameservices' % (cm_host,
4937
cluster_name,
@@ -66,7 +54,7 @@ def update_hadoop_env(env):
6654
tmp_env = dict(env)
6755
logging.debug('Updating environment descriptor')
6856
if env['hadoop_distro'] == 'CDH':
69-
fill_hadoop_env_cdh(tmp_env)
57+
logging.error('CDH is not a supported hadoop distribution')
7058
elif env['hadoop_distro'] == 'HDP':
7159
fill_hadoop_env_hdp(tmp_env)
7260
else:
@@ -184,105 +172,6 @@ def fill_hadoop_env_hdp(env):
184172
env['hive_server'] = '%s' % component_host(component_detail)
185173
env['hive_port'] = '10001'
186174

187-
def fill_hadoop_env_cdh(env):
188-
# pylint: disable=E1103
189-
api = connect_cm(
190-
env['hadoop_manager_host'],
191-
env['hadoop_manager_username'],
192-
env['hadoop_manager_password'])
193-
194-
for cluster_detail in api.get_all_clusters():
195-
cluster_name = cluster_detail.name
196-
break
197-
198-
logging.debug('getting %s', cluster_name)
199-
env['cm_status_links'] = {}
200-
env.pop('yarn_node_managers', None)
201-
env.pop('yarn_resource_manager_host', None)
202-
env.pop('zookeeper_quorum', None)
203-
204-
cluster = api.get_cluster(cluster_name)
205-
for service in cluster.get_all_services():
206-
env['cm_status_links']['%s' % service.name] = service.serviceUrl
207-
if service.type == "HDFS":
208-
nameservice = get_nameservice(env['hadoop_manager_host'], cluster_name,
209-
service.name,
210-
user_name=env['hadoop_manager_username'],
211-
password=env['hadoop_manager_password'])
212-
if nameservice:
213-
env['name_node'] = 'hdfs://%s' % nameservice
214-
for role in service.get_all_roles():
215-
if not nameservice and role.type == "NAMENODE":
216-
env['name_node'] = 'hdfs://%s:8020' % api.get_host(role.hostRef.hostId).hostname
217-
if role.type == "HTTPFS":
218-
env['webhdfs_host'] = '%s' % api.get_host(role.hostRef.hostId).hostname
219-
env['webhdfs_port'] = '14000'
220-
elif service.type == "YARN":
221-
for role in service.get_all_roles():
222-
if role.type == "RESOURCEMANAGER":
223-
if 'yarn_resource_manager_host' in env:
224-
rm_instance = '_backup'
225-
else:
226-
rm_instance = ''
227-
env['yarn_resource_manager_host%s' % rm_instance] = '%s' % api.get_host(role.hostRef.hostId).hostname
228-
env['yarn_resource_manager_port%s' % rm_instance] = '8088'
229-
env['yarn_resource_manager_mr_port%s' % rm_instance] = '8032'
230-
if role.type == "NODEMANAGER":
231-
if 'yarn_node_managers' in env:
232-
env['yarn_node_managers'] = '%s,%s' % (env['yarn_node_managers'], api.get_host(role.hostRef.hostId).hostname)
233-
else:
234-
env['yarn_node_managers'] = '%s' % api.get_host(
235-
role.hostRef.hostId).hostname
236-
elif service.type == "MAPREDUCE":
237-
for role in service.get_all_roles():
238-
if role.type == "JOBTRACKER":
239-
env['job_tracker'] = '%s:8021' % api.get_host(role.hostRef.hostId).hostname
240-
break
241-
elif service.type == "ZOOKEEPER":
242-
for role in service.get_all_roles():
243-
if role.type == "SERVER":
244-
if 'zookeeper_quorum' in env:
245-
env['zookeeper_quorum'] += ',%s' % api.get_host(role.hostRef.hostId).hostname
246-
else:
247-
env['zookeeper_quorum'] = '%s' % api.get_host(role.hostRef.hostId).hostname
248-
env['zookeeper_port'] = '2181'
249-
elif service.type == "HBASE":
250-
for role in service.get_all_roles():
251-
if role.type == "HBASERESTSERVER":
252-
env['hbase_rest_server'] = '%s' % api.get_host(role.hostRef.hostId).hostname
253-
env['hbase_rest_port'] = '20550'
254-
elif role.type == "HBASETHRIFTSERVER":
255-
env['hbase_thrift_server'] = '%s' % api.get_host(role.hostRef.hostId).hostname
256-
elif service.type == "OOZIE":
257-
for role in service.get_all_roles():
258-
if role.type == "OOZIE_SERVER":
259-
env['oozie_uri'] = 'http://%s:11000/oozie' % api.get_host(role.hostRef.hostId).hostname
260-
break
261-
elif service.type == "HIVE":
262-
for role in service.get_all_roles():
263-
if role.type == "HIVESERVER2":
264-
env['hive_server'] = '%s' % api.get_host(role.hostRef.hostId).hostname
265-
env['hive_port'] = '10000'
266-
break
267-
elif service.type == "IMPALA":
268-
for role in service.get_all_roles():
269-
if role.type == "IMPALAD":
270-
env['impala_host'] = '%s' % api.get_host(role.hostRef.hostId).hostname
271-
env['impala_port'] = '21050'
272-
break
273-
elif service.type == "KUDU":
274-
for role in service.get_all_roles():
275-
if role.type == "KUDU_MASTER":
276-
env['kudu_host'] = '%s' % api.get_host(role.hostRef.hostId).hostname
277-
env['kudu_port'] = '7051'
278-
break
279-
elif service.type == "HUE":
280-
for role in service.get_all_roles():
281-
if role.type == "HUE_SERVER":
282-
env['hue_host'] = '%s' % api.get_host(role.hostRef.hostId).hostname
283-
env['hue_port'] = '8888'
284-
break
285-
286175
def tree(archive_filepath):
287176
file_handle = file(archive_filepath, 'rb')
288177
tar_file = tarfile.open(None, 'r', file_handle)
@@ -299,7 +188,6 @@ def tree(archive_filepath):
299188

300189
return root
301190

302-
303191
def canonicalize(path):
304192
path = path.replace('\\', '/')
305193
path = path.replace('//', '/')

api/src/main/resources/deployment_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _get_saved_package_data(self, package):
131131
package_metadata = None
132132
if self._package_registrar.package_exists(package):
133133
package_metadata = self._package_registrar.get_package_metadata(package)
134-
print package_metadata
134+
logging.debug(package_metadata)
135135
package_owner = package_metadata['metadata']['user']
136136
package_exists = True
137137
return package_owner, package_exists, package_metadata

api/src/main/resources/requirements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
argparse==1.2.1
2-
backports-abc==0.5
3-
backports.ssl-match-hostname==3.5.0.1
42
certifi==2017.4.17
53
cffi==1.9.1
6-
cm-api==14.0.0
74
cryptography==1.7.1
85
enum34==1.1.6
96
happybase==1.0.0
@@ -27,4 +24,3 @@ thrift==0.9.3
2724
thriftpy==0.3.9
2825
tornado==4.4.2
2926
tornado-cors==0.6.0
30-
wsgiref==0.1.2

0 commit comments

Comments
 (0)