equal
deleted
inserted
replaced
1 # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
1 # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
2 # Copyright (c) 2012 OpenStack LLC. |
2 # Copyright (c) 2012 OpenStack LLC. |
3 # All Rights Reserved. |
3 # All Rights Reserved. |
4 # |
4 # |
5 # Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
5 # Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
6 # |
6 # |
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may |
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may |
8 # not use this file except in compliance with the License. You may obtain |
8 # not use this file except in compliance with the License. You may obtain |
9 # a copy of the License at |
9 # a copy of the License at |
10 # |
10 # |
18 """ |
18 """ |
19 Drivers for Solaris ZFS operations in local and iSCSI modes |
19 Drivers for Solaris ZFS operations in local and iSCSI modes |
20 """ |
20 """ |
21 |
21 |
22 import abc |
22 import abc |
23 import os |
|
24 import time |
23 import time |
25 |
24 |
26 from oslo.config import cfg |
25 from oslo.config import cfg |
27 |
26 |
28 from cinder import exception |
27 from cinder import exception |
29 from cinder.image import image_utils |
28 from cinder.image import image_utils |
|
29 from cinder.i18n import _ |
30 from cinder.openstack.common import log as logging |
30 from cinder.openstack.common import log as logging |
31 from cinder.openstack.common import processutils |
31 from cinder.openstack.common import processutils |
32 from cinder.volume import driver |
32 from cinder.volume import driver |
33 |
33 |
34 from solaris_install.target.size import Size |
34 from solaris_install.target.size import Size |
115 Firstly, the volume should be checked if it is a cloned one. If yes, |
115 Firstly, the volume should be checked if it is a cloned one. If yes, |
116 its parent snapshot with prefix 'tmp-snapshot-' should be deleted as |
116 its parent snapshot with prefix 'tmp-snapshot-' should be deleted as |
117 well after it is removed. |
117 well after it is removed. |
118 """ |
118 """ |
119 zvol = self._get_zvol_path(volume) |
119 zvol = self._get_zvol_path(volume) |
120 if not os.path.exists(zvol): |
120 try: |
|
121 (out, _err) = self._execute('/usr/bin/ls', zvol) |
|
122 except processutils.ProcessExecutionError: |
121 LOG.debug(_("The volume path '%s' doesn't exist") % zvol) |
123 LOG.debug(_("The volume path '%s' doesn't exist") % zvol) |
122 return |
124 return |
123 |
125 |
124 zfs_volume = self._get_zfs_volume_name(volume) |
126 zfs_volume = self._get_zfs_volume_name(volume) |
125 origin_snapshot = self._get_zfs_property('origin', zfs_volume) |
127 origin_snapshot = self._get_zfs_property('origin', zfs_volume) |
169 |
171 |
170 def initialize_connection(self, volume, connector): |
172 def initialize_connection(self, volume, connector): |
171 """Initialize the connection and returns connection info.""" |
173 """Initialize the connection and returns connection info.""" |
172 volume_path = '%s/volume-%s' % (self.configuration.zfs_volume_base, |
174 volume_path = '%s/volume-%s' % (self.configuration.zfs_volume_base, |
173 volume['id']) |
175 volume['id']) |
|
176 properties = {} |
|
177 properties['device_path'] = self._get_zvol_path(volume) |
|
178 |
174 return { |
179 return { |
175 'driver_volume_type': 'local', |
180 'driver_volume_type': 'local', |
176 'volume_path': volume_path, |
181 'volume_path': volume_path, |
177 'data': {} |
182 'data': properties |
178 } |
183 } |
179 |
184 |
180 def terminate_connection(self, volume, connector, **kwargs): |
185 def terminate_connection(self, volume, connector, **kwargs): |
181 """Disconnection from the connector.""" |
186 """Disconnection from the connector.""" |
182 pass |
187 pass |
376 break |
381 break |
377 if line.startswith("Lun"): |
382 if line.startswith("Lun"): |
378 view_and_lun['lun'] = int(line.split()[2]) |
383 view_and_lun['lun'] = int(line.split()[2]) |
379 |
384 |
380 if view_and_lun['view'] is None or view_and_lun['lun'] is None: |
385 if view_and_lun['view'] is None or view_and_lun['lun'] is None: |
381 LOG.error(_("Failed to get the view_entry or LUN of the LU '%s'.") |
386 err_msg = (_("Failed to get the view_entry or LUN of the LU '%s'.") |
382 % lu) |
387 % lu) |
383 raise |
388 raise exception.VolumeBackendAPIException(data=err_msg) |
384 else: |
389 else: |
385 LOG.debug(_("The view_entry and LUN of LU '%s' are '%s' and '%d'.") |
390 LOG.debug(_("The view_entry and LUN of LU '%s' are '%s' and '%d'.") |
386 % (lu, view_and_lun['view'], view_and_lun['lun'])) |
391 % (lu, view_and_lun['view'], view_and_lun['lun'])) |
387 |
392 |
388 return view_and_lun |
393 return view_and_lun |
420 target_name) |
425 target_name) |
421 assert self._check_target(target_name, 'iSCSI') |
426 assert self._check_target(target_name, 'iSCSI') |
422 |
427 |
423 # Add a view entry to the logical unit with the specified LUN, 8776 |
428 # Add a view entry to the logical unit with the specified LUN, 8776 |
424 if luid is not None: |
429 if luid is not None: |
425 self._stmf_execute('/usr/sbin/stmfadm', 'add-view', '-n', 8776, |
430 self._stmf_execute('/usr/sbin/stmfadm', 'add-view', '-n', '8776', |
426 '-t', target_group, luid) |
431 '-t', target_group, luid) |
427 |
432 |
428 def remove_export(self, context, volume): |
433 def remove_export(self, context, volume): |
429 """Remove an export for a volume. |
434 """Remove an export for a volume. |
430 |
435 |
484 volume['name']) |
489 volume['name']) |
485 properties = {} |
490 properties = {} |
486 |
491 |
487 properties['target_discovered'] = True |
492 properties['target_discovered'] = True |
488 properties['target_iqn'] = target_name |
493 properties['target_iqn'] = target_name |
|
494 |
489 properties['target_portal'] = ('%s:%d' % |
495 properties['target_portal'] = ('%s:%d' % |
490 (self.configuration.iscsi_ip_address, |
496 (self.configuration.iscsi_ip_address, |
491 self.configuration.iscsi_port)) |
497 self.configuration.iscsi_port)) |
492 view_lun = self._get_view_and_lun(luid) |
498 view_lun = self._get_view_and_lun(luid) |
493 if view_lun['lun'] is not None: |
499 if view_lun['lun'] is not None: |