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/resourcequotas.py b/tcp_tests/managers/k8s/resourcequotas.py
index 49d81d5..2edf00d 100644
--- a/tcp_tests/managers/k8s/resourcequotas.py
+++ b/tcp_tests/managers/k8s/resourcequotas.py
@@ -12,59 +12,45 @@
# 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 K8sResourceQuota(K8sBaseResource):
- """docstring for K8sResourceQuota"""
+ resource_type = 'resourcequota'
- def __repr__(self):
- return "<K8sResourceQuota: %s>" % self.name
+ def _read(self, **kwargs):
+ return self._manager.api.read_namespaced_resource_quota(
+ self.name, self.namespace, **kwargs)
- @property
- def name(self):
- return self.metadata.name
+ def _create(self, body, **kwargs):
+ return self._manager.api.create_namespaced_resource_quota(
+ self.namespace, body, **kwargs)
+
+ def _patch(self, body, **kwargs):
+ return self._manager.api.patch_namespaced_resource_quota(
+ self.name, self.namespace, body, **kwargs)
+
+ def _replace(self, body, **kwargs):
+ return self._manager.api.replace_namespaced_resource_quota(
+ self.name, self.namespace, body, **kwargs)
+
+ def _delete(self, **kwargs):
+ self._manager.api.delete_namespaced_resource_quota(
+ self.name, self.namespace, client.V1DeleteOptions(), **kwargs)
class K8sResourceQuotaManager(K8sBaseManager):
- """docstring for ClassName"""
-
resource_class = K8sResourceQuota
- def _get(self, name, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.read_namespaced_resource_quota(
- name=name, namespace=namespace, **kwargs)
+ @property
+ def api(self):
+ return self._cluster.api_core
- def _list(self, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.list_namespaced_resource_quota(
- namespace=namespace, **kwargs)
+ def _list(self, namespace, **kwargs):
+ return self.api.list_namespaced_resource_quota(namespace, **kwargs)
- def _create(self, body, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.create_namespaced_resource_quota(
- body=body, namespace=namespace, **kwargs)
-
- def _replace(self, body, name, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.replace_namespaced_resource_quota(
- body=body, name=name, namespace=namespace, **kwargs)
-
- def _delete(self, body, name, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.delete_namespaced_resource_quota(
- body=body, name=name, namespace=namespace, **kwargs)
-
- def _deletecollection(self, namespace=None, **kwargs):
- namespace = namespace or self.namespace
- return self.api.deletecollection_namespaced_resource_quota(
- namespace=namespace, **kwargs)
-
- def full_list(self, *args, **kwargs):
- lst = self._full_list(*args, **kwargs)
- return [self.resource_class(self, item) for item in lst.items]
-
- def _full_list(self, **kwargs):
- return self.api.list_resourse_quota(**kwargs)
+ def _list_all(self, **kwargs):
+ return self.api.list_resource_quota_for_all_namespaces(**kwargs)