self.configuration.append_config_values(volume_opts)
self.hostname = socket.gethostname()
self.vg = vg_obj
+ self.backend_name =\
+ self.configuration.safe_get('volume_backend_name') or 'LVM'
+ self.protocol = 'local'
def set_execute(self, execute):
self._execute = execute
"""
if refresh:
- self._update_volume_status()
- self._update_volume_status()
+ self._update_volume_stats()
return self._stats
- def _update_volume_status(self):
- """Retrieve status info from volume group."""
+ def _update_volume_stats(self):
+ """Retrieve stats info from volume group."""
+
+ LOG.debug(_("Updating volume stats"))
+ if self.vg is None:
+ LOG.warning(_('Unable to update stats on non-intialized '
+ 'Volume Group: %s'), self.configuration.volume_group)
+ return
- # FIXME(jdg): Fix up the duplicate code between
- # LVM, LVMISCSI and ISER starting with this section
- LOG.debug(_("Updating volume status"))
+ self.vg.update_volume_group_info()
data = {}
- backend_name = self.configuration.safe_get('volume_backend_name')
- data["volume_backend_name"] = backend_name or 'LVM'
+ # Note(zhiteng): These information are driver/backend specific,
+ # each driver may define these values in its own config options
+ # or fetch from driver specific configuration file.
+ data["volume_backend_name"] = self.backend_name
data["vendor_name"] = 'Open Source'
data["driver_version"] = self.VERSION
- data["storage_protocol"] = 'local'
+ data["storage_protocol"] = self.protocol
data['total_capacity_gb'] = float(self.vg.vg_size)
data['free_capacity_gb'] = float(self.vg.vg_free_space)
root_helper = 'sudo cinder-rootwrap %s' % CONF.rootwrap_config
self.tgtadm = iscsi.get_target_admin(root_helper)
super(LVMISCSIDriver, self).__init__(*args, **kwargs)
+ self.backend_name =\
+ self.configuration.safe_get('volume_backend_name') or 'LVM_iSCSI'
+ self.protocol = 'iSCSI'
def set_execute(self, execute):
super(LVMISCSIDriver, self).set_execute(execute)
return (True, model_update)
- def get_volume_stats(self, refresh=False):
- """Get volume stats.
-
- If 'refresh' is True, run update the stats first.
- """
- if refresh:
- self._update_volume_stats()
-
- return self._stats
-
- def _update_volume_stats(self):
- """Retrieve stats info from volume group."""
-
- LOG.debug(_("Updating volume stats"))
- self.vg.update_volume_group_info()
- data = {}
-
- # Note(zhiteng): These information are driver/backend specific,
- # each driver may define these values in its own config options
- # or fetch from driver specific configuration file.
- backend_name = self.configuration.safe_get('volume_backend_name')
- data["volume_backend_name"] = backend_name or 'LVM_iSCSI'
- data["vendor_name"] = 'Open Source'
- data["driver_version"] = self.VERSION
- data["storage_protocol"] = 'iSCSI'
-
- data['total_capacity_gb'] = float(self.vg.vg_size)
- data['free_capacity_gb'] = float(self.vg.vg_free_space)
- data['reserved_percentage'] = self.configuration.reserved_percentage
- data['QoS_support'] = False
- data['location_info'] =\
- ('LVMVolumeDriver:%(hostname)s:%(vg)s'
- ':%(lvm_type)s:%(lvm_mirrors)s' %
- {'hostname': self.hostname,
- 'vg': self.configuration.volume_group,
- 'lvm_type': self.configuration.lvm_type,
- 'lvm_mirrors': self.configuration.lvm_mirrors})
-
- self._stats = data
-
def _iscsi_location(self, ip, target, iqn, lun=None):
return "%s:%s,%s %s %s" % (ip, self.configuration.iscsi_port,
target, iqn, lun)
root_helper = 'sudo cinder-rootwrap %s' % CONF.rootwrap_config
self.tgtadm = iser.get_target_admin(root_helper)
LVMVolumeDriver.__init__(self, *args, **kwargs)
+ self.backend_name =\
+ self.configuration.safe_get('volume_backend_name') or 'LVM_iSER'
+ self.protocol = 'iSER'
def set_execute(self, execute):
LVMVolumeDriver.set_execute(self, execute)
self.tgtadm.remove_iser_target(iser_target, 0, volume['id'],
volume['name'])
- def _update_volume_status(self):
- """Retrieve status info from volume group."""
-
- LOG.debug(_("Updating volume status"))
- self.vg.update_volume_group_info()
- data = {}
-
- # Note(zhiteng): These information are driver/backend specific,
- # each driver may define these values in its own config options
- # or fetch from driver specific configuration file.
- backend_name = self.configuration.safe_get('volume_backend_name')
- data["volume_backend_name"] = backend_name or 'LVM_iSER'
- data["vendor_name"] = 'Open Source'
- data["driver_version"] = self.VERSION
- data["storage_protocol"] = 'iSER'
- data['total_capacity_gb'] = float(self.vg.vg_size)
- data['free_capacity_gb'] = float(self.vg.vg_free_space)
-
- data['reserved_percentage'] = self.configuration.reserved_percentage
- data['QoS_support'] = False
-
- self._stats = data
-
def _iser_location(self, ip, target, iqn, lun=None):
return "%s:%s,%s %s %s" % (ip, self.configuration.iser_port,
target, iqn, lun)
LOG.info(_("Starting volume driver %(driver_name)s (%(version)s)") %
{'driver_name': self.driver.__class__.__name__,
'version': self.driver.get_version()})
- self.driver.do_setup(ctxt)
- self.driver.check_for_setup_error()
+ try:
+ self.driver.do_setup(ctxt)
+ self.driver.check_for_setup_error()
+ except Exception:
+ LOG.error(_("Error encountered during "
+ "initialization of driver: %s"),
+ self.driver.__class__.__name__)
volumes = self.db.volume_get_all_by_host(ctxt, self.host)
LOG.debug(_("Re-exporting %s volumes"), len(volumes))
LOG.info(_('Resuming delete on volume: %s') % volume['id'])
self.delete_volume(ctxt, volume['id'])
+ self.driver.set_initialized()
+
# collect and publish service capabilities
self.publish_service_capabilities(ctxt)
@periodic_task.periodic_task
def _report_driver_status(self, context):
LOG.info(_("Updating volume status"))
- volume_stats = self.driver.get_volume_stats(refresh=True)
- if volume_stats:
- # This will grab info about the host and queue it
- # to be sent to the Schedulers.
- self.update_service_capabilities(volume_stats)
+ if not self.driver.initialized:
+ LOG.warning(_('Unabled to update stats, driver is '
+ 'uninitialized'))
+ else:
+ volume_stats = self.driver.get_volume_stats(refresh=True)
+ if volume_stats:
+ # This will grab info about the host and queue it
+ # to be sent to the Schedulers.
+ self.update_service_capabilities(volume_stats)
def publish_service_capabilities(self, context):
"""Collect driver status and then publish."""