Skip to content

Commit

Permalink
Add example plugin implementation to interface.py
Browse files Browse the repository at this point in the history
Signed-off-by: Toni Finger <[email protected]>
  • Loading branch information
tonifinger committed Nov 6, 2024
1 parent 73edf99 commit 90d958e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
31 changes: 30 additions & 1 deletion Tests/kaas/plugin/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ class KubernetesClusterPlugin():
An abstract base class for custom Kubernetes cluster provider plugins.
It represents an interface class from which the api provider-specific
plugins must be derived as child classes
To implement fill the methods `create_cluster` and `delete_cluster` with
api provider-specific functionalities for creating and deleting clusters.
- Implement `create_cluster` and `delete_cluster` methods
- Create `__init__(self, config_file=None)` method to handle api specific
configurations.
Example:
.. code:: python
from interface import KubernetesClusterPlugin
from apiX_library import cluster_api_class as ClusterAPI
class PluginX(KubernetesClusterPlugin):
def __init__(self, config_file=None):
self.config = config_file
def create_cluster(self):
self.cluster = ClusterAPI(name=cluster_name, image=cluster_image)
self.cluster.create(self.config)
kubeconfig_filepath = str(self.cluster.kubeconfig_path.resolve())
return self.kubeconfig_filepath
def delete_cluster(self):
self.cluster = ClusterAPI(cluster_name)
self.cluster.delete()
..
"""

@abstractmethod
Expand All @@ -22,5 +51,5 @@ def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig_fi
def delete_cluster(self, cluster_name=None):
"""
This method is to be called in order to unprovision a cluster
:param: cluster_uuid:
:param: cluster_name:
"""
4 changes: 2 additions & 2 deletions Tests/kaas/plugin/plugin_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class PluginStatic(KubernetesClusterPlugin):
using a kubeconfig file
"""

def _create_cluster(self):
def create_cluster(self):
self.kubeconfig = self.kubeconfig

def _delete_cluster(self):
def delete_cluster(self):
pass

0 comments on commit 90d958e

Please sign in to comment.