From d49398cc978b00d19a66a5d3f6de1d4dd2986acf Mon Sep 17 00:00:00 2001 From: Trevor McKay Date: Tue, 24 Mar 2015 11:50:31 -0400 Subject: [PATCH] Implement job-types endpoint support methods for MapR plugin This change implements the optional methods in the Plugins SPI to support the job-types endpoint for the MapR plugin. Config hints at this point are unchanged. Additional work may be needed to provide config-hints specific to MapR plugin versions. Partial-Implements: blueprint edp-job-types-endpoint Change-Id: I8e3919060f12769ffa26d755cf3d8f7d2c839b2f --- sahara/plugins/mapr/abstract/version_handler.py | 8 ++++++++ sahara/plugins/mapr/base/base_version_handler.py | 6 ++++++ sahara/plugins/mapr/plugin.py | 12 ++++++++++++ .../mapr/versions/mapr_spark/version_handler.py | 6 ++++++ .../plugins/mapr/versions/v3_1_1/version_handler.py | 6 ++++++ 5 files changed, 38 insertions(+) diff --git a/sahara/plugins/mapr/abstract/version_handler.py b/sahara/plugins/mapr/abstract/version_handler.py index 7d35b4bd..0931184a 100644 --- a/sahara/plugins/mapr/abstract/version_handler.py +++ b/sahara/plugins/mapr/abstract/version_handler.py @@ -56,6 +56,14 @@ class AbstractVersionHandler(object): def get_edp_engine(self, cluster, job_type): return + @abc.abstractmethod + def get_edp_job_types(self): + return [] + + @abc.abstractmethod + def get_edp_config_hints(self, job_type): + return {} + @abc.abstractmethod def get_context(self, cluster, added=None, removed=None): return diff --git a/sahara/plugins/mapr/base/base_version_handler.py b/sahara/plugins/mapr/base/base_version_handler.py index a512e528..24d88789 100644 --- a/sahara/plugins/mapr/base/base_version_handler.py +++ b/sahara/plugins/mapr/base/base_version_handler.py @@ -40,6 +40,12 @@ class BaseVersionHandler(vh.AbstractVersionHandler): return edp.MapROozieJobEngine(cluster) return None + def get_edp_job_types(self): + return edp.MapROozieJobEngine.get_supported_job_types() + + def get_edp_config_hints(self, job_type): + return edp.MapROozieJobEngine.get_possible_job_config(job_type) + def get_services(self): return self._services diff --git a/sahara/plugins/mapr/plugin.py b/sahara/plugins/mapr/plugin.py index 3c7106ff..5223085c 100644 --- a/sahara/plugins/mapr/plugin.py +++ b/sahara/plugins/mapr/plugin.py @@ -68,6 +68,18 @@ class MapRPlugin(p.ProvisioningPluginBase): v_handler = self._get_handler(cluster.hadoop_version) return v_handler.get_edp_engine(cluster, job_type) + def get_edp_job_types(self, versions=[]): + res = {} + for vers in self.get_versions(): + if not versions or vers in versions: + vh = self._get_handler(vers) + res[vers] = vh.get_edp_job_types() + return res + + def get_edp_config_hints(self, job_type, version): + v_handler = self._get_handler(version) + return v_handler.get_edp_config_hints(job_type) + def get_open_ports(self, node_group): v_handler = self._get_handler(node_group.cluster.hadoop_version) return v_handler.get_open_ports(node_group) diff --git a/sahara/plugins/mapr/versions/mapr_spark/version_handler.py b/sahara/plugins/mapr/versions/mapr_spark/version_handler.py index 37a36c37..19bf763a 100755 --- a/sahara/plugins/mapr/versions/mapr_spark/version_handler.py +++ b/sahara/plugins/mapr/versions/mapr_spark/version_handler.py @@ -48,3 +48,9 @@ class VersionHandler(bvh.BaseVersionHandler): if job_type in edp_engine.MapRSparkEngine.get_supported_job_types(): return edp_engine.MapRSparkEngine(cluster) return None + + def get_edp_job_types(self): + return edp_engine.MapRSparkEngine.get_supported_job_types() + + def get_edp_config_hints(self, job_type): + return edp_engine.MapRSparkEngine.get_possible_job_config(job_type) diff --git a/sahara/plugins/mapr/versions/v3_1_1/version_handler.py b/sahara/plugins/mapr/versions/v3_1_1/version_handler.py index 351a7d35..ab1ea864 100644 --- a/sahara/plugins/mapr/versions/v3_1_1/version_handler.py +++ b/sahara/plugins/mapr/versions/v3_1_1/version_handler.py @@ -73,3 +73,9 @@ class VersionHandler(bvh.BaseVersionHandler): if job_type in edp.MapR3OozieJobEngine.get_supported_job_types(): return edp.MapR3OozieJobEngine(cluster) return None + + def get_edp_job_types(self): + return edp.MapR3OozieJobEngine.get_supported_job_types() + + def get_edp_config_hints(self, job_type): + return edp.MapR3OozieJobEngine.get_possible_job_config(job_type)