]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Removes ssh_execute in utils.py
authorZhongyue Luo <zhongyue.nah@intel.com>
Mon, 19 Aug 2013 01:58:26 +0000 (09:58 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Wed, 21 Aug 2013 00:52:03 +0000 (08:52 +0800)
The ssh_execute function is already defined in oslo.processutils
Removes the version in utils.py

Change-Id: Ie0bd73d1f4e6df290270f6d712584431e965be78

cinder/utils.py
cinder/volume/drivers/san/san.py

index ab33463ce42332147f7e12ae4f81d1e2d3ec1a1a..e124ca0486e129c4e7138fb16c928db16c69fe39 100644 (file)
@@ -202,44 +202,6 @@ def check_ssh_injection(cmd_list):
                     raise exception.SSHInjectionThreat(command=cmd_list)
 
 
-def ssh_execute(ssh, cmd, process_input=None,
-                addl_env=None, check_exit_code=True):
-    LOG.debug(_('Running cmd (SSH): %s'), cmd)
-    if addl_env:
-        raise exception.Error(_('Environment not supported over SSH'))
-
-    if process_input:
-        # This is (probably) fixable if we need it...
-        raise exception.Error(_('process_input not supported over SSH'))
-
-    stdin_stream, stdout_stream, stderr_stream = ssh.exec_command(cmd)
-    channel = stdout_stream.channel
-
-    #stdin.write('process_input would go here')
-    #stdin.flush()
-
-    # NOTE(justinsb): This seems suspicious...
-    # ...other SSH clients have buffering issues with this approach
-    stdout = stdout_stream.read()
-    stderr = stderr_stream.read()
-    stdin_stream.close()
-    stdout_stream.close()
-    stderr_stream.close()
-
-    exit_status = channel.recv_exit_status()
-
-    # exit_status == -1 if no exit code was returned
-    if exit_status != -1:
-        LOG.debug(_('Result was %s') % exit_status)
-        if check_exit_code and exit_status != 0:
-            raise exception.ProcessExecutionError(exit_code=exit_status,
-                                                  stdout=stdout,
-                                                  stderr=stderr,
-                                                  cmd=cmd)
-    channel.close()
-    return (stdout, stderr)
-
-
 def create_channel(client, width, height):
     """Invoke an interactive shell session on server."""
     channel = client.invoke_shell()
index bdf7767ed5941d5b73efd06ad1f56aa41b2798be..59d3b596e42f50086bccb50e7b8cd7d00500a201 100644 (file)
@@ -29,6 +29,7 @@ from oslo.config import cfg
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
 from cinder.volume import driver
 
@@ -124,7 +125,7 @@ class SanDriver(driver.VolumeDriver):
                 while attempts > 0:
                     attempts -= 1
                     try:
-                        return utils.ssh_execute(
+                        return processutils.ssh_execute(
                             ssh,
                             command,
                             check_exit_code=check_exit_code)