]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix some issues with pool name sent to SVC
authorgfm <gfm@us.ibm.com>
Fri, 6 Mar 2015 01:02:11 +0000 (19:02 -0600)
committergfm <gfm@us.ibm.com>
Fri, 6 Mar 2015 16:31:54 +0000 (10:31 -0600)
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
cinder/volume/drivers/ibm/storwize_svc/ssh.py

index 6150705efc368de288167c4df3aa9fffae4e55b3..eaede2f685d5e010ab43d2e683ddf4f3e699728a 100644 (file)
@@ -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'])
index 49da20c87ce508981a042e0235743afb683dd300..f243dc5eff3e887a5179f9753bd2f1732e619851 100644 (file)
@@ -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):