def volume_client(self): if self._volume_client: return self._volume_client if not ceph_module_found: raise exception.ManilaException( _("Ceph client libraries not found.") ) conf_path = self.configuration.safe_get('cephfs_conf_path') cluster_name = self.configuration.safe_get('cephfs_cluster_name') auth_id = self.configuration.safe_get('cephfs_auth_id') self._volume_client = ceph_volume_client.CephFSVolumeClient( auth_id, conf_path, cluster_name) LOG.info(_LI("[%(be)s}] Ceph client found, connecting..."), {"be": self.backend_name}) if auth_id != CEPH_DEFAULT_AUTH_ID: # Evict any other manila sessions. Only do this if we're # using a client ID that isn't the default admin ID, to avoid # rudely disrupting anyone else. premount_evict = auth_id else: premount_evict = None try: self._volume_client.connect(premount_evict=premount_evict) except Exception: self._volume_client = None raise else: LOG.info(_LI("[%(be)s] Ceph client connection complete."), {"be": self.backend_name}) return self._volume_client
def volume_client(self): if self._volume_client: return self._volume_client if not ceph_module_found: raise ValueError("Ceph client libraries not found.") try: cluster_name = os.environ["CEPH_CLUSTER_NAME"] except KeyError: cluster_name = "ceph" try: mons = os.environ["CEPH_MON"] except KeyError: raise ValueError("Missing CEPH_MON env") try: auth_id = os.environ["CEPH_AUTH_ID"] except KeyError: raise ValueError("Missing CEPH_AUTH_ID") try: auth_key = os.environ["CEPH_AUTH_KEY"] except: raise ValueError("Missing CEPH_AUTH_KEY") conf_path = self._create_conf(cluster_name, mons) self._create_keyring(cluster_name, auth_id, auth_key) self._volume_client = ceph_volume_client.CephFSVolumeClient( auth_id, conf_path, cluster_name, volume_prefix = self.volume_prefix) try: self._volume_client.connect(None) except Exception: self._volume_client = None raise return self._volume_client