예제 #1
0
 def _get_manager(self, backend):
     LOG.debug("Manager requested for volume_backend '%s'.", backend)
     if backend is None:
         LOG.debug("Fetching default backend.")
         backend = self._get_volume_backend(allow_null_host=True)
     if backend not in self.volume_managers:
         msg = (_("Volume manager for backend '%s' does not exist.") %
                (backend))
         raise exception.BackupFailedToGetVolumeBackend(msg)
     return self.volume_managers[backend]
예제 #2
0
    def _get_volume_backend(self, host=None, allow_null_host=False):
        if host is None:
            if not allow_null_host:
                msg = _("NULL host not allowed for volume backend lookup.")
                raise exception.BackupFailedToGetVolumeBackend(msg)
        else:
            LOG.debug("Checking hostname '%s' for backend info.", host)
            part = host.partition('@')
            if (part[1] == '@') and (part[2] != ''):
                backend = part[2]
                LOG.debug("Got backend '%s'.", backend)
                return backend

        LOG.info(_LI("Backend not found in hostname (%s) so using default."),
                 host)

        if 'default' not in self.volume_managers:
            # For multi-backend we just pick "first" from volume managers dict
            return next(iter(self.volume_managers))

        return 'default'
    def _get_volume_backend(self, host=None, allow_null_host=False):
        if host is None:
            if not allow_null_host:
                msg = _("NULL host not allowed for volume backend lookup.")
                raise exception.BackupFailedToGetVolumeBackend(msg)
        else:
            LOG.debug("Checking hostname '%s' for backend info." % (host))
            part = host.partition('@')
            if (part[1] == '@') and (part[2] != ''):
                backend = part[2]
                LOG.debug("Got backend '%s'." % (backend))
                return backend

        LOG.info(
            _("Backend not found in hostname (%s) so using default.") % (host))

        if 'default' not in self.volume_managers:
            # For multi-backend we just pick the top of the list.
            return self.volume_managers.keys()[0]

        return 'default'
예제 #4
0
    def _get_volume_backend(self, host=None, allow_null_host=False):
        if host is None:
            if not allow_null_host:
                msg = _("NULL host not allowed for volume backend lookup.")
                raise exception.BackupFailedToGetVolumeBackend(msg)
        else:
            LOG.debug("Checking hostname '%s' for backend info.", host)
            # NOTE(xyang): If host='myhost@lvmdriver', backend='lvmdriver'
            # by the logic below. This is different from extract_host.
            # vol_utils.extract_host(host, 'backend')='myhost@lvmdriver'.
            part = host.partition('@')
            if (part[1] == '@') and (part[2] != ''):
                backend = part[2]
                LOG.debug("Got backend '%s'.", backend)
                return backend

        LOG.info("Backend not found in hostname (%s) so using default.", host)

        if 'default' not in self.volume_managers:
            # For multi-backend we just pick the top of the list.
            return next(iter(self.volume_managers))

        return 'default'