Refactoring of k8s manager and tests
Changes:
- Official kubernetes python lib
- Rewrite k8s api wrapper in OOP manner
- Use api where its possible instead of cli
- Remove virtlet code because its can be replaced with pod api
- Remove unused/oudated manager code
- Remove bug workaround in k8s upgrade template
- Remove netchecker obsolete code
- Remove unfinished test_rbd_flexvolume_driver
Change-Id: I446a240123282196a6ba54f588aea84791f175ba
Related-PROD: PROD-21700
diff --git a/tcp_tests/managers/k8s/persistentvolumes.py b/tcp_tests/managers/k8s/persistentvolumes.py
index 8ab7ec2..7424935 100644
--- a/tcp_tests/managers/k8s/persistentvolumes.py
+++ b/tcp_tests/managers/k8s/persistentvolumes.py
@@ -12,46 +12,43 @@
# License for the specific language governing permissions and limitations
+from kubernetes import client
+
from tcp_tests.managers.k8s.base import K8sBaseResource
from tcp_tests.managers.k8s.base import K8sBaseManager
class K8sPersistentVolume(K8sBaseResource):
- """docstring for K8sPersistentVolume"""
+ resource_type = 'persistentvolume'
- def __repr__(self):
- return "<K8sPersistentVolume: %s>" % self.name
+ def _read(self, **kwargs):
+ return self._manager.api.read_persistent_volume(self.name, **kwargs)
- @property
- def name(self):
- return self.metadata.name
+ def _create(self, body, **kwargs):
+ return self._manager.api.create_persistent_volume(body, **kwargs)
+
+ def _patch(self, body, **kwargs):
+ return self._manager.api.patch_persistent_volume(
+ self.name, body, **kwargs)
+
+ def _replace(self, body, **kwargs):
+ return self._manager.api.replace_persistent_volume(
+ self.name, body, **kwargs)
+
+ def _delete(self, **kwargs):
+ self._manager.api.delete_persistent_volume(
+ self.name, client.V1DeleteOptions(), **kwargs)
class K8sPersistentVolumeManager(K8sBaseManager):
- """docstring for ClassName"""
-
resource_class = K8sPersistentVolume
- def _get(self, name, **kwargs):
- return self.api.read_namespaced_persistent_volume(
- name=name, **kwargs)
+ @property
+ def api(self):
+ return self._cluster.api_core
- def _list(self, **kwargs):
- return self.api.list_namespaced_persistent_volume(
- **kwargs)
+ def _list(self, namespace, **kwargs):
+ return self.api.list_persistent_volume(**kwargs)
- def _create(self, body, **kwargs):
- return self.api.create_namespaced_persistent_volume(
- body, **kwargs)
-
- def _replace(self, body, name, **kwargs):
- return self.api.replace_namespaced_persistent_volume(
- body=body, name=name, **kwargs)
-
- def _delete(self, body, name, **kwargs):
- return self.api.delete_namespaced_persistent_volume(
- body=body, name=name, **kwargs)
-
- def _deletecollection(self, **kwargs):
- return self.api.deletecollection_namespaced_persistent_volume(
- **kwargs)
+ def _list_all(self, **kwargs):
+ return self._list(None, **kwargs)