diff options
Diffstat (limited to 'roles/lib_openshift/library')
-rw-r--r-- | roles/lib_openshift/library/oc_scale.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py index 39afa6ba8..4e6717ec0 100644 --- a/roles/lib_openshift/library/oc_scale.py +++ b/roles/lib_openshift/library/oc_scale.py @@ -49,10 +49,10 @@ description: options: state: description: - - State represents whether to create, modify, delete, or list + - State represents whether to scale or list the current replicas required: true default: present - choices: ["present", "absent", "list"] + choices: ["present", "list"] aliases: [] kubeconfig: description: @@ -1191,6 +1191,7 @@ class OpenShiftCLIConfig(object): return rval + # pylint: disable=too-many-public-methods class DeploymentConfig(Yedit): ''' Class to wrap the oc command line tools ''' @@ -1251,7 +1252,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 @@ -1401,7 +1402,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 @@ -1411,7 +1412,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 @@ -1478,7 +1479,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 @@ -1497,27 +1498,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) @@ -1527,6 +1528,7 @@ spec: current_reps = self.get(DeploymentConfig.replicas_path) return not current_reps == replicas + # pylint: disable=too-many-public-methods class ReplicationController(DeploymentConfig): ''' Class to wrap the oc command line tools ''' @@ -1537,7 +1539,7 @@ 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) # pylint: disable=too-many-instance-attributes @@ -1580,9 +1582,13 @@ class OCScale(OpenShiftCLI): vol = self._get(self.kind, self.name) if vol['returncode'] == 0: if self.kind == 'dc': + # The resource returned from a query could be an rc or dc. + # pylint: disable=redefined-variable-type self.resource = DeploymentConfig(content=vol['results'][0]) vol['results'] = [self.resource.get_replicas()] if self.kind == 'rc': + # The resource returned from a query could be an rc or dc. + # pylint: disable=redefined-variable-type self.resource = ReplicationController(content=vol['results'][0]) vol['results'] = [self.resource.get_replicas()] |