From 1c06d57ea6adad929b08d810405f6480e5752296 Mon Sep 17 00:00:00 2001 From: gfm Date: Thu, 5 Mar 2015 19:02:11 -0600 Subject: [PATCH] Fix some issues with pool name sent to SVC Add quotes around a pool name so a pool name with imbedded spaces is a single argument when it arrives on the SVC What is happening today is SVC returns a usage error and fails the request. Update unit tests to verify quotes where added. Closes-Bug: 1422903 Change-Id: Ic96304b907913dd8b11a583f03d169f314d851de --- cinder/tests/test_storwize_svc.py | 18 +++++++++++++++--- cinder/volume/drivers/ibm/storwize_svc/ssh.py | 11 ++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index 6150705ef..eaede2f68 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -386,11 +386,15 @@ class StorwizeSVCManagementSimulator: if 'obj' not in kwargs: return self._print_info_cmd(rows=rows, **kwargs) else: - if kwargs['obj'] == self._flags['storwize_svc_volpool_name']: + pool_name = kwargs['obj'].strip('\'\"') + if pool_name == kwargs['obj']: + raise exception.InvalidInput( + reason=_('obj missing quotes %s') % kwargs['obj']) + elif pool_name == self._flags['storwize_svc_volpool_name']: row = rows[1] - elif kwargs['obj'] == 'openstack2': + elif pool_name == 'openstack2': row = rows[2] - elif kwargs['obj'] == 'openstack3': + elif pool_name == 'openstack3': row = rows[3] else: return self._errors['CMMVC5754E'] @@ -625,6 +629,11 @@ port_speed!N/A 'compressed_copy': volume_info['compressed_copy']} volume_info['copies'] = {'0': vol_cp} + mdiskgrp = kwargs['mdiskgrp'].strip('\'\"') + if mdiskgrp == kwargs['mdiskgrp']: + raise exception.InvalidInput( + reason=_('mdiskgrp missing quotes %s') % kwargs['mdiskgrp']) + if volume_info['name'] in self._volumes_list: return self._errors['CMMVC6035E'] else: @@ -1433,6 +1442,9 @@ port_speed!N/A if 'mdiskgrp' not in kwargs: return self._errors['CMMVC5707E'] mdiskgrp = kwargs['mdiskgrp'].strip('\'\"') + if mdiskgrp == kwargs['mdiskgrp']: + raise exception.InvalidInput( + reason=_('mdiskgrp missing quotes %s') % kwargs['mdiskgrp']) copy_info = {} copy_info['id'] = self._find_unused_id(vol['copies']) diff --git a/cinder/volume/drivers/ibm/storwize_svc/ssh.py b/cinder/volume/drivers/ibm/storwize_svc/ssh.py index 49da20c87..f243dc5ef 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/ssh.py +++ b/cinder/volume/drivers/ibm/storwize_svc/ssh.py @@ -89,7 +89,8 @@ class StorwizeSSH(object): return self.run_ssh_info(ssh_cmd)[0] def lsmdiskgrp(self, pool): - ssh_cmd = ['svcinfo', 'lsmdiskgrp', '-bytes', '-delim', '!', pool] + ssh_cmd = ['svcinfo', 'lsmdiskgrp', '-bytes', '-delim', '!', + '"%s"' % pool] return self.run_ssh_info(ssh_cmd)[0] def lsiogrp(self): @@ -191,9 +192,9 @@ class StorwizeSSH(object): self.run_ssh_assert_no_output(ssh_cmd) def mkvdisk(self, name, size, units, pool, opts, params): - ssh_cmd = ['svctask', 'mkvdisk', '-name', name, '-mdiskgrp', pool, - '-iogrp', str(opts['iogrp']), '-size', size, '-unit', - units] + params + ssh_cmd = ['svctask', 'mkvdisk', '-name', name, '-mdiskgrp', + '"%s"' % pool, '-iogrp', str(opts['iogrp']), '-size', + size, '-unit', units] + params return self.run_ssh_check_created(ssh_cmd) def rmvdisk(self, vdisk, force=True): @@ -330,7 +331,7 @@ class StorwizeSSH(object): def addvdiskcopy(self, vdisk, dest_pool, params): ssh_cmd = (['svctask', 'addvdiskcopy'] + params + ['-mdiskgrp', - dest_pool, vdisk]) + '"%s"' % dest_pool, vdisk]) return self.run_ssh_check_created(ssh_cmd) def lsvdiskcopy(self, vdisk, copy_id=None): -- 2.45.2