From 08233d358bd0eaf21879473c9b40787d0fac4e0e Mon Sep 17 00:00:00 2001 From: Trevor McKay Date: Tue, 17 Mar 2015 18:14:28 -0400 Subject: [PATCH] Implement job-types endpoint support methods for CDH plugin This change implements the optional methods in the Plugins SPI to support the job-types endpoint for the CDH plugin. Config hints at this point are unchanged. Additional work may be needed to provide config-hints specific to CDH plugin versions. Partial-Implements: blueprint edp-job-types-endpoint Change-Id: I7cc9ab01d8e23bdd3c240a2962140460bad2d33a --- sahara/plugins/cdh/abstractversionhandler.py | 8 ++++++++ sahara/plugins/cdh/plugin.py | 13 +++++++++++++ sahara/plugins/cdh/v5/versionhandler.py | 6 ++++++ sahara/plugins/cdh/v5_3_0/versionhandler.py | 6 ++++++ 4 files changed, 33 insertions(+) diff --git a/sahara/plugins/cdh/abstractversionhandler.py b/sahara/plugins/cdh/abstractversionhandler.py index 02697234..5ba3cb36 100644 --- a/sahara/plugins/cdh/abstractversionhandler.py +++ b/sahara/plugins/cdh/abstractversionhandler.py @@ -57,6 +57,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_open_ports(self, node_group): return diff --git a/sahara/plugins/cdh/plugin.py b/sahara/plugins/cdh/plugin.py index d1ee6ee7..f406e65f 100644 --- a/sahara/plugins/cdh/plugin.py +++ b/sahara/plugins/cdh/plugin.py @@ -71,6 +71,19 @@ class CDHPluginProvider(p.ProvisioningPluginBase): return self._get_version_handler( cluster.hadoop_version).get_edp_engine(cluster, job_type) + def get_edp_job_types(self, versions=[]): + res = {} + for vers in self.version_factory.get_versions(): + if not versions or vers in versions: + vh = self.version_factory.get_version_handler(vers) + res[vers] = vh.get_edp_job_types() + return res + + def get_edp_config_hints(self, job_type, version): + version_handler = ( + self.version_factory.get_version_handler(version)) + return version_handler.get_edp_config_hints(job_type) + def get_open_ports(self, node_group): return self._get_version_handler( node_group.cluster.hadoop_version).get_open_ports(node_group) diff --git a/sahara/plugins/cdh/v5/versionhandler.py b/sahara/plugins/cdh/v5/versionhandler.py index 6f4bfedb..e2e1d421 100644 --- a/sahara/plugins/cdh/v5/versionhandler.py +++ b/sahara/plugins/cdh/v5/versionhandler.py @@ -100,5 +100,11 @@ class VersionHandler(avm.AbstractVersionHandler): return edp_engine.EdpOozieEngine(cluster) return None + def get_edp_job_types(self): + return edp_engine.EdpOozieEngine.get_supported_job_types() + + def get_edp_config_hints(self, job_type): + return edp_engine.EdpOozieEngine.get_possible_job_config(job_type) + def get_open_ports(self, node_group): return dp.get_open_ports(node_group) diff --git a/sahara/plugins/cdh/v5_3_0/versionhandler.py b/sahara/plugins/cdh/v5_3_0/versionhandler.py index 666f1a41..8111c60f 100644 --- a/sahara/plugins/cdh/v5_3_0/versionhandler.py +++ b/sahara/plugins/cdh/v5_3_0/versionhandler.py @@ -109,5 +109,11 @@ class VersionHandler(avm.AbstractVersionHandler): return edp_engine.EdpOozieEngine(cluster) return None + def get_edp_job_types(self): + return edp_engine.EdpOozieEngine.get_supported_job_types() + + def get_edp_config_hints(self, job_type): + return edp_engine.EdpOozieEngine.get_possible_job_config(job_type) + def get_open_ports(self, node_group): return dp.get_open_ports(node_group)