-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathK8sStorageClass.py
43 lines (33 loc) · 1.3 KB
/
K8sStorageClass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.md', which is part of this source code package.
#
from kubernetes_py.K8sObject import K8sObject
from kubernetes_py.models.v1beta1.StorageClass import StorageClass
class K8sStorageClass(K8sObject):
def __init__(self, config=None, name=None):
super(K8sStorageClass, self).__init__(config=config, name=name, obj_type="StorageClass")
# ------------------------------------------------------------------------------------- override
def get(self):
self.model = StorageClass(self.get_model())
return self
def create(self):
super(K8sStorageClass, self).create()
self.get()
return self
def update(self):
super(K8sStorageClass, self).update()
self.get()
return self
def list(self, pattern=None, labels=None):
ls = super(K8sStorageClass, self).list(labels=labels)
sclasses = list(map(lambda x: StorageClass(x), ls))
if pattern is not None:
sclasses = list(filter(lambda x: pattern in x.name, sclasses))
k8s = []
for x in sclasses:
j = K8sStorageClass(config=self.config, name=x.name).from_model(m=x)
k8s.append(j)
return k8s