blob: b28b8690cba15fe1cde066e56f233f582e6c6c5a [file] [log] [blame]
Artem Panchenko0594cd72017-06-12 13:25:26 +03001# Copyright 2017 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13
14
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040015from kubernetes import client
16
Artem Panchenko0594cd72017-06-12 13:25:26 +030017from tcp_tests.managers.k8s.base import K8sBaseResource
18from tcp_tests.managers.k8s.base import K8sBaseManager
19
20
21class K8sPersistentVolumeClaim(K8sBaseResource):
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040022 resource_type = 'persistentvolumeclaim'
Artem Panchenko0594cd72017-06-12 13:25:26 +030023
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040024 def _read(self, **kwargs):
25 return self._manager.api.read_namespaced_persistent_volume_claim(
26 self.name, self.namespace, **kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030027
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040028 def _create(self, body, **kwargs):
29 return self._manager.api.create_namespaced_persistent_volume_claim(
30 self.namespace, body, **kwargs)
31
32 def _patch(self, body, **kwargs):
33 return self._manager.api.patch_namespaced_persistent_volume_claim(
34 self.name, self.namespace, body, **kwargs)
35
36 def _replace(self, body, **kwargs):
37 return self._manager.api.replace_namespaced_persistent_volume_claim(
38 self.name, self.namespace, body, **kwargs)
39
40 def _delete(self, **kwargs):
41 self._manager.api.delete_namespaced_persistent_volume_claim(
42 self.name, self.namespace, client.V1DeleteOptions(), **kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030043
44
45class K8sPersistentVolumeClaimManager(K8sBaseManager):
Artem Panchenko0594cd72017-06-12 13:25:26 +030046 resource_class = K8sPersistentVolumeClaim
47
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040048 @property
49 def api(self):
50 return self._cluster.api_core
Artem Panchenko0594cd72017-06-12 13:25:26 +030051
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040052 def _list(self, namespace, **kwargs):
Artem Panchenko0594cd72017-06-12 13:25:26 +030053 return self.api.list_namespaced_persistent_volume_claim(
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040054 namespace, **kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030055
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040056 def _list_all(self, **kwargs):
57 return self.api.list_persistent_volume_claim_for_all_namespaces(
58 **kwargs)