Merge lp:~justin-fathomdb/nova/san into lp:~hudson-openstack/nova/trunk

Proposed by justinsb
Status: Merged
Approved by: Vish Ishaya
Approved revision: 652
Merged at revision: 656
Proposed branch: lp:~justin-fathomdb/nova/san
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 444 lines (+378/-6)
5 files modified
.mailmap (+1/-0)
nova/utils.py (+36/-0)
nova/volume/driver.py (+5/-5)
nova/volume/manager.py (+1/-1)
nova/volume/san.py (+335/-0)
To merge this branch: bzr merge lp:~justin-fathomdb/nova/san
Reviewer Review Type Date Requested Status
Devin Carlen (community) Approve
Vish Ishaya (community) Approve
justinsb (community) Needs Resubmitting
Review via email: mp+48633@code.launchpad.net

Description of the change

Added support for 'SAN' style volumes. A SAN's big difference is that the iSCSI target won't normally run on the same host as the volume service.

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

This looks pretty awesome. It seems like ssh_execute could live in utils.py, since it is likely useful for other components as well.

107 + # TODO(justinsb): store in volume, remerge with generic iSCSI code
108 + host = FLAGS.san_ip

Perhaps we should have an extra field for ip for all of the iscsi drivers. That way the host name doesn't have to be resolvable from the compute host, and we can git rid of the ugly --iscsi_ip_prefix flag. I'm ok with this happening in another patch though.

The long list of commented setup commands should be moved into the docstring or perhaps fleshed out and moved into docs/

review: Needs Fixing
Revision history for this message
Devin Carlen (devcamcar) wrote :

A nit:

405 + # I'm suspicious of this...
406 + # ...other SSH clients have buffering issues with this approach

Please use the NOTE(myname): prefix and avoid first person in comments so that the community knows who is providing the information here.

review: Needs Fixing
Revision history for this message
justinsb (justin-fathomdb) wrote :

Thanks Vish & Devin.

Devin: I formatted the note as you suggested.

Vish: I moved ssh_execute into utils. It'll end up there in the end, and this way change tracking is easier. I do want to introduce SSH connection pooling in future.

I moved the comments into a docstring, though I don't know how they will look once they're the doc is generated. Once this is locked down, definitely agree this should be moved into docs.

Finally, I totally agree that the iSCSI target address vs san_ip vs iscsi_ip_prefix thing is ugly. I'm not actually sure what iscsi_ip_prefix is for (I had to rewrite the discovery function anyway, and I didn't need it) But long term, I think that a single volume controller may be managing multiple SAN nodes, and so I'd like to fix this properly at that stage. It will need a new attribute in the volume model, so I stayed away from it initially to keep the patch small. So I'd like to defer this to another patch if that's OK!

review: Needs Resubmitting
Revision history for this message
Devin Carlen (devcamcar) wrote :

Cool, I'll do a proper review in a bit. I'm ok with deferring to another patch as long as we create a bug or blueprint (whichever is more appropriate) to document what limitations there are in this proposed implementation.

Revision history for this message
justinsb (justin-fathomdb) wrote :

I'm not sure there's actually a limitation in the current approach - I think it should work at least as well as the current OpenISCSI target code. But there's some code messiness in the handling of the iSCSI target IP; happily the future direction of the SAN code is likely to evolve to fix this anyway. Not sure if we should do a bug/blueprint in this case (or what would really go in it if we did!)

Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm. We can do another patch for putting the ip of the target into the db.

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

The attempt to merge lp:~justin-fathomdb/nova/san into lp:nova failed. Below is the output from the failed tests.

/bin/sh: /var/lib/hudson/test_nova.sh: not found

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (20.8 KiB)

The attempt to merge lp:~justin-fathomdb/nova/san into lp:nova failed. Below is the output from the failed tests.

AdminAPITest
    test_admin_disabled ok
    test_admin_enabled ok
APITest
    test_exceptions_are_converted_to_faults ok
Test
    test_authorize_token ok
    test_authorize_user ok
    test_bad_token ok
    test_bad_user ok
    test_no_user ok
    test_token_expiry ok
TestLimiter
    test_authorize_token ok
