blob: 742493500a4025ce6f48bd2bed932cc5838ab8e7 [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 K8sPersistentVolume(K8sBaseResource):
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040022 resource_type = 'persistentvolume'
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_persistent_volume(self.name, **kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030026
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040027 def _create(self, body, **kwargs):
28 return self._manager.api.create_persistent_volume(body, **kwargs)
29
30 def _patch(self, body, **kwargs):
31 return self._manager.api.patch_persistent_volume(
32 self.name, body, **kwargs)
33
34 def _replace(self, body, **kwargs):
35 return self._manager.api.replace_persistent_volume(
36 self.name, body, **kwargs)
37
38 def _delete(self, **kwargs):
39 self._manager.api.delete_persistent_volume(
40 self.name, client.V1DeleteOptions(), **kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030041
42
43class K8sPersistentVolumeManager(K8sBaseManager):
Artem Panchenko0594cd72017-06-12 13:25:26 +030044 resource_class = K8sPersistentVolume
45
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040046 @property
47 def api(self):
48 return self._cluster.api_core
Artem Panchenko0594cd72017-06-12 13:25:26 +030049
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040050 def _list(self, namespace, **kwargs):
51 return self.api.list_persistent_volume(**kwargs)
Artem Panchenko0594cd72017-06-12 13:25:26 +030052
Vladimir Jigulin4ad52a82018-08-12 05:51:30 +040053 def _list_all(self, **kwargs):
54 return self._list(None, **kwargs)