Merge "NetApp SolidFire: Fix pylint issues" into stable/ussuri
This commit is contained in:
commit
90a07b6e73
|
@ -199,10 +199,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
'name': self.fake_sfsnap_name,
|
'name': self.fake_sfsnap_name,
|
||||||
'volumeID': 6}]
|
'volumeID': 6}]
|
||||||
|
|
||||||
def fake_init_cluster_pairs(*args, **kwargs):
|
def fake_issue_api_request(self, method, params, version='1.0',
|
||||||
return None
|
|
||||||
|
|
||||||
def fake_issue_api_request(obj, method, params, version='1.0',
|
|
||||||
endpoint=None):
|
endpoint=None):
|
||||||
if method == 'GetClusterCapacity':
|
if method == 'GetClusterCapacity':
|
||||||
data = {}
|
data = {}
|
||||||
|
@ -405,7 +402,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
# Crap, unimplemented API call in Fake
|
# Crap, unimplemented API call in Fake
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def fake_issue_api_request_fails(obj, method,
|
def fake_issue_api_request_fails(self, method,
|
||||||
params, version='1.0',
|
params, version='1.0',
|
||||||
endpoint=None):
|
endpoint=None):
|
||||||
response = {'error': {'code': 000,
|
response = {'error': {'code': 000,
|
||||||
|
@ -421,7 +418,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
'maxIOPS': 1000,
|
'maxIOPS': 1000,
|
||||||
'burstIOPS': 1000}
|
'burstIOPS': 1000}
|
||||||
|
|
||||||
def fake_volume_get(obj, key, default=None):
|
def fake_volume_get(self, key, default=None):
|
||||||
return {'qos': 'fast'}
|
return {'qos': 'fast'}
|
||||||
|
|
||||||
def fake_update_cluster_status(self):
|
def fake_update_cluster_status(self):
|
||||||
|
@ -1038,7 +1035,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
return_value=fake_no_volumes):
|
return_value=fake_no_volumes):
|
||||||
sfv.delete_snapshot(testsnap)
|
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):
|
endpoint=None):
|
||||||
EXPECTED_SIZE = 2 << 30 # 2147483648 size + increase
|
EXPECTED_SIZE = 2 << 30 # 2147483648 size + increase
|
||||||
|
|
||||||
|
@ -1050,12 +1047,12 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
if params.get('totalSize', None) != EXPECTED_SIZE:
|
if params.get('totalSize', None) != EXPECTED_SIZE:
|
||||||
msg = ('Error (%s) encountered during '
|
msg = ('Error (%s) encountered during '
|
||||||
'SolidFire API call.' % response['error']['name'])
|
'SolidFire API call.' % response['error']['name'])
|
||||||
raise exception.SolidFireAPIException(message=msg)
|
raise solidfire.SolidFireAPIException(message=msg)
|
||||||
|
|
||||||
if params.get('qos', None) != SolidFireVolumeTestCase.EXPECTED_QOS:
|
if params.get('qos', None) != SolidFireVolumeTestCase.EXPECTED_QOS:
|
||||||
msg = ('Error (%s) encountered during '
|
msg = ('Error (%s) encountered during '
|
||||||
'SolidFire API call.' % response['error']['name'])
|
'SolidFire API call.' % response['error']['name'])
|
||||||
raise exception.SolidFireAPIException(message=msg)
|
raise solidfire.SolidFireAPIException(message=msg)
|
||||||
|
|
||||||
return {'result': {}, 'id': 1}
|
return {'result': {}, 'id': 1}
|
||||||
|
|
||||||
|
@ -1202,7 +1199,9 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
sfv.active_cluster['svip'] = self.svip
|
sfv.active_cluster['svip'] = self.svip
|
||||||
|
|
||||||
mock_issue_api_request.reset_mock()
|
mock_issue_api_request.reset_mock()
|
||||||
|
# pylint: disable=assignment-from-no-return
|
||||||
updates = sfv.extend_volume(vol, vol.size + 10)
|
updates = sfv.extend_volume(vol, vol.size + 10)
|
||||||
|
# pylint: enable=assignment-from-no-return
|
||||||
self.assertIsNone(updates)
|
self.assertIsNone(updates)
|
||||||
|
|
||||||
modify_params = {
|
modify_params = {
|
||||||
|
@ -1752,7 +1751,14 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
'username': 'prefix-testprjid'}]
|
'username': 'prefix-testprjid'}]
|
||||||
|
|
||||||
def _fake_do_v_create(project_id, params):
|
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)
|
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
||||||
with mock.patch.object(sfv,
|
with mock.patch.object(sfv,
|
||||||
|
@ -1765,7 +1771,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
||||||
'_do_volume_create',
|
'_do_volume_create',
|
||||||
side_effect=_fake_do_v_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',
|
self.assertEqual('a720b3c0-d1f0-11e1-9b23-0800200c9a66',
|
||||||
sf_vol_object['attributes']['uuid'])
|
sf_vol_object['attributes']['uuid'])
|
||||||
self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77',
|
self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77',
|
||||||
|
|
|
@ -28,7 +28,6 @@ from oslo_utils import excutils
|
||||||
from oslo_utils import timeutils
|
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
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
|
@ -601,7 +600,9 @@ class SolidFireDriver(san.SanISCSIDriver):
|
||||||
payload = {'method': method, 'params': params}
|
payload = {'method': method, 'params': params}
|
||||||
url = '%s/json-rpc/%s/' % (endpoint['url'], version)
|
url = '%s/json-rpc/%s/' % (endpoint['url'], version)
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
|
warnings.simplefilter(
|
||||||
|
"ignore",
|
||||||
|
requests.packages.urllib3.exceptions.InsecureRequestWarning)
|
||||||
req = requests.post(url,
|
req = requests.post(url,
|
||||||
data=json.dumps(payload),
|
data=json.dumps(payload),
|
||||||
auth=(endpoint['login'], endpoint['passwd']),
|
auth=(endpoint['login'], endpoint['passwd']),
|
||||||
|
@ -2491,13 +2492,11 @@ class SolidFireDriver(san.SanISCSIDriver):
|
||||||
vol_updates['updates'].update(conn_info)
|
vol_updates['updates'].update(conn_info)
|
||||||
volume_updates.append(vol_updates)
|
volume_updates.append(vol_updates)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
volume_updates.append({'volume_id': v['id'],
|
volume_updates.append({'volume_id': v['id'],
|
||||||
'updates': {'status': 'error', }})
|
'updates': {'status': 'error', }})
|
||||||
LOG.error("Error trying to failover volume %s", v.id)
|
LOG.exception("Error trying to failover volume %s.",
|
||||||
msg = e.message if hasattr(e, 'message') else e
|
v['id'])
|
||||||
LOG.exception(msg)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
volume_updates.append({'volume_id': v['id'],
|
volume_updates.append({'volume_id': v['id'],
|
||||||
'updates': {'status': 'error', }})
|
'updates': {'status': 'error', }})
|
||||||
|
|
Loading…
Reference in New Issue