Browse Source

Merge "NetApp SolidFire: Fix pylint issues" into stable/train

tags/15.4.1
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
06db60fbc6
2 changed files with 23 additions and 18 deletions
  1. +17
    -11
      cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py
  2. +6
    -7
      cinder/volume/drivers/solidfire.py

+ 17
- 11
cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py View File

@@ -179,10 +179,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'name': self.fake_sfsnap_name,
'volumeID': 6}]

def fake_init_cluster_pairs(*args, **kwargs):
return None

def fake_issue_api_request(obj, method, params, version='1.0',
def fake_issue_api_request(self, method, params, version='1.0',
endpoint=None):
if method is 'GetClusterCapacity':
data = {}
@@ -385,7 +382,7 @@ class SolidFireVolumeTestCase(test.TestCase):
# Crap, unimplemented API call in Fake
return None

def fake_issue_api_request_fails(obj, method,
def fake_issue_api_request_fails(self, method,
params, version='1.0',
endpoint=None):
response = {'error': {'code': 000,
@@ -401,7 +398,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'maxIOPS': 1000,
'burstIOPS': 1000}

def fake_volume_get(obj, key, default=None):
def fake_volume_get(self, key, default=None):
return {'qos': 'fast'}

def fake_update_cluster_status(self):
@@ -1018,7 +1015,7 @@ class SolidFireVolumeTestCase(test.TestCase):
return_value=fake_no_volumes):
sfv.delete_snapshot(testsnap)

def fake_ext_qos_issue_api_request(obj, method, params, version='1.0',
def fake_ext_qos_issue_api_request(self, method, params, version='1.0',
endpoint=None):
EXPECTED_SIZE = 2 << 30 # 2147483648 size + increase

@@ -1030,12 +1027,12 @@ class SolidFireVolumeTestCase(test.TestCase):
if params.get('totalSize', None) != EXPECTED_SIZE:
msg = ('Error (%s) encountered during '
'SolidFire API call.' % response['error']['name'])
raise exception.SolidFireAPIException(message=msg)
raise solidfire.SolidFireAPIException(message=msg)

if params.get('qos', None) != SolidFireVolumeTestCase.EXPECTED_QOS:
msg = ('Error (%s) encountered during '
'SolidFire API call.' % response['error']['name'])
raise exception.SolidFireAPIException(message=msg)
raise solidfire.SolidFireAPIException(message=msg)

return {'result': {}, 'id': 1}

@@ -1182,7 +1179,9 @@ class SolidFireVolumeTestCase(test.TestCase):
sfv.active_cluster['svip'] = self.svip

mock_issue_api_request.reset_mock()
# pylint: disable=assignment-from-no-return
updates = sfv.extend_volume(vol, vol.size + 10)
# pylint: enable=assignment-from-no-return
self.assertIsNone(updates)

modify_params = {
@@ -1732,7 +1731,14 @@ class SolidFireVolumeTestCase(test.TestCase):
'username': 'prefix-testprjid'}]

def _fake_do_v_create(project_id, params):
return project_id, params
cvol = {
'name': 'UUID-a720b3c0-d1f0-11e1-9b23-0800200c9a66',
'attributes': {
'uuid': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
'migration_uuid': 'b830b3c0-d1f0-11e1-9b23-1900200c9a77'
}
}
return cvol

sfv = solidfire.SolidFireDriver(configuration=self.configuration)
with mock.patch.object(sfv,
@@ -1745,7 +1751,7 @@ class SolidFireVolumeTestCase(test.TestCase):
'_do_volume_create',
side_effect=_fake_do_v_create):

project_id, sf_vol_object = sfv.create_volume(testvol)
sf_vol_object = sfv.create_volume(testvol)
self.assertEqual('a720b3c0-d1f0-11e1-9b23-0800200c9a66',
sf_vol_object['attributes']['uuid'])
self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77',


+ 6
- 7
cinder/volume/drivers/solidfire.py View File

@@ -28,7 +28,6 @@ from oslo_utils import excutils
from oslo_utils import timeutils
from oslo_utils import units
import requests
from requests.packages.urllib3 import exceptions
import six

from cinder import context
@@ -592,7 +591,9 @@ class SolidFireDriver(san.SanISCSIDriver):
payload = {'method': method, 'params': params}
url = '%s/json-rpc/%s/' % (endpoint['url'], version)
with warnings.catch_warnings():
warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
warnings.simplefilter(
"ignore",
requests.packages.urllib3.exceptions.InsecureRequestWarning)
req = requests.post(url,
data=json.dumps(payload),
auth=(endpoint['login'], endpoint['passwd']),
@@ -2485,13 +2486,11 @@ class SolidFireDriver(san.SanISCSIDriver):
LOG.debug("Updates for volume: %(id)s %(updates)s",
{'id': v.id, 'updates': vol_updates})

except Exception as e:
except Exception:
volume_updates.append({'volume_id': v['id'],
'updates': {'status': 'error', }})
LOG.error("Error trying to failover volume %s", v.id)
msg = e.message if hasattr(e, 'message') else e
LOG.exception(msg)

LOG.exception("Error trying to failover volume %s.",
v['id'])
else:
volume_updates.append({'volume_id': v['id'],
'updates': {'status': 'error', }})


Loading…
Cancel
Save