From 876c7ff076bf16c4e626e0aaad46bf3bbdf79e0c Mon Sep 17 00:00:00 2001 From: John Griffith Date: Fri, 14 Aug 2015 13:03:21 -0600 Subject: [PATCH] Update SolidFire driver to pass newer flake8 Just an easy update of some things that newer versions of flake8 complains about. I've updated my env to flake8 2.1.0, and figured might as well fix these up rather ignore them. pep8 is 1.5.6 and pyflakes is at 0.8.1 Change-Id: I6d22fe95b67acddcece283e6dca6fe980904bfed --- cinder/volume/drivers/solidfire.py | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 8cefc45fc..26d68070a 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -1,5 +1,5 @@ -# Copyright 2013 SolidFire Inc # All Rights Reserved. +# Copyright 2013 SolidFire Inc # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -19,6 +19,7 @@ import random import socket import string import time +import warnings from oslo_config import cfg from oslo_log import log as logging @@ -27,8 +28,6 @@ from oslo_utils import timeutils from oslo_utils import units import requests from requests.packages.urllib3 import exceptions -import warnings - import six from cinder import context @@ -191,14 +190,14 @@ class SolidFireDriver(san.SanISCSIDriver): def _build_endpoint_info(self, **kwargs): endpoint = {} - endpoint['mvip'] =\ - kwargs.get('mvip', self.configuration.san_ip) - endpoint['login'] =\ - kwargs.get('login', self.configuration.san_login) - endpoint['passwd'] =\ - kwargs.get('passwd', self.configuration.san_password) - endpoint['port'] =\ - kwargs.get('port', self.configuration.sf_api_port) + endpoint['mvip'] = ( + kwargs.get('mvip', self.configuration.san_ip)) + endpoint['login'] = ( + kwargs.get('login', self.configuration.san_login)) + endpoint['passwd'] = ( + kwargs.get('passwd', self.configuration.san_password)) + endpoint['port'] = ( + kwargs.get('port', self.configuration.sf_api_port)) endpoint['url'] = 'https://%s:%s' % (endpoint['mvip'], endpoint['port']) @@ -359,7 +358,7 @@ class SolidFireDriver(san.SanISCSIDriver): def _do_clone_volume(self, src_uuid, src_project_id, vref): - """Create a clone of an existing volume or snapshot. """ + """Create a clone of an existing volume or snapshot.""" attributes = {} qos = {} @@ -562,18 +561,18 @@ class SolidFireDriver(san.SanISCSIDriver): # the optional properties.virtual_size is set on the image # before we get here virt_size = int(image_meta['properties'].get('virtual_size')) - min_sz_in_bytes =\ - math.ceil(virt_size / float(units.Gi)) * float(units.Gi) + min_sz_in_bytes = ( + math.ceil(virt_size / float(units.Gi)) * float(units.Gi)) min_sz_in_gig = math.ceil(min_sz_in_bytes / float(units.Gi)) attributes = {} attributes['image_info'] = {} - attributes['image_info']['image_updated_at'] =\ - image_meta['updated_at'].isoformat() - attributes['image_info']['image_name'] =\ - image_meta['name'] - attributes['image_info']['image_created_at'] =\ - image_meta['created_at'].isoformat() + attributes['image_info']['image_updated_at'] = ( + image_meta['updated_at'].isoformat()) + attributes['image_info']['image_name'] = ( + image_meta['name']) + attributes['image_info']['image_created_at'] = ( + image_meta['created_at'].isoformat()) attributes['image_info']['image_id'] = image_meta['id'] params = {'name': 'OpenStackIMG-%s' % image_id, 'accountID': self.template_account_id, @@ -636,8 +635,8 @@ class SolidFireDriver(san.SanISCSIDriver): return # Check updated_at field, delete copy and update if needed - if sf_vol['attributes']['image_info']['image_updated_at'] ==\ - image_meta['updated_at'].isoformat(): + if sf_vol['attributes']['image_info']['image_updated_at'] == ( + image_meta['updated_at'].isoformat()): return else: # Bummer, it's been updated, delete it @@ -978,8 +977,8 @@ class SolidFireDriver(san.SanISCSIDriver): LOG.error(_LE('Failed to get updated stats')) results = results['result']['clusterCapacity'] - free_capacity =\ - results['maxProvisionedSpace'] - results['usedSpace'] + free_capacity = ( + results['maxProvisionedSpace'] - results['usedSpace']) data = {} backend_name = self.configuration.safe_get('volume_backend_name') @@ -988,18 +987,18 @@ class SolidFireDriver(san.SanISCSIDriver): data["driver_version"] = self.VERSION data["storage_protocol"] = 'iSCSI' - data['total_capacity_gb'] =\ - float(results['maxProvisionedSpace'] / units.Gi) + data['total_capacity_gb'] = ( + float(results['maxProvisionedSpace'] / units.Gi)) data['free_capacity_gb'] = float(free_capacity / units.Gi) data['reserved_percentage'] = self.configuration.reserved_percentage data['QoS_support'] = True - data['compression_percent'] =\ - results['compressionPercent'] - data['deduplicaton_percent'] =\ - results['deDuplicationPercent'] - data['thin_provision_percent'] =\ - results['thinProvisioningPercent'] + data['compression_percent'] = ( + results['compressionPercent']) + data['deduplicaton_percent'] = ( + results['deDuplicationPercent']) + data['thin_provision_percent'] = ( + results['thinProvisioningPercent']) self.cluster_stats = data def attach_volume(self, context, volume, -- 2.45.2