summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-03-21 17:26:21 -0400
committerKenny Woodson <kwoodson@redhat.com>2017-03-21 17:26:21 -0400
commitc7124d09eb19a0f20d8e60ccf43eccbedf1e8c29 (patch)
tree8c78af295e6367aae318023df164da2b6ffa5bc6
parented210226e0996ebb6d31ff55185ad96357bf3014 (diff)
downloadopenshift-c7124d09eb19a0f20d8e60ccf43eccbedf1e8c29.tar.gz
openshift-c7124d09eb19a0f20d8e60ccf43eccbedf1e8c29.tar.bz2
openshift-c7124d09eb19a0f20d8e60ccf43eccbedf1e8c29.tar.xz
openshift-c7124d09eb19a0f20d8e60ccf43eccbedf1e8c29.zip
Adding configmap support.
-rw-r--r--roles/lib_openshift/library/oc_adm_registry.py19
-rw-r--r--roles/lib_openshift/library/oc_volume.py43
-rw-r--r--roles/lib_openshift/src/ansible/oc_volume.py4
-rw-r--r--roles/lib_openshift/src/class/oc_volume.py6
-rw-r--r--roles/lib_openshift/src/doc/volume6
-rw-r--r--roles/lib_openshift/src/lib/volume.py2
6 files changed, 55 insertions, 25 deletions
diff --git a/roles/lib_openshift/library/oc_adm_registry.py b/roles/lib_openshift/library/oc_adm_registry.py
index bbbe8652f..3a892971b 100644
--- a/roles/lib_openshift/library/oc_adm_registry.py
+++ b/roles/lib_openshift/library/oc_adm_registry.py
@@ -2060,9 +2060,8 @@ class Service(Yedit):
# -*- -*- -*- Begin included fragment: lib/volume.py -*- -*- -*-
-
class Volume(object):
- ''' Class to represent the volume object'''
+ ''' Class to represent an openshift volume object'''
volume_mounts_path = {"pod": "spec.containers[0].volumeMounts",
"dc": "spec.template.spec.containers[0].volumeMounts",
"rc": "spec.template.spec.containers[0].volumeMounts",
@@ -2077,24 +2076,28 @@ class Volume(object):
''' return a properly structured volume '''
volume_mount = None
volume = {'name': volume_info['name']}
- if volume_info['type'] == 'secret':
+ volume_type = volume_info['type'].lower()
+ if volume_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':
+ elif volume_type == 'emptydir':
volume['emptyDir'] = {}
volume_mount = {'mountPath': volume_info['path'],
'name': volume_info['name']}
- elif volume_info['type'] == 'pvc':
+ elif volume_type == 'pvc' or volume_type == 'persistentvolumeclaim':
volume['persistentVolumeClaim'] = {}
volume['persistentVolumeClaim']['claimName'] = volume_info['claimName']
volume['persistentVolumeClaim']['claimSize'] = volume_info['claimSize']
- volume_mount = {'mountPath': volume_info['path'],
- 'name': volume_info['name']}
- elif volume_info['type'] == 'hostpath':
+ elif volume_type == 'hostpath':
volume['hostPath'] = {}
volume['hostPath']['path'] = volume_info['path']
+ elif volume_type == 'configmap':
+ volume['configMap'] = {}
+ volume['configMap']['name'] = volume_info['configmap_name']
+ volume_mount = {'mountPath': volume_info['path'],
+ 'name': volume_info['name']}
return (volume, volume_mount)
diff --git a/roles/lib_openshift/library/oc_volume.py b/roles/lib_openshift/library/oc_volume.py
index dc7026901..e9e29468a 100644
--- a/roles/lib_openshift/library/oc_volume.py
+++ b/roles/lib_openshift/library/oc_volume.py
@@ -105,6 +105,7 @@ options:
- hostpath
- secret
- pvc
+ - configmap
aliases: []
mount_path:
description:
@@ -130,6 +131,12 @@ options:
required: false
default: None
aliases: []
+ configmap_name:
+ description:
+ - The name of the configmap
+ required: false
+ default: None
+ aliases: []
author:
- "Kenny Woodson <kwoodson@redhat.com>"
extends_documentation_fragment: []
@@ -1060,9 +1067,9 @@ class OpenShiftCLI(object):
if output_type == 'json':
try:
rval['results'] = json.loads(stdout)
- except ValueError as err:
- if "No JSON object could be decoded" in err.args:
- err = err.args
+ except ValueError as verr:
+ if "No JSON object could be decoded" in verr.args:
+ err = verr.args
elif output_type == 'raw':
rval['results'] = stdout
@@ -1733,9 +1740,8 @@ spec:
# -*- -*- -*- Begin included fragment: lib/volume.py -*- -*- -*-
-
class Volume(object):
- ''' Class to represent the volume object'''
+ ''' Class to represent an openshift volume object'''
volume_mounts_path = {"pod": "spec.containers[0].volumeMounts",
"dc": "spec.template.spec.containers[0].volumeMounts",
"rc": "spec.template.spec.containers[0].volumeMounts",
@@ -1750,24 +1756,28 @@ class Volume(object):
''' return a properly structured volume '''
volume_mount = None
volume = {'name': volume_info['name']}
- if volume_info['type'] == 'secret':
+ volume_type = volume_info['type'].lower()
+ if volume_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':
+ elif volume_type == 'emptydir':
volume['emptyDir'] = {}
volume_mount = {'mountPath': volume_info['path'],
'name': volume_info['name']}
- elif volume_info['type'] == 'pvc':
+ elif volume_type == 'pvc' or volume_type == 'persistentvolumeclaim':
volume['persistentVolumeClaim'] = {}
volume['persistentVolumeClaim']['claimName'] = volume_info['claimName']
volume['persistentVolumeClaim']['claimSize'] = volume_info['claimSize']
- volume_mount = {'mountPath': volume_info['path'],
- 'name': volume_info['name']}
- elif volume_info['type'] == 'hostpath':
+ elif volume_type == 'hostpath':
volume['hostPath'] = {}
volume['hostPath']['path'] = volume_info['path']
+ elif volume_type == 'configmap':
+ volume['configMap'] = {}
+ volume['configMap']['name'] = volume_info['configmap_name']
+ volume_mount = {'mountPath': volume_info['path'],
+ 'name': volume_info['name']}
return (volume, volume_mount)
@@ -1800,6 +1810,7 @@ class OCVolume(OpenShiftCLI):
secret_name,
claim_size,
claim_name,
+ configmap_name,
kubeconfig='/etc/origin/master/admin.kubeconfig',
verbose=False):
''' Constructor for OCVolume '''
@@ -1810,7 +1821,8 @@ class OCVolume(OpenShiftCLI):
'path': mount_path,
'type': mount_type,
'claimSize': claim_size,
- 'claimName': claim_name}
+ 'claimName': claim_name,
+ 'configmap_name': configmap_name}
self.volume, self.volume_mount = Volume.create_volume_structure(self.volume_info)
self.name = resource_name
self.namespace = namespace
@@ -1886,6 +1898,8 @@ class OCVolume(OpenShiftCLI):
# pvc
params['claim_size'],
params['claim_name'],
+ # configmap
+ params['configmap_name'],
kubeconfig=params['kubeconfig'],
verbose=params['debug'])
@@ -1964,7 +1978,6 @@ class OCVolume(OpenShiftCLI):
return {'failed': True, 'msg': 'Unknown state passed. {}'.format(state)}
-
# -*- -*- -*- End included fragment: class/oc_volume.py -*- -*- -*-
# -*- -*- -*- Begin included fragment: ansible/oc_volume.py -*- -*- -*-
@@ -1985,7 +1998,7 @@ def main():
vol_name=dict(default=None, type='str'),
name=dict(default=None, type='str'),
mount_type=dict(default=None,
- choices=['emptydir', 'hostpath', 'secret', 'pvc'],
+ choices=['emptydir', 'hostpath', 'secret', 'pvc', 'configmap'],
type='str'),
mount_path=dict(default=None, type='str'),
# secrets require a name
@@ -1993,6 +2006,8 @@ def main():
# pvc requires a size
claim_size=dict(default=None, type='str'),
claim_name=dict(default=None, type='str'),
+ # configmap requires a name
+ configmap_name=dict(default=None, type='str'),
),
supports_check_mode=True,
)
diff --git a/roles/lib_openshift/src/ansible/oc_volume.py b/roles/lib_openshift/src/ansible/oc_volume.py
index 955680543..660376d2f 100644
--- a/roles/lib_openshift/src/ansible/oc_volume.py
+++ b/roles/lib_openshift/src/ansible/oc_volume.py
@@ -17,7 +17,7 @@ def main():
vol_name=dict(default=None, type='str'),
name=dict(default=None, type='str'),
mount_type=dict(default=None,
- choices=['emptydir', 'hostpath', 'secret', 'pvc'],
+ choices=['emptydir', 'hostpath', 'secret', 'pvc', 'configmap'],
type='str'),
mount_path=dict(default=None, type='str'),
# secrets require a name
@@ -25,6 +25,8 @@ def main():
# pvc requires a size
claim_size=dict(default=None, type='str'),
claim_name=dict(default=None, type='str'),
+ # configmap requires a name
+ configmap_name=dict(default=None, type='str'),
),
supports_check_mode=True,
)
diff --git a/roles/lib_openshift/src/class/oc_volume.py b/roles/lib_openshift/src/class/oc_volume.py
index 3509e9178..5211a1afd 100644
--- a/roles/lib_openshift/src/class/oc_volume.py
+++ b/roles/lib_openshift/src/class/oc_volume.py
@@ -26,6 +26,7 @@ class OCVolume(OpenShiftCLI):
secret_name,
claim_size,
claim_name,
+ configmap_name,
kubeconfig='/etc/origin/master/admin.kubeconfig',
verbose=False):
''' Constructor for OCVolume '''
@@ -36,7 +37,8 @@ class OCVolume(OpenShiftCLI):
'path': mount_path,
'type': mount_type,
'claimSize': claim_size,
- 'claimName': claim_name}
+ 'claimName': claim_name,
+ 'configmap_name': configmap_name}
self.volume, self.volume_mount = Volume.create_volume_structure(self.volume_info)
self.name = resource_name
self.namespace = namespace
@@ -112,6 +114,8 @@ class OCVolume(OpenShiftCLI):
# pvc
params['claim_size'],
params['claim_name'],
+ # configmap
+ params['configmap_name'],
kubeconfig=params['kubeconfig'],
verbose=params['debug'])
diff --git a/roles/lib_openshift/src/doc/volume b/roles/lib_openshift/src/doc/volume
index 8112c79c2..1d04afeef 100644
--- a/roles/lib_openshift/src/doc/volume
+++ b/roles/lib_openshift/src/doc/volume
@@ -80,6 +80,12 @@ options:
required: false
default: None
aliases: []
+ configmap_name:
+ description:
+ - The name of the configmap
+ required: false
+ default: None
+ aliases: []
author:
- "Kenny Woodson <kwoodson@redhat.com>"
extends_documentation_fragment: []
diff --git a/roles/lib_openshift/src/lib/volume.py b/roles/lib_openshift/src/lib/volume.py
index b0e48523f..c049c8b49 100644
--- a/roles/lib_openshift/src/lib/volume.py
+++ b/roles/lib_openshift/src/lib/volume.py
@@ -36,7 +36,7 @@ class Volume(object):
volume['hostPath']['path'] = volume_info['path']
elif volume_type == 'configmap':
volume['configMap'] = {}
- volume['configMap']['name'] = volume_info['name']
+ volume['configMap']['name'] = volume_info['configmap_name']
volume_mount = {'mountPath': volume_info['path'],
'name': volume_info['name']}