TestFaults
    test_fault_parts ok
    test_raise ok
    test_retry_header ok
FlavorsTest
    test_get_flavor_by_id ok
    test_get_flavor_list ok
GlanceImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
ImageControllerWithGlanceServiceTest
    test_get_image_details ok
    test_get_image_index ok
LocalImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
LimiterTest
    test_minute ok
    test_one_per_period ok
    test_second ok
    test_users_get_separate_buckets ok
    test_we_can_go_indefinitely_if_we_spread_out_requests ok
WSGIAppProxyTest
    test_200 ok
    test_403 ok
    test_failure ok
WSGIAppTest
    test_escaping ok
    test_good_urls ok
    test_invalid_methods ok
    test_invalid_urls ok
    test_response_to_delays ok
ServersTest
    test_create_backup_schedules ok
    test_create_instance ok
    test_delete_backup_schedules ok
    test_delete_server_instance ok
    test_get_all_server_details ok
    test...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (27.5 KiB)

The attempt to merge lp:~justin-fathomdb/nova/san into lp:nova failed. Below is the output from the failed tests.

AdminAPITest
    test_admin_disabled ok
    test_admin_enabled ok
APITest
    test_exceptions_are_converted_to_faults ok
Test
    test_authorize_token ok
    test_authorize_user ok
    test_bad_token ok
    test_bad_user ok
    test_no_user ok
    test_token_expiry ok
TestLimiter
    test_authorize_token ok
TestFaults
    test_fault_parts ok
    test_raise ok
    test_retry_header ok
FlavorsTest
    test_get_flavor_by_id ok
    test_get_flavor_list ok
GlanceImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
ImageControllerWithGlanceServiceTest
    test_get_image_details ok
    test_get_image_index ok
LocalImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
LimiterTest
    test_minute ok
    test_one_per_period ok
    test_second ok
    test_users_get_separate_buckets ok
    test_we_can_go_indefinitely_if_we_spread_out_requests ok
WSGIAppProxyTest
    test_200 ok
    test_403 ok
    test_failure ok
WSGIAppTest
    test_escaping ok
    test_good_urls ok
    test_invalid_methods ok
    test_invalid_urls ok
    test_response_to_delays ok
ServersTest
    test_create_backup_schedules ok
    test_create_instance ok
    test_delete_backup_schedules ok
    test_delete_server_instance ok
    test_get_all_server_details ok
    test...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.mailmap'
