From d3d119e8d6f37141d9e928d6a85451e091985c51 Mon Sep 17 00:00:00 2001 From: "Li, Chen" Date: Mon, 13 Apr 2015 16:53:38 +0800 Subject: [PATCH] Fix strange check in code Check like "if ${process} not in [0, 1]" has been used in code, they should be changed to "if ${process} > 1" Change-Id: If7606d1da58a1e962035051c9538e8df925422c1 --- sahara/plugins/cdh/v5/validation.py | 10 +++++----- sahara/plugins/cdh/v5_3_0/validation.py | 18 +++++++++--------- sahara/plugins/vanilla/hadoop2/validation.py | 10 +++++----- .../plugins/vanilla/v1_2_1/versionhandler.py | 6 +++--- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sahara/plugins/cdh/v5/validation.py b/sahara/plugins/cdh/v5/validation.py index e05b3807..be76aae0 100644 --- a/sahara/plugins/cdh/v5/validation.py +++ b/sahara/plugins/cdh/v5/validation.py @@ -38,12 +38,12 @@ def validate_cluster_creating(cluster): snn_count) rm_count = _get_inst_count(cluster, 'YARN_RESOURCEMANAGER') - if rm_count not in [0, 1]: + if rm_count > 1: raise ex.InvalidComponentCountException('YARN_RESOURCEMANAGER', _('0 or 1'), rm_count) hs_count = _get_inst_count(cluster, 'YARN_JOBHISTORY') - if hs_count not in [0, 1]: + if hs_count > 1: raise ex.InvalidComponentCountException('YARN_JOBHISTORY', _('0 or 1'), hs_count) @@ -59,7 +59,7 @@ def validate_cluster_creating(cluster): oo_count = _get_inst_count(cluster, 'OOZIE_SERVER') dn_count = _get_inst_count(cluster, 'HDFS_DATANODE') - if oo_count not in [0, 1]: + if oo_count > 1: raise ex.InvalidComponentCountException('OOZIE_SERVER', _('0 or 1'), oo_count) @@ -97,12 +97,12 @@ def validate_cluster_creating(cluster): 'HIVE_METASTORE', required_by='WEBHCAT') hue_count = _get_inst_count(cluster, 'HUE_SERVER') - if hue_count not in [0, 1]: + if hue_count > 1: raise ex.InvalidComponentCountException('HUE_SERVER', _('0 or 1'), hue_count) shs_count = _get_inst_count(cluster, 'SPARK_YARN_HISTORY_SERVER') - if shs_count not in [0, 1]: + if shs_count > 1: raise ex.InvalidComponentCountException('SPARK_YARN_HISTORY_SERVER', _('0 or 1'), shs_count) if shs_count and not rm_count: diff --git a/sahara/plugins/cdh/v5_3_0/validation.py b/sahara/plugins/cdh/v5_3_0/validation.py index 5ce1d9de..aabc39a8 100644 --- a/sahara/plugins/cdh/v5_3_0/validation.py +++ b/sahara/plugins/cdh/v5_3_0/validation.py @@ -38,12 +38,12 @@ def validate_cluster_creating(cluster): snn_count) rm_count = _get_inst_count(cluster, 'YARN_RESOURCEMANAGER') - if rm_count not in [0, 1]: + if rm_count > 1: raise ex.InvalidComponentCountException('YARN_RESOURCEMANAGER', _('0 or 1'), rm_count) hs_count = _get_inst_count(cluster, 'YARN_JOBHISTORY') - if hs_count not in [0, 1]: + if hs_count > 1: raise ex.InvalidComponentCountException('YARN_JOBHISTORY', _('0 or 1'), hs_count) @@ -59,7 +59,7 @@ def validate_cluster_creating(cluster): oo_count = _get_inst_count(cluster, 'OOZIE_SERVER') dn_count = _get_inst_count(cluster, 'HDFS_DATANODE') - if oo_count not in [0, 1]: + if oo_count > 1: raise ex.InvalidComponentCountException('OOZIE_SERVER', _('0 or 1'), oo_count) @@ -97,12 +97,12 @@ def validate_cluster_creating(cluster): 'HIVE_METASTORE', required_by='HIVE_WEBHCAT') hue_count = _get_inst_count(cluster, 'HUE_SERVER') - if hue_count not in [0, 1]: + if hue_count > 1: raise ex.InvalidComponentCountException('HUE_SERVER', _('0 or 1'), hue_count) shs_count = _get_inst_count(cluster, 'SPARK_YARN_HISTORY_SERVER') - if shs_count not in [0, 1]: + if shs_count > 1: raise ex.InvalidComponentCountException('SPARK_YARN_HISTORY_SERVER', _('0 or 1'), shs_count) if shs_count and not rm_count: @@ -139,7 +139,7 @@ def validate_cluster_creating(cluster): 'HDFS_DATANODE', required_by='FLUME_AGENT') snt_count = _get_inst_count(cluster, 'SENTRY_SERVER') - if snt_count not in [0, 1]: + if snt_count > 1: raise ex.InvalidComponentCountException('SENTRY_SERVER', _('0 or 1'), snt_count) if snt_count == 1: @@ -160,7 +160,7 @@ def validate_cluster_creating(cluster): 'ZOOKEEPER', required_by='SOLR_SERVER') s2s_count = _get_inst_count(cluster, 'SQOOP_SERVER') - if s2s_count not in [0, 1]: + if s2s_count > 1: raise ex.InvalidComponentCountException('SQOOP_SERVER', _('0 or 1'), s2s_count) if s2s_count == 1: @@ -192,10 +192,10 @@ def validate_cluster_creating(cluster): ics_count = _get_inst_count(cluster, 'IMPALA_CATALOGSERVER') iss_count = _get_inst_count(cluster, 'IMPALA_STATESTORE') id_count = _get_inst_count(cluster, 'IMPALAD') - if ics_count not in [0, 1]: + if ics_count > 1: raise ex.InvalidComponentCountException('IMPALA_CATALOGSERVER', _('0 or 1'), ics_count) - if iss_count not in [0, 1]: + if iss_count > 1: raise ex.InvalidComponentCountException('IMPALA_STATESTORE', _('0 or 1'), iss_count) if ics_count == 1: diff --git a/sahara/plugins/vanilla/hadoop2/validation.py b/sahara/plugins/vanilla/hadoop2/validation.py index 4e5491c5..2df19b24 100644 --- a/sahara/plugins/vanilla/hadoop2/validation.py +++ b/sahara/plugins/vanilla/hadoop2/validation.py @@ -27,17 +27,17 @@ def validate_cluster_creating(pctx, cluster): raise ex.InvalidComponentCountException('namenode', 1, nn_count) snn_count = _get_inst_count(cluster, 'secondarynamenode') - if snn_count not in [0, 1]: + if snn_count > 1: raise ex.InvalidComponentCountException('secondarynamenode', _('0 or 1'), snn_count) rm_count = _get_inst_count(cluster, 'resourcemanager') - if rm_count not in [0, 1]: + if rm_count > 1: raise ex.InvalidComponentCountException('resourcemanager', _('0 or 1'), rm_count) hs_count = _get_inst_count(cluster, 'historyserver') - if hs_count not in [0, 1]: + if hs_count > 1: raise ex.InvalidComponentCountException('historyserver', _('0 or 1'), hs_count) @@ -49,7 +49,7 @@ def validate_cluster_creating(pctx, cluster): oo_count = _get_inst_count(cluster, 'oozie') dn_count = _get_inst_count(cluster, 'datanode') - if oo_count not in [0, 1]: + if oo_count > 1: raise ex.InvalidComponentCountException('oozie', _('0 or 1'), oo_count) if oo_count == 1: @@ -73,7 +73,7 @@ def validate_cluster_creating(pctx, cluster): 'dfs.replication.')) hive_count = _get_inst_count(cluster, 'hiveserver') - if hive_count not in [0, 1]: + if hive_count > 1: raise ex.InvalidComponentCountException('hive', _('0 or 1'), hive_count) diff --git a/sahara/plugins/vanilla/v1_2_1/versionhandler.py b/sahara/plugins/vanilla/v1_2_1/versionhandler.py index 8bcd53f1..3d5e72ab 100644 --- a/sahara/plugins/vanilla/v1_2_1/versionhandler.py +++ b/sahara/plugins/vanilla/v1_2_1/versionhandler.py @@ -67,14 +67,14 @@ class VersionHandler(avm.AbstractVersionHandler): jt_count = sum([ng.count for ng in utils.get_node_groups(cluster, "jobtracker")]) - if jt_count not in [0, 1]: + if jt_count > 1: raise ex.InvalidComponentCountException("jobtracker", _('0 or 1'), jt_count) oozie_count = sum([ng.count for ng in utils.get_node_groups(cluster, "oozie")]) - if oozie_count not in [0, 1]: + if oozie_count > 1: raise ex.InvalidComponentCountException("oozie", _('0 or 1'), oozie_count) @@ -96,7 +96,7 @@ class VersionHandler(avm.AbstractVersionHandler): raise ex.RequiredServiceMissingException( "jobtracker", required_by="hive") - if hive_count not in [0, 1]: + if hive_count > 1: raise ex.InvalidComponentCountException("hive", _('0 or 1'), hive_count)