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
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
# Copyright 2013 SolidFire Inc
 | 
					 | 
				
			||||||
# All Rights Reserved.
 | 
					# All Rights Reserved.
 | 
				
			||||||
 | 
					# Copyright 2013 SolidFire Inc
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 | 
					#    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
 | 
					#    not use this file except in compliance with the License. You may obtain
 | 
				
			||||||
@@ -19,6 +19,7 @@ import random
 | 
				
			|||||||
import socket
 | 
					import socket
 | 
				
			||||||
import string
 | 
					import string
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
 | 
					import warnings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from oslo_config import cfg
 | 
					from oslo_config import cfg
 | 
				
			||||||
from oslo_log import log as logging
 | 
					from oslo_log import log as logging
 | 
				
			||||||
@@ -27,8 +28,6 @@ from oslo_utils import timeutils
 | 
				
			|||||||
from oslo_utils import units
 | 
					from oslo_utils import units
 | 
				
			||||||
import requests
 | 
					import requests
 | 
				
			||||||
from requests.packages.urllib3 import exceptions
 | 
					from requests.packages.urllib3 import exceptions
 | 
				
			||||||
import warnings
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import six
 | 
					import six
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cinder import context
 | 
					from cinder import context
 | 
				
			||||||
@@ -191,14 +190,14 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
    def _build_endpoint_info(self, **kwargs):
 | 
					    def _build_endpoint_info(self, **kwargs):
 | 
				
			||||||
        endpoint = {}
 | 
					        endpoint = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        endpoint['mvip'] =\
 | 
					        endpoint['mvip'] = (
 | 
				
			||||||
            kwargs.get('mvip', self.configuration.san_ip)
 | 
					            kwargs.get('mvip', self.configuration.san_ip))
 | 
				
			||||||
        endpoint['login'] =\
 | 
					        endpoint['login'] = (
 | 
				
			||||||
            kwargs.get('login', self.configuration.san_login)
 | 
					            kwargs.get('login', self.configuration.san_login))
 | 
				
			||||||
        endpoint['passwd'] =\
 | 
					        endpoint['passwd'] = (
 | 
				
			||||||
            kwargs.get('passwd', self.configuration.san_password)
 | 
					            kwargs.get('passwd', self.configuration.san_password))
 | 
				
			||||||
        endpoint['port'] =\
 | 
					        endpoint['port'] = (
 | 
				
			||||||
            kwargs.get('port', self.configuration.sf_api_port)
 | 
					            kwargs.get('port', self.configuration.sf_api_port))
 | 
				
			||||||
        endpoint['url'] = 'https://%s:%s' % (endpoint['mvip'],
 | 
					        endpoint['url'] = 'https://%s:%s' % (endpoint['mvip'],
 | 
				
			||||||
                                             endpoint['port'])
 | 
					                                             endpoint['port'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -359,7 +358,7 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
    def _do_clone_volume(self, src_uuid,
 | 
					    def _do_clone_volume(self, src_uuid,
 | 
				
			||||||
                         src_project_id,
 | 
					                         src_project_id,
 | 
				
			||||||
                         vref):
 | 
					                         vref):
 | 
				
			||||||
        """Create a clone of an existing volume or snapshot. """
 | 
					        """Create a clone of an existing volume or snapshot."""
 | 
				
			||||||
        attributes = {}
 | 
					        attributes = {}
 | 
				
			||||||
        qos = {}
 | 
					        qos = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -562,18 +561,18 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
        # the optional properties.virtual_size is set on the image
 | 
					        # the optional properties.virtual_size is set on the image
 | 
				
			||||||
        # before we get here
 | 
					        # before we get here
 | 
				
			||||||
        virt_size = int(image_meta['properties'].get('virtual_size'))
 | 
					        virt_size = int(image_meta['properties'].get('virtual_size'))
 | 
				
			||||||
        min_sz_in_bytes =\
 | 
					        min_sz_in_bytes = (
 | 
				
			||||||
            math.ceil(virt_size / float(units.Gi)) * float(units.Gi)
 | 
					            math.ceil(virt_size / float(units.Gi)) * float(units.Gi))
 | 
				
			||||||
        min_sz_in_gig = math.ceil(min_sz_in_bytes / float(units.Gi))
 | 
					        min_sz_in_gig = math.ceil(min_sz_in_bytes / float(units.Gi))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        attributes = {}
 | 
					        attributes = {}
 | 
				
			||||||
        attributes['image_info'] = {}
 | 
					        attributes['image_info'] = {}
 | 
				
			||||||
        attributes['image_info']['image_updated_at'] =\
 | 
					        attributes['image_info']['image_updated_at'] = (
 | 
				
			||||||
            image_meta['updated_at'].isoformat()
 | 
					            image_meta['updated_at'].isoformat())
 | 
				
			||||||
        attributes['image_info']['image_name'] =\
 | 
					        attributes['image_info']['image_name'] = (
 | 
				
			||||||
            image_meta['name']
 | 
					            image_meta['name'])
 | 
				
			||||||
        attributes['image_info']['image_created_at'] =\
 | 
					        attributes['image_info']['image_created_at'] = (
 | 
				
			||||||
            image_meta['created_at'].isoformat()
 | 
					            image_meta['created_at'].isoformat())
 | 
				
			||||||
        attributes['image_info']['image_id'] = image_meta['id']
 | 
					        attributes['image_info']['image_id'] = image_meta['id']
 | 
				
			||||||
        params = {'name': 'OpenStackIMG-%s' % image_id,
 | 
					        params = {'name': 'OpenStackIMG-%s' % image_id,
 | 
				
			||||||
                  'accountID': self.template_account_id,
 | 
					                  'accountID': self.template_account_id,
 | 
				
			||||||
@@ -636,8 +635,8 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Check updated_at field, delete copy and update if needed
 | 
					        # Check updated_at field, delete copy and update if needed
 | 
				
			||||||
        if sf_vol['attributes']['image_info']['image_updated_at'] ==\
 | 
					        if sf_vol['attributes']['image_info']['image_updated_at'] == (
 | 
				
			||||||
                image_meta['updated_at'].isoformat():
 | 
					                image_meta['updated_at'].isoformat()):
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            # Bummer, it's been updated, delete it
 | 
					            # Bummer, it's been updated, delete it
 | 
				
			||||||
@@ -978,8 +977,8 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
            LOG.error(_LE('Failed to get updated stats'))
 | 
					            LOG.error(_LE('Failed to get updated stats'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        results = results['result']['clusterCapacity']
 | 
					        results = results['result']['clusterCapacity']
 | 
				
			||||||
        free_capacity =\
 | 
					        free_capacity = (
 | 
				
			||||||
            results['maxProvisionedSpace'] - results['usedSpace']
 | 
					            results['maxProvisionedSpace'] - results['usedSpace'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        data = {}
 | 
					        data = {}
 | 
				
			||||||
        backend_name = self.configuration.safe_get('volume_backend_name')
 | 
					        backend_name = self.configuration.safe_get('volume_backend_name')
 | 
				
			||||||
@@ -988,18 +987,18 @@ class SolidFireDriver(san.SanISCSIDriver):
 | 
				
			|||||||
        data["driver_version"] = self.VERSION
 | 
					        data["driver_version"] = self.VERSION
 | 
				
			||||||
        data["storage_protocol"] = 'iSCSI'
 | 
					        data["storage_protocol"] = 'iSCSI'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        data['total_capacity_gb'] =\
 | 
					        data['total_capacity_gb'] = (
 | 
				
			||||||
            float(results['maxProvisionedSpace'] / units.Gi)
 | 
					            float(results['maxProvisionedSpace'] / units.Gi))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        data['free_capacity_gb'] = float(free_capacity / units.Gi)
 | 
					        data['free_capacity_gb'] = float(free_capacity / units.Gi)
 | 
				
			||||||
        data['reserved_percentage'] = self.configuration.reserved_percentage
 | 
					        data['reserved_percentage'] = self.configuration.reserved_percentage
 | 
				
			||||||
        data['QoS_support'] = True
 | 
					        data['QoS_support'] = True
 | 
				
			||||||
        data['compression_percent'] =\
 | 
					        data['compression_percent'] = (
 | 
				
			||||||
            results['compressionPercent']
 | 
					            results['compressionPercent'])
 | 
				
			||||||
        data['deduplicaton_percent'] =\
 | 
					        data['deduplicaton_percent'] = (
 | 
				
			||||||
            results['deDuplicationPercent']
 | 
					            results['deDuplicationPercent'])
 | 
				
			||||||
        data['thin_provision_percent'] =\
 | 
					        data['thin_provision_percent'] = (
 | 
				
			||||||
            results['thinProvisioningPercent']
 | 
					            results['thinProvisioningPercent'])
 | 
				
			||||||
        self.cluster_stats = data
 | 
					        self.cluster_stats = data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def attach_volume(self, context, volume,
 | 
					    def attach_volume(self, context, volume,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user