Skip to content

Commit 330a61c

Browse files
author
Jonathan Hurley
committedAug 16, 2017
AMBARI-21722 - Begin Using Service Versions In Python stack_feature Code (jonathanhurley)
1 parent 12c0588 commit 330a61c

File tree

73 files changed

+1578
-1013
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1578
-1013
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
"""
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
"""
20+
21+
from resource_management.libraries.script.script import Script
22+
23+
def get_component_repository_version(service_name, component_name = None):
24+
"""
25+
Gets the version associated with the specified component from the structure in the command.
26+
Every command should contain a mapping of service/component to the desired repository it's set
27+
to.
28+
29+
:service_name: the name of the service
30+
:component_name: the name of the component
31+
"""
32+
versions = _get_component_repositories()
33+
if versions is None:
34+
return None
35+
36+
if service_name not in versions:
37+
return None
38+
39+
component_versions = versions[service_name]
40+
if len(component_versions) == 0:
41+
return None
42+
43+
if component_name is None:
44+
for component in component_versions:
45+
return component_versions[component]
46+
47+
if not component_name in component_versions:
48+
return None
49+
50+
return component_versions[component_name]
51+
52+
53+
def _get_component_repositories():
54+
"""
55+
Gets an initialized dictionary from the value in componentVersionMap. This structure is
56+
sent on every command by Ambari and should contain each service & component's desired repository.
57+
:return:
58+
"""
59+
config = Script.get_config()
60+
if "componentVersionMap" not in config or config["componentVersionMap"] is "":
61+
return None
62+
63+
return config["componentVersionMap"]

‎ambari-common/src/main/python/resource_management/libraries/functions/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class StackFeature:
6565
SPARK_LIVY2 = "spark_livy2"
6666
STORM_KERBEROS = "storm_kerberos"
6767
STORM_AMS = "storm_ams"
68-
CREATE_KAFKA_BROKER_ID = "create_kafka_broker_id"
6968
KAFKA_LISTENERS = "kafka_listeners"
7069
KAFKA_KERBEROS = "kafka_kerberos"
7170
PIG_ON_TEZ = "pig_on_tez"

0 commit comments

Comments
 (0)
Please sign in to comment.