summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/lib/volume.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-02-12 14:22:46 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-02-20 16:13:40 -0500
commit0e6d708c0278a2363fdf4161b949b944d29ea9d3 (patch)
tree7ae0a590566456a5696fe2efb26f51b36b0665aa /roles/lib_openshift/src/lib/volume.py
parentc9563d87c6de11503c5e8fe29a794b8c2846afcc (diff)
downloadopenshift-0e6d708c0278a2363fdf4161b949b944d29ea9d3.tar.gz
openshift-0e6d708c0278a2363fdf4161b949b944d29ea9d3.tar.bz2
openshift-0e6d708c0278a2363fdf4161b949b944d29ea9d3.tar.xz
openshift-0e6d708c0278a2363fdf4161b949b944d29ea9d3.zip
Adding router and registry to lib_openshift.
Diffstat (limited to 'roles/lib_openshift/src/lib/volume.py')
-rw-r--r--roles/lib_openshift/src/lib/volume.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/roles/lib_openshift/src/lib/volume.py b/roles/lib_openshift/src/lib/volume.py
new file mode 100644
index 000000000..dc07d3ce1
--- /dev/null
+++ b/roles/lib_openshift/src/lib/volume.py
@@ -0,0 +1,36 @@
+# pylint: skip-file
+
+class Volume(object):
+ ''' Class to wrap the oc command line tools '''
+ volume_mounts_path = {"pod": "spec.containers[0].volumeMounts",
+ "dc": "spec.template.spec.containers[0].volumeMounts",
+ "rc": "spec.template.spec.containers[0].volumeMounts",
+ }
+ volumes_path = {"pod": "spec.volumes",
+ "dc": "spec.template.spec.volumes",
+ "rc": "spec.template.spec.volumes",
+ }
+
+ @staticmethod
+ def create_volume_structure(volume_info):
+ ''' return a properly structured volume '''
+ volume_mount = None
+ volume = {'name': volume_info['name']}
+ if volume_info['type'] == 'secret':
+ volume['secret'] = {}
+ volume[volume_info['type']] = {'secretName': volume_info['secret_name']}
+ volume_mount = {'mountPath': volume_info['path'],
+ 'name': volume_info['name']}
+ elif volume_info['type'] == 'emptydir':
+ volume['emptyDir'] = {}
+ volume_mount = {'mountPath': volume_info['path'],
+ 'name': volume_info['name']}
+ elif volume_info['type'] == 'pvc':
+ volume['persistentVolumeClaim'] = {}
+ volume['persistentVolumeClaim']['claimName'] = volume_info['claimName']
+ volume['persistentVolumeClaim']['claimSize'] = volume_info['claimSize']
+ elif volume_info['type'] == 'hostpath':
+ volume['hostPath'] = {}
+ volume['hostPath']['path'] = volume_info['path']
+
+ return (volume, volume_mount)