Repository: ambari Updated Branches: refs/heads/trunk 6701cfc17 -> 628812a16
AMBARI-11070. Ambari UI should not allow incorrect NN UI https configuration (mpapirkovskyy via srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/628812a1 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/628812a1 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/628812a1 Branch: refs/heads/trunk Commit: 628812a16025a23f21067d1d58b1666146141538 Parents: 6701cfc Author: Srimanth Gunturi <sgunt...@hortonworks.com> Authored: Tue May 12 14:38:57 2015 -0700 Committer: Srimanth Gunturi <sgunt...@hortonworks.com> Committed: Tue May 12 14:38:57 2015 -0700 ---------------------------------------------------------------------- .../stacks/HDP/2.2/services/stack_advisor.py | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/628812a1/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py index a7aa973..5a49fda 100644 --- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py +++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py @@ -19,6 +19,7 @@ limitations under the License. import math from math import floor +from urlparse import urlparse class HDP22StackAdvisor(HDP21StackAdvisor): @@ -637,6 +638,27 @@ class HDP22StackAdvisor(HDP21StackAdvisor): VALID_TRANSFER_PROTECTION_VALUES = ['authentication', 'integrity', 'privacy'] validationItems = [] + address_properties = [ + # "dfs.datanode.address", + # "dfs.datanode.http.address", + # "dfs.datanode.https.address", + # "dfs.datanode.ipc.address", + # "dfs.journalnode.http-address", + # "dfs.journalnode.https-address", + # "dfs.namenode.rpc-address", + # "dfs.namenode.secondary.http-address", + "dfs.namenode.http-address", + "dfs.namenode.https-address", + ] + #Validating *address properties for correct values + + for address_property in address_properties: + if address_property in hdfs_site: + value = hdfs_site[address_property] + if not is_valid_host_port_authority(value): + validationItems.append({"config-name" : address_property, "item" : + self.getErrorItem(address_property + " does not contain a valid host:port authority: " + value)}) + #Adding Ranger Plugin logic here ranger_plugin_properties = getSiteProperties(configurations, "ranger-hdfs-plugin-properties") ranger_plugin_enabled = ranger_plugin_properties['ranger-hdfs-plugin-enabled'] @@ -1000,3 +1022,15 @@ def is_number(s): pass return False + +def is_valid_host_port_authority(target): + has_scheme = "://" in target + if not has_scheme: + target = "dummyscheme://"+target + try: + result = urlparse(target) + if result.hostname is not None and result.port is not None: + return True + except ValueError: + pass + return False