Merge "Reduce use of eval()"

This commit is contained in:
Jenkins
2016-01-21 23:54:50 +00:00
committed by Gerrit Code Review
4 changed files with 9 additions and 5 deletions

View File

@@ -175,7 +175,7 @@ class SSHPoolTestCase(test.TestCase):
@mock.patch('six.moves.builtins.open')
@mock.patch('paramiko.SSHClient')
def test_closed_reopened_ssh_connections(self, mock_sshclient, mock_open):
mock_sshclient.return_value = eval('FakeSSHClient')()
mock_sshclient.return_value = FakeSSHClient()
sshpool = ssh_utils.SSHPool("127.0.0.1", 22, 10,
"test",
password="test",

View File

@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import ast
import inspect
import os.path
@@ -1329,7 +1330,7 @@ class EMCVMAXCommon(object):
self.conn = self._get_ecom_connection()
if isinstance(loc, six.string_types):
name = eval(loc)
name = ast.literal_eval(loc)
keys = name['keybindings']
systemName = keys['SystemName']
@@ -3952,7 +3953,7 @@ class EMCVMAXCommon(object):
version = None
try:
if isinstance(loc, six.string_types):
name = eval(loc)
name = ast.literal_eval(loc)
version = name['version']
except KeyError:
pass

View File

@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import ast
from oslo_log import log as logging
import six
@@ -203,7 +205,7 @@ class EMCVMAXFCDriver(driver.FibreChannelDriver):
data = {'driver_volume_type': 'fibre_channel',
'data': {}}
loc = volume['provider_location']
name = eval(loc)
name = ast.literal_eval(loc)
storage_system = name['keybindings']['SystemName']
LOG.debug("Start FC detach process for volume: %(volume)s.",
{'volume': volume['name']})

View File

@@ -19,6 +19,7 @@
"""
Cinder Volume driver for Fujitsu ETERNUS DX S3 series.
"""
import ast
import base64
import hashlib
import six
@@ -1383,7 +1384,7 @@ class FJDXCommon(object):
volumename = self._create_volume_name(volume['id'])
try:
location = eval(volume['provider_location'])
location = ast.literal_eval(volume['provider_location'])
classname = location['classname']
bindings = location['keybindings']