--- .mailmap 2011-01-18 19:34:29 +0000
+++ .mailmap 2011-02-09 19:30:31 +0000
@@ -33,3 +33,4 @@
33<corywright@gmail.com> <cory.wright@rackspace.com>33<corywright@gmail.com> <cory.wright@rackspace.com>
34<ant@openstack.org> <amesserl@rackspace.com>34<ant@openstack.org> <amesserl@rackspace.com>
35<chiradeep@cloud.com> <chiradeep@chiradeep-lt2>35<chiradeep@cloud.com> <chiradeep@chiradeep-lt2>
36<justin@fathomdb.com> <superstack@superstack.org>
3637
=== modified file 'nova/utils.py'
--- nova/utils.py 2011-01-27 19:52:10 +0000
+++ nova/utils.py 2011-02-09 19:30:31 +0000
@@ -152,6 +152,42 @@
152 return result152 return result
153153
154154
155def ssh_execute(ssh, cmd, process_input=None,
156 addl_env=None, check_exit_code=True):
157 LOG.debug(_("Running cmd (SSH): %s"), cmd)
158 if addl_env:
159 raise exception.Error("Environment not supported over SSH")
160
161 if process_input:
162 # This is (probably) fixable if we need it...
163 raise exception.Error("process_input not supported over SSH")
164
165 stdin_stream, stdout_stream, stderr_stream = ssh.exec_command(cmd)
166 channel = stdout_stream.channel
167
168 #stdin.write('process_input would go here')
169 #stdin.flush()
170
171 # NOTE(justinsb): This seems suspicious...
172 # ...other SSH clients have buffering issues with this approach
173 stdout = stdout_stream.read()
174 stderr = stderr_stream.read()
175 stdin_stream.close()
176
177 exit_status = channel.recv_exit_status()
178
179 # exit_status == -1 if no exit code was returned
180 if exit_status != -1:
181 LOG.debug(_("Result was %s") % exit_status)
182 if check_exit_code and exit_status != 0:
183 raise exception.ProcessExecutionError(exit_code=exit_status,
184 stdout=stdout,
185 stderr=stderr,
186 cmd=cmd)
187
188 return (stdout, stderr)
189
190
155def abspath(s):191def abspath(s):
156 return os.path.join(os.path.dirname(__file__), s)192 return os.path.join(os.path.dirname(__file__), s)
157193
158194
=== modified file 'nova/volume/driver.py'
--- nova/volume/driver.py 2011-01-19 02:50:21 +0000
+++ nova/volume/driver.py 2011-02-09 19:30:31 +0000
@@ -294,8 +294,10 @@
294 self._execute("sudo ietadm --op delete --tid=%s" %294 self._execute("sudo ietadm --op delete --tid=%s" %
295 iscsi_target)295 iscsi_target)
296296
297 def _get_name_and_portal(self, volume_name, host):297 def _get_name_and_portal(self, volume):
298 """Gets iscsi name and portal from volume name and host."""298 """Gets iscsi name and portal from volume name and host."""
299 volume_name = volume['name']
300 host = volume['host']
299 (out, _err) = self._execute("sudo iscsiadm -m discovery -t "301 (out, _err) = self._execute("sudo iscsiadm -m discovery -t "
300 "sendtargets -p %s" % host)302 "sendtargets -p %s" % host)
301 for target in out.splitlines():303 for target in out.splitlines():
@@ -307,8 +309,7 @@
307309
308 def discover_volume(self, volume):310 def discover_volume(self, volume):
309 """Discover volume on a remote host."""311 """Discover volume on a remote host."""
310 iscsi_name, iscsi_portal = self._get_name_and_portal(volume['name'],312 iscsi_name, iscsi_portal = self._get_name_and_portal(volume)
311 volume['host'])
312 self._execute("sudo iscsiadm -m node -T %s -p %s --login" %313 self._execute("sudo iscsiadm -m node -T %s -p %s --login" %
313 (iscsi_name, iscsi_portal))314 (iscsi_name, iscsi_portal))
314 self._execute("sudo iscsiadm -m node -T %s -p %s --op update "315 self._execute("sudo iscsiadm -m node -T %s -p %s --op update "
@@ -319,8 +320,7 @@
319320
320 def undiscover_volume(self, volume):321 def undiscover_volume(self, volume):
321 """Undiscover volume on a remote host."""322 """Undiscover volume on a remote host."""
322 iscsi_name, iscsi_portal = self._get_name_and_portal(volume['name'],323 iscsi_name, iscsi_portal = self._get_name_and_portal(volume)
323 volume['host'])
324 self._execute("sudo iscsiadm -m node -T %s -p %s --op update "324 self._execute("sudo iscsiadm -m node -T %s -p %s --op update "
325 "-n node.startup -v manual" %325 "-n node.startup -v manual" %
326 (iscsi_name, iscsi_portal))326 (iscsi_name, iscsi_portal))
327327
=== modified file 'nova/volume/manager.py'
--- nova/volume/manager.py 2011-01-21 21:10:26 +0000
+++ nova/volume/manager.py 2011-02-09 19:30:31 +0000
@@ -87,7 +87,7 @@
87 if volume['status'] in ['available', 'in-use']:87 if volume['status'] in ['available', 'in-use']:
88 self.driver.ensure_export(ctxt, volume)88 self.driver.ensure_export(ctxt, volume)
89 else:89 else:
90 LOG.info(_("volume %s: skipping export"), volume_ref['name'])90 LOG.info(_("volume %s: skipping export"), volume['name'])
9191
92 def create_volume(self, context, volume_id):92 def create_volume(self, context, volume_id):
93 """Creates and exports the volume."""93 """Creates and exports the volume."""
9494
=== added file 'nova/volume/san.py'
--- nova/volume/san.py 1970-01-01 00:00:00 +0000
+++ nova/volume/san.py 2011-02-09 19:30:31 +0000
@@ -0,0 +1,335 @@
1# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2011 Justin Santa Barbara
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17"""
18Drivers for san-stored volumes.
19The unique thing about a SAN is that we don't expect that we can run the volume
20 controller on the SAN hardware. We expect to access it over SSH or some API.
21"""
22
23import os
24import paramiko
25
26from nova import exception
27from nova import flags
28from nova import log as logging
29from nova.utils import ssh_execute
30from nova.volume.driver import ISCSIDriver
31
32LOG = logging.getLogger("nova.volume.driver")
33FLAGS = flags.FLAGS
34flags.DEFINE_boolean('san_thin_provision', 'true',
35 'Use thin provisioning for SAN volumes?')
36flags.DEFINE_string('san_ip', '',
37 'IP address of SAN controller')
38flags.DEFINE_string('san_login', 'admin',
39 'Username for SAN controller')
40flags.DEFINE_string('san_password', '',
41 'Password for SAN controller')
42flags.DEFINE_string('san_privatekey', '',
43 'Filename of private key to use for SSH authentication')
44
45
46class SanISCSIDriver(ISCSIDriver):
47 """ Base class for SAN-style storage volumes
48 (storage providers we access over SSH)"""
49 #Override because SAN ip != host ip
50 def _get_name_and_portal(self, volume):
51 """Gets iscsi name and portal from volume name and host."""
52 volume_name = volume['name']
53
54 # TODO(justinsb): store in volume, remerge with generic iSCSI code
55 host = FLAGS.san_ip
56
57 (out, _err) = self._execute("sudo iscsiadm -m discovery -t "
58 "sendtargets -p %s" % host)
59
60 location = None
61 find_iscsi_name = self._build_iscsi_target_name(volume)
62 for target in out.splitlines():
63 if find_iscsi_name in target:
64 (location, _sep, iscsi_name) = target.partition(" ")
65 break
66 if not location:
67 raise exception.Error(_("Could not find iSCSI export "
68 " for volume %s") %
69 volume_name)
70
71 iscsi_portal = location.split(",")[0]
72 LOG.debug("iscsi_name=%s, iscsi_portal=%s" %
73 (iscsi_name, iscsi_portal))
74 return (iscsi_name, iscsi_portal)
75
76 def _build_iscsi_target_name(self, volume):
77 return "%s%s" % (FLAGS.iscsi_target_prefix, volume['name'])
78
79 # discover_volume is still OK
80 # undiscover_volume is still OK
81
82 def _connect_to_ssh(self):
83 ssh = paramiko.SSHClient()
84 #TODO(justinsb): We need a better SSH key policy
85 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
86 if FLAGS.san_password:
87 ssh.connect(FLAGS.san_ip,
88 username=FLAGS.san_login,
89 password=FLAGS.san_password)
90 elif FLAGS.san_privatekey:
91 privatekeyfile = os.path.expanduser(FLAGS.san_privatekey)
92 # It sucks that paramiko doesn't support DSA keys
93 privatekey = paramiko.RSAKey.from_private_key_file(privatekeyfile)
94 ssh.connect(FLAGS.san_ip,
95 username=FLAGS.san_login,
96 pkey=privatekey)
97 else:
98 raise exception.Error("Specify san_password or san_privatekey")
99 return ssh
100
101 def _run_ssh(self, command, check_exit_code=True):
102 #TODO(justinsb): SSH connection caching (?)
103 ssh = self._connect_to_ssh()
104
105 #TODO(justinsb): Reintroduce the retry hack
106 ret = ssh_execute(ssh, command, check_exit_code=check_exit_code)
107
108 ssh.close()
109
110 return ret
111
112 def ensure_export(self, context, volume):
113 """Synchronously recreates an export for a logical volume."""
114 pass
115
116 def create_export(self, context, volume):
117 """Exports the volume."""
118 pass
119
120 def remove_export(self, context, volume):
121 """Removes an export for a logical volume."""
122 pass
123
124 def check_for_setup_error(self):
125 """Returns an error if prerequisites aren't met"""
126 if not (FLAGS.san_password or FLAGS.san_privatekey):
127 raise exception.Error("Specify san_password or san_privatekey")
128
129 if not (FLAGS.san_ip):
130 raise exception.Error("san_ip must be set")
131
132
133def _collect_lines(data):
134 """ Split lines from data into an array, trimming them """
135 matches = []
136 for line in data.splitlines():
137 match = line.strip()
138 matches.append(match)
139
140 return matches
141
142
143def _get_prefixed_values(data, prefix):
144 """Collect lines which start with prefix; with trimming"""
145 matches = []
146 for line in data.splitlines():
147 line = line.strip()
148 if line.startswith(prefix):
149 match = line[len(prefix):]
150 match = match.strip()
151 matches.append(match)
152
153 return matches
154
155
156class SolarisISCSIDriver(SanISCSIDriver):
157 """Executes commands relating to Solaris-hosted ISCSI volumes.
158 Basic setup for a Solaris iSCSI server:
159 pkg install storage-server SUNWiscsit
160 svcadm enable stmf
161 svcadm enable -r svc:/network/iscsi/target:default
162 pfexec itadm create-tpg e1000g0 ${MYIP}
163 pfexec itadm create-target -t e1000g0
164
165 Then grant the user that will be logging on lots of permissions.
166 I'm not sure exactly which though:
167 zfs allow justinsb create,mount,destroy rpool
168 usermod -P'File System Management' justinsb
169 usermod -P'Primary Administrator' justinsb
170
171 Also make sure you can login using san_login & san_password/san_privatekey
172 """
173
174 def _view_exists(self, luid):
175 cmd = "pfexec /usr/sbin/stmfadm list-view -l %s" % (luid)
176 (out, _err) = self._run_ssh(cmd,
177 check_exit_code=False)
178 if "no views found" in out:
179 return False
180
181 if "View Entry:" in out:
182 return True
183
184 raise exception.Error("Cannot parse list-view output: %s" % (out))
185
186 def _get_target_groups(self):
187 """Gets list of target groups from host."""
188 (out, _err) = self._run_ssh("pfexec /usr/sbin/stmfadm list-tg")
189 matches = _get_prefixed_values(out, 'Target group: ')
190 LOG.debug("target_groups=%s" % matches)
191 return matches
192
193 def _target_group_exists(self, target_group_name):
194 return target_group_name not in self._get_target_groups()
195
196 def _get_target_group_members(self, target_group_name):
197 (out, _err) = self._run_ssh("pfexec /usr/sbin/stmfadm list-tg -v %s" %
198 (target_group_name))
199 matches = _get_prefixed_values(out, 'Member: ')
200 LOG.debug("members of %s=%s" % (target_group_name, matches))
201 return matches
202
203 def _is_target_group_member(self, target_group_name, iscsi_target_name):
204 return iscsi_target_name in (
205 self._get_target_group_members(target_group_name))
206
207 def _get_iscsi_targets(self):
208 cmd = ("pfexec /usr/sbin/itadm list-target | "
209 "awk '{print $1}' | grep -v ^TARGET")
210 (out, _err) = self._run_ssh(cmd)
211 matches = _collect_lines(out)
212 LOG.debug("_get_iscsi_targets=%s" % (matches))
213 return matches
214
215 def _iscsi_target_exists(self, iscsi_target_name):
216 return iscsi_target_name in self._get_iscsi_targets()
217
218 def _build_zfs_poolname(self, volume):
219 #TODO(justinsb): rpool should be configurable
220 zfs_poolname = 'rpool/%s' % (volume['name'])
221 return zfs_poolname
222
223 def create_volume(self, volume):
224 """Creates a volume."""
225 if int(volume['size']) == 0:
226 sizestr = '100M'
227 else:
228 sizestr = '%sG' % volume['size']
229
230 zfs_poolname = self._build_zfs_poolname(volume)
231
232 thin_provision_arg = '-s' if FLAGS.san_thin_provision else ''
233 # Create a zfs volume
234 self._run_ssh("pfexec /usr/sbin/zfs create %s -V %s %s" %
235 (thin_provision_arg,
236 sizestr,
237 zfs_poolname))
238
239 def _get_luid(self, volume):
240 zfs_poolname = self._build_zfs_poolname(volume)
241
242 cmd = ("pfexec /usr/sbin/sbdadm list-lu | "
243 "grep -w %s | awk '{print $1}'" %
244 (zfs_poolname))
245
246 (stdout, _stderr) = self._run_ssh(cmd)
247
248 luid = stdout.strip()
249 return luid
250
251 def _is_lu_created(self, volume):
252 luid = self._get_luid(volume)
253 return luid
254
255 def delete_volume(self, volume):
256 """Deletes a volume."""
257 zfs_poolname = self._build_zfs_poolname(volume)
258 self._run_ssh("pfexec /usr/sbin/zfs destroy %s" %
259 (zfs_poolname))
260
261 def local_path(self, volume):
262 # TODO(justinsb): Is this needed here?
263 escaped_group = FLAGS.volume_group.replace('-', '--')
264 escaped_name = volume['name'].replace('-', '--')
265 return "/dev/mapper/%s-%s" % (escaped_group, escaped_name)
266
267 def ensure_export(self, context, volume):
268 """Synchronously recreates an export for a logical volume."""
269 #TODO(justinsb): On bootup, this is called for every volume.
270 # It then runs ~5 SSH commands for each volume,
271 # most of which fetch the same info each time
272 # This makes initial start stupid-slow
273 self._do_export(volume, force_create=False)
274
275 def create_export(self, context, volume):
276 self._do_export(volume, force_create=True)
277
278 def _do_export(self, volume, force_create):
279 # Create a Logical Unit (LU) backed by the zfs volume
280 zfs_poolname = self._build_zfs_poolname(volume)
281
282 if force_create or not self._is_lu_created(volume):
283 cmd = ("pfexec /usr/sbin/sbdadm create-lu /dev/zvol/rdsk/%s" %
284 (zfs_poolname))
285 self._run_ssh(cmd)
286
287 luid = self._get_luid(volume)
288 iscsi_name = self._build_iscsi_target_name(volume)
289 target_group_name = 'tg-%s' % volume['name']
290
291 # Create a iSCSI target, mapped to just this volume
292 if force_create or not self._target_group_exists(target_group_name):
293 self._run_ssh("pfexec /usr/sbin/stmfadm create-tg %s" %
294 (target_group_name))
295
296 # Yes, we add the initiatior before we create it!
297 # Otherwise, it complains that the target is already active
298 if force_create or not self._is_target_group_member(target_group_name,
299 iscsi_name):
300 self._run_ssh("pfexec /usr/sbin/stmfadm add-tg-member -g %s %s" %
301 (target_group_name, iscsi_name))
302 if force_create or not self._iscsi_target_exists(iscsi_name):
303 self._run_ssh("pfexec /usr/sbin/itadm create-target -n %s" %
304 (iscsi_name))
305 if force_create or not self._view_exists(luid):
306 self._run_ssh("pfexec /usr/sbin/stmfadm add-view -t %s %s" %
307 (target_group_name, luid))
308
309 def remove_export(self, context, volume):
310 """Removes an export for a logical volume."""
311
312 # This is the reverse of _do_export
313 luid = self._get_luid(volume)
314 iscsi_name = self._build_iscsi_target_name(volume)
315 target_group_name = 'tg-%s' % volume['name']
316
317 if self._view_exists(luid):
318 self._run_ssh("pfexec /usr/sbin/stmfadm remove-view -l %s -a" %
319 (luid))
320
321 if self._iscsi_target_exists(iscsi_name):
322 self._run_ssh("pfexec /usr/sbin/stmfadm offline-target %s" %
323 (iscsi_name))
324 self._run_ssh("pfexec /usr/sbin/itadm delete-target %s" %
325 (iscsi_name))
326
327 # We don't delete the tg-member; we delete the whole tg!
328
329 if self._target_group_exists(target_group_name):
330 self._run_ssh("pfexec /usr/sbin/stmfadm delete-tg %s" %
331 (target_group_name))
332
333 if self._is_lu_created(volume):
334 self._run_ssh("pfexec /usr/sbin/sbdadm delete-lu %s" %
335 (luid))