You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/07/03 10:02:07 UTC
ambari git commit: AMBARI-12269 upgradeHelper implement template
feature for mapping (dsen)
Repository: ambari
Updated Branches:
refs/heads/trunk b1ea08ba2 -> 97a3097de
AMBARI-12269 upgradeHelper implement template feature for mapping (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/97a3097d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/97a3097d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/97a3097d
Branch: refs/heads/trunk
Commit: 97a3097de695a74428839d05a08866199b492b1f
Parents: b1ea08b
Author: Dmytro Sen <ds...@apache.org>
Authored: Fri Jul 3 11:01:59 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Fri Jul 3 11:01:59 2015 +0300
----------------------------------------------------------------------
ambari-server/src/main/python/upgradeHelper.py | 34 +++++++++++++++++++--
1 file changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/97a3097d/ambari-server/src/main/python/upgradeHelper.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/upgradeHelper.py b/ambari-server/src/main/python/upgradeHelper.py
index 24e3aec..a4d01da 100644
--- a/ambari-server/src/main/python/upgradeHelper.py
+++ b/ambari-server/src/main/python/upgradeHelper.py
@@ -78,6 +78,7 @@ Example:
"from-catalog": "test", (optional, require "to-catalog. Source of old-property1-name)
"to-catalog": "test", (optional, require "from-catalog. Target of new_property1_name)
"default": "default value", (optional, if set and old property not exists, new one would be created with default value)
+ "template": "yes", (optional, template parsing for default option)
"required-services": ["YARN"] (optional, process entry if services in the list existed on the cluster
}
}
@@ -433,6 +434,14 @@ class UpgradeCatalog(object):
return self._catalog_options[CatConst.CONFIG_TYPES]
return {}
+ @property
+ def action_handlers(self):
+ return self._handlers
+
+ @property
+ def tag_search_pattern(self):
+ return self._search_pattern
+
def __handle_remove_tag(self, catalog_item_name, catalog_property_item, properties):
"""
:type catalog_item_name str
@@ -621,10 +630,26 @@ class ServerConfigFactory(object):
:type catalog UpgradeCatalog
"""
for map_item in catalog.mapping.list():
- self._process_single_map_transformation(map_item, catalog.mapping.get(map_item))
+ self._process_single_map_transformation(catalog, map_item, catalog.mapping.get(map_item))
- def _process_single_map_transformation(self, map_item_name, map_property_item):
+ def _process_default_template_map_replacement(self, catalog, item):
+ """
+ :type catalog: UpgradeCatalog
+ :type item: dict
"""
+ if CatConst.VALUE_TEMPLATE_TAG in item and CatConst.TEMPLATE_HANDLER in catalog.action_handlers and\
+ CatConst.PROPERTY_DEFAULT in item and item[CatConst.VALUE_TEMPLATE_TAG] == CatConst.TRUE_TAG:
+
+ parsed_value = catalog.action_handlers[CatConst.TEMPLATE_HANDLER](
+ catalog,
+ catalog.tag_search_pattern.findall(item[CatConst.PROPERTY_DEFAULT]),
+ item[CatConst.PROPERTY_DEFAULT]
+ )
+ item[CatConst.PROPERTY_DEFAULT] = parsed_value
+
+ def _process_single_map_transformation(self, catalog, map_item_name, map_property_item):
+ """
+ :type catalog UpgradeCatalog
:type map_item_name str
:type map_property_item dict
"""
@@ -639,6 +664,9 @@ class ServerConfigFactory(object):
if CatConst.PROPERTY_MAP_TO in map_property_item:
new_property_name = map_property_item[CatConst.PROPERTY_MAP_TO]
+ # process template tag
+ self._process_default_template_map_replacement(catalog, map_property_item)
+
source_cfg_group = map_property_item[CatConst.PROPERTY_FROM_CATALOG] if CatConst.PROPERTY_FROM_CATALOG in map_property_item and\
map_property_item[CatConst.PROPERTY_FROM_CATALOG] != "" else None
target_cfg_group = map_property_item[CatConst.PROPERTY_TO_CATALOG] if CatConst.PROPERTY_TO_CATALOG in map_property_item and \
@@ -1024,7 +1052,7 @@ def get_ranger_host():
return ranger_host_list[0]
def get_ranger_service_details():
- server_cfg_factory = ServerConfigFactory()
+ server_cfg_factory = Options.server_config_factory
server_cfg_catalog = server_cfg_factory.get_config('admin-properties')
properties_latest = server_cfg_catalog.properties
data = {}