summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorSuperStack <superstack@superstack.org>2011-02-04 13:12:43 -0600
committerSuperStack <superstack@superstack.org>2011-02-04 13:12:43 -0600
commit0753b724b91cdaf6f9e59be276e60008dd72b05c (patch)
treec0615404f097d36c680c000e11a40ba891eab823 /nova
parent62d2a1a101dc97e80cb0a582197a6b7468abf593 (diff)
parent5315d5068c6250ccf71c1aa67e7e0109a0718f2a (diff)
Moved ssh_execute to utils; moved comments to docstring
Diffstat (limited to 'nova')
-rw-r--r--nova/utils.py35
-rw-r--r--nova/volume/san.py77
2 files changed, 53 insertions, 59 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 5f5225289..100e26f70 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -152,6 +152,41 @@ def execute(cmd, process_input=None, addl_env=None, check_exit_code=True):
return result
+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()
+
+ 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)
+
+ return (stdout, stderr)
+
def abspath(s):
return os.path.join(os.path.dirname(__file__), s)
diff --git a/nova/volume/san.py b/nova/volume/san.py
index 22a0da13f..1f3417ae5 100644
--- a/nova/volume/san.py
+++ b/nova/volume/san.py
@@ -26,6 +26,7 @@ import paramiko
from nova import exception
from nova import flags
from nova import log as logging
+from nova.utils import ssh_execute
from nova.volume.driver import ISCSIDriver
LOG = logging.getLogger("nova.volume.driver")
@@ -38,8 +39,6 @@ flags.DEFINE_string('san_login', 'admin',
'Username for SAN controller')
flags.DEFINE_string('san_password', '',
'Password for SAN controller')
-flags.DEFINE_string('san_cluster_name', '',
- 'Cluster name for creating SAN volumes')
flags.DEFINE_string('san_privatekey', '',
'Filename of private key to use for SSH authentication')
@@ -148,17 +147,22 @@ def _get_prefixed_values(data, prefix):
return matches
class SolarisISCSIDriver(SanISCSIDriver):
- """Executes commands relating to Solaris-hosted ISCSI volumes."""
-
- #pkg install storage-server SUNWiscsit
- #svcadm enable stmf
- #zfs allow justinsb create,mount,destroy rpool
- #usermod -P'File System Management' justinsb
- # I don't know which perms are needed for sbdadm...
- #usermod -P'Primary Administrator' justinsb
- # svcadm enable -r svc:/network/iscsi/target:default
- # pfexec itadm create-tpg e1000g0 10.1.184.98
- # pfexec itadm create-target -t e1000g0
+ """Executes commands relating to Solaris-hosted ISCSI volumes.
+ Basic setup for a Solaris iSCSI server:
+ pkg install storage-server SUNWiscsit
+ svcadm enable stmf
+ svcadm enable -r svc:/network/iscsi/target:default
+ pfexec itadm create-tpg e1000g0 ${MYIP}
+ pfexec itadm create-target -t e1000g0
+
+ Then grant the user that will be logging on lots of permissions.
+ I'm not sure exactly which though:
+ zfs allow justinsb create,mount,destroy rpool
+ usermod -P'File System Management' justinsb
+ usermod -P'Primary Administrator' justinsb
+
+ Also make sure you can login using san_login & san_password/san_privatekey
+ """
def _view_exists(self, luid):
(out, _err) = self._run_ssh("pfexec /usr/sbin/stmfadm list-view -l %s" %
@@ -280,19 +284,13 @@ class SolarisISCSIDriver(SanISCSIDriver):
iscsi_name = self._build_iscsi_target_name(volume)
target_group_name = 'tg-%s' % volume['name']
- # The sequence of commands looks like this:
- #pfexec stmfadm create-tg tg-vol2
- # Yes, we add it before we create it!
- #pfexec stmfadm add-tg-member -g tg-vol2 iqn.2010-10.org.openstack:vol2
- #pfexec itadm create-target -n iqn.2010-10.org.openstack:vol2
- #pfexec stmfadm add-view -t tg-vol2 600144F051E2440000004D4A0F730004
-
# Create a iSCSI target, mapped to just this volume
if force_create or not self._target_group_exists(target_group_name):
self._run_ssh("pfexec /usr/sbin/stmfadm create-tg %s" %
(target_group_name))
# Yes, we add the initiatior before we create it!
+ # Otherwise, it complains that the target is already active
if force_create or not self._is_target_group_member(target_group_name,
iscsi_name):
self._run_ssh("pfexec /usr/sbin/stmfadm add-tg-member -g %s %s" %
@@ -332,42 +330,3 @@ class SolarisISCSIDriver(SanISCSIDriver):
self._run_ssh("pfexec /usr/sbin/sbdadm delete-lu %s" %
(luid))
-
-def ssh_execute(ssh, cmd, process_input=None,
- addl_env=None, check_exit_code=True):
- LOG.debug(_("Running cmd (subprocess): %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()
-
- # I'm suspicious of this...
- # ...other SSH clients have buffering issues with this approach
- stdout = stdout_stream.read()
- stderr = stderr_stream.read()
- stdin_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)
-
- # Removed, although this is workaround is needed in utils.execute:
- # (no reason to believe it's needed here!)
- # greenthread.sleep(0)
-
- return (stdout, stderr)