From 453b56bf074cf9acbc71bc8626c4688e17020cd9 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Tue, 24 Jan 2017 17:08:31 -0500 Subject: Fixing tests and linting. --- roles/lib_openshift/src/lib/deploymentconfig.py | 26 ++++++++++++---------- .../lib_openshift/src/lib/replicationcontroller.py | 4 +++- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'roles/lib_openshift/src/lib') diff --git a/roles/lib_openshift/src/lib/deploymentconfig.py b/roles/lib_openshift/src/lib/deploymentconfig.py index c0e9af0a1..e060d3707 100644 --- a/roles/lib_openshift/src/lib/deploymentconfig.py +++ b/roles/lib_openshift/src/lib/deploymentconfig.py @@ -1,4 +1,6 @@ # pylint: skip-file +# flake8: noqa + # pylint: disable=too-many-public-methods class DeploymentConfig(Yedit): @@ -60,7 +62,7 @@ spec: volume_mounts_path = "spec.template.spec.containers[0].volumeMounts" def __init__(self, content=None): - ''' Constructor for OpenshiftOC ''' + ''' Constructor for deploymentconfig ''' if not content: content = DeploymentConfig.default_deployment_config @@ -210,7 +212,7 @@ spec: exist_volumes = self.get_volumes() del_idx = None for idx, exist_volume in enumerate(exist_volumes): - if exist_volume.has_key('name') and exist_volume['name'] == volume['name']: + if 'name' in exist_volume and exist_volume['name'] == volume['name']: del_idx = idx break @@ -220,7 +222,7 @@ spec: del_idx = None for idx, exist_volume_mount in enumerate(exist_volume_mounts): - if exist_volume_mount.has_key('name') and exist_volume_mount['name'] == volume['name']: + if 'name' in exist_volume_mount and exist_volume_mount['name'] == volume['name']: del_idx = idx break @@ -287,7 +289,7 @@ spec: # update the volume mount for exist_vol_mount in exist_volume_mounts: if exist_vol_mount['name'] == volume_mount['name']: - if exist_vol_mount.has_key('mountPath') and \ + if 'mountPath' in exist_vol_mount and \ str(exist_vol_mount['mountPath']) != str(volume_mount['mountPath']): exist_vol_mount['mountPath'] = volume_mount['mountPath'] modified = True @@ -306,27 +308,27 @@ spec: results = [] results.append(exist_volume['name'] == volume['name']) - if volume.has_key('secret'): - results.append(exist_volume.has_key('secret')) + if 'secret' in volume: + results.append('secret' in exist_volume) results.append(exist_volume['secret']['secretName'] == volume['secret']['secretName']) results.append(exist_volume_mount['name'] == volume_mount['name']) results.append(exist_volume_mount['mountPath'] == volume_mount['mountPath']) - elif volume.has_key('emptyDir'): + elif 'emptyDir' in volume: results.append(exist_volume_mount['name'] == volume['name']) results.append(exist_volume_mount['mountPath'] == volume_mount['mountPath']) - elif volume.has_key('persistentVolumeClaim'): + elif 'persistentVolumeClaim' in volume: pvc = 'persistentVolumeClaim' - results.append(exist_volume.has_key(pvc)) + results.append(pvc in exist_volume) if results[-1]: results.append(exist_volume[pvc]['claimName'] == volume[pvc]['claimName']) - if volume[pvc].has_key('claimSize'): + if 'claimSize' in volume[pvc]: results.append(exist_volume[pvc]['claimSize'] == volume[pvc]['claimSize']) - elif volume.has_key('hostpath'): - results.append(exist_volume.has_key('hostPath')) + elif 'hostpath' in volume: + results.append('hostPath' in exist_volume) results.append(exist_volume['hostPath']['path'] == volume_mount['mountPath']) return not all(results) diff --git a/roles/lib_openshift/src/lib/replicationcontroller.py b/roles/lib_openshift/src/lib/replicationcontroller.py index 7dafc60f1..ae585a986 100644 --- a/roles/lib_openshift/src/lib/replicationcontroller.py +++ b/roles/lib_openshift/src/lib/replicationcontroller.py @@ -1,4 +1,6 @@ # pylint: skip-file +# flake8: noqa + # pylint: disable=too-many-public-methods class ReplicationController(DeploymentConfig): @@ -10,5 +12,5 @@ class ReplicationController(DeploymentConfig): volume_mounts_path = "spec.template.spec.containers[0].volumeMounts" def __init__(self, content): - ''' Constructor for OpenshiftOC ''' + ''' Constructor for ReplicationController ''' super(ReplicationController, self).__init__(content=content) -- cgit v1.2.3