~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/volume/xensm.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from nova import flags
17
17
from nova import log as logging
18
18
from nova import utils
19
 
from nova.virt import xenapi_conn
 
19
from nova.virt.xenapi import connection as xenapi_conn
20
20
from nova.virt.xenapi import volumeops
21
21
import nova.volume.driver
22
22
 
59
59
            except Exception as ex:
60
60
                LOG.debug(_("Failed to create sr %s...continuing") %
61
61
                          str(backend_ref['id']))
62
 
                raise exception.Error(_('Create failed'))
 
62
                raise exception.NovaException(_('Create failed'))
63
63
 
64
64
            LOG.debug(_('SR UUID of new SR is: %s') % sr_uuid)
65
65
            try:
68
68
                                               dict(sr_uuid=sr_uuid))
69
69
            except Exception as ex:
70
70
                LOG.exception(ex)
71
 
                raise exception.Error(_("Failed to update db"))
 
71
                raise exception.NovaException(_("Failed to update db"))
72
72
 
73
73
        else:
74
74
            # sr introduce, if not already done
88
88
                self._create_storage_repo(context, backend)
89
89
            except Exception as ex:
90
90
                LOG.exception(ex)
91
 
                raise exception.Error(_('Failed to reach backend %d')
 
91
                raise exception.NovaException(_('Failed to reach backend %d')
92
92
                                      % backend['id'])
93
93
 
94
94
    def __init__(self, *args, **kwargs):
97
97
        # This driver leverages Xen storage manager, and hence requires
98
98
        # hypervisor to be Xen
99
99
        if FLAGS.connection_type != 'xenapi':
100
 
            raise exception.Error(_('XenSMDriver requires xenapi connection'))
 
100
            msg = _('XenSMDriver requires xenapi connection')
 
101
            raise exception.NovaException(msg)
101
102
 
102
103
        url = FLAGS.xenapi_connection_url
103
104
        username = FLAGS.xenapi_connection_username
107
108
            self._volumeops = volumeops.VolumeOps(session)
108
109
        except Exception as ex:
109
110
            LOG.exception(ex)
110
 
            raise exception.Error(_("Failed to initiate session"))
 
111
            raise exception.NovaException(_("Failed to initiate session"))
111
112
 
112
113
        super(XenSMDriver, self).__init__(execute=utils.execute,
113
114
                                          sync_exec=utils.execute,
151
152
                self.db.sm_volume_create(self.ctxt, sm_vol_rec)
152
153
            except Exception as ex:
153
154
                LOG.exception(ex)
154
 
                raise exception.Error(_("Failed to update volume in db"))
 
155
                msg = _("Failed to update volume in db")
 
156
                raise exception.NovaException(msg)
155
157
 
156
158
        else:
157
 
            raise exception.Error(_('Unable to create volume'))
 
159
            raise exception.NovaException(_('Unable to create volume'))
158
160
 
159
161
    def delete_volume(self, volume):
160
162
 
168
170
            self._volumeops.delete_volume_for_sm(vol_rec['vdi_uuid'])
169
171
        except Exception as ex:
170
172
            LOG.exception(ex)
171
 
            raise exception.Error(_("Failed to delete vdi"))
 
173
            raise exception.NovaException(_("Failed to delete vdi"))
172
174
 
173
175
        try:
174
176
            self.db.sm_volume_delete(self.ctxt, volume['id'])
175
177
        except Exception as ex:
176
178
            LOG.exception(ex)
177
 
            raise exception.Error(_("Failed to delete volume in db"))
 
179
            raise exception.NovaException(_("Failed to delete volume in db"))
178
180
 
179
181
    def local_path(self, volume):
180
182
        return str(volume['id'])
207
209
                                                          volume['id']))
208
210
        except Exception as ex:
209
211
            LOG.exception(ex)
210
 
            raise exception.Error(_("Failed to find volume in db"))
 
212
            raise exception.NovaException(_("Failed to find volume in db"))
211
213
 
212
214
        # Keep the volume id key consistent with what ISCSI driver calls it
213
215
        xensm_properties['volume_id'] = xensm_properties['id']
218
220
                                  xensm_properties['backend_id'])
219
221
        except Exception as ex:
220
222
            LOG.exception(ex)
221
 
            raise exception.Error(_("Failed to find backend in db"))
 
223
            raise exception.NovaException(_("Failed to find backend in db"))
222
224
 
223
225
        params = self._convert_config_params(backend_conf['config_params'])
224
226