Skip to content

Commit 90d958e

Browse files
committed
Add example plugin implementation to interface.py
Signed-off-by: Toni Finger <[email protected]>
1 parent 73edf99 commit 90d958e

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

Tests/kaas/plugin/interface.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ class KubernetesClusterPlugin():
66
An abstract base class for custom Kubernetes cluster provider plugins.
77
It represents an interface class from which the api provider-specific
88
plugins must be derived as child classes
9+
10+
To implement fill the methods `create_cluster` and `delete_cluster` with
11+
api provider-specific functionalities for creating and deleting clusters.
12+
13+
- Implement `create_cluster` and `delete_cluster` methods
14+
- Create `__init__(self, config_file=None)` method to handle api specific
15+
configurations.
16+
17+
Example:
18+
.. code:: python
19+
20+
from interface import KubernetesClusterPlugin
21+
from apiX_library import cluster_api_class as ClusterAPI
22+
23+
class PluginX(KubernetesClusterPlugin):
24+
25+
def __init__(self, config_file=None):
26+
self.config = config_file
27+
28+
def create_cluster(self):
29+
self.cluster = ClusterAPI(name=cluster_name, image=cluster_image)
30+
self.cluster.create(self.config)
31+
kubeconfig_filepath = str(self.cluster.kubeconfig_path.resolve())
32+
return self.kubeconfig_filepath
33+
34+
def delete_cluster(self):
35+
self.cluster = ClusterAPI(cluster_name)
36+
self.cluster.delete()
37+
..
938
"""
1039

1140
@abstractmethod
@@ -22,5 +51,5 @@ def create_cluster(self, cluster_name="scs-cluster", version=None, kubeconfig_fi
2251
def delete_cluster(self, cluster_name=None):
2352
"""
2453
This method is to be called in order to unprovision a cluster
25-
:param: cluster_uuid:
54+
:param: cluster_name:
2655
"""

Tests/kaas/plugin/plugin_static.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class PluginStatic(KubernetesClusterPlugin):
77
using a kubeconfig file
88
"""
99

10-
def _create_cluster(self):
10+
def create_cluster(self):
1111
self.kubeconfig = self.kubeconfig
1212

13-
def _delete_cluster(self):
13+
def delete_cluster(self):
1414
pass

0 commit comments

Comments
 (0)