-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathK8sVolumeMount.py
84 lines (60 loc) · 2.16 KB
/
K8sVolumeMount.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/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.
#
import json
import yaml
from kubernetes_py.models.v1.VolumeMount import VolumeMount
class K8sVolumeMount(object):
def __init__(self, name=None, mount_path=None, read_only=False, sub_path=None):
super(K8sVolumeMount, self).__init__()
self.model = VolumeMount()
if name is not None:
self.name = name
if mount_path is not None:
self.mount_path = mount_path
if read_only is not None:
self.read_only = read_only
if sub_path is not None:
self.sub_path = sub_path
# ------------------------------------------------------------------------------------- name
@property
def name(self):
return self.model.name
@name.setter
def name(self, name=None):
self.model.name = name
# ------------------------------------------------------------------------------------- mount_path
@property
def mount_path(self):
return self.model.mount_path
@mount_path.setter
def mount_path(self, mp=None):
self.model.mount_path = mp
# ------------------------------------------------------------------------------------- read_only
@property
def read_only(self):
return self.model.read_only
@read_only.setter
def read_only(self, ro=None):
self.model.read_only = ro
# ------------------------------------------------------------------------------------- sub_path
@property
def sub_path(self):
return self.model.sub_path
@sub_path.setter
def sub_path(self, sp=None):
self.model.sub_path = sp
# ------------------------------------------------------------------------------------- serialize
def serialize(self):
return self.model.serialize()
def as_json(self):
data = self.serialize()
dump = json.dumps(data, indent=4)
return dump
def as_yaml(self):
data = self.serialize()
dump = yaml.dump(data, default_flow_style=False)
return dump