Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions cinderback.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sys
import time

import keystoneauth1
from cinderclient import client
from cinderclient import v2
from cinderclient import __version__ as cinder_version
Expand Down Expand Up @@ -778,18 +779,28 @@ def export_metadata(self, filename, all_tenants=False):

def get_client(self, tenant_id, keep_tenant=True):
"""Return a client for requested tenant"""
# If we are the original tenant of the volume
if (not keep_tenant or
self.client.client.auth_ref['token']['tenant']['id']
== tenant_id):
if not keep_tenant:
return self.client

_LI("Using tenant id %s", tenant_id)
return client.Client(version=2,
username=self.username,
api_key=self.api_key,
tenant_id=tenant_id,
auth_url=self.auth_url)
auth_ref = self.client.client.auth_ref

# Get project ID for Keystone V3
if isinstance(auth_ref, keystoneauth1.access.access.AccessInfoV3):
auth_project_id = auth_ref.project_id
# Get project ID for Keystone v2
else:
auth_project_id = auth_ref['token']['tenant']['id']

if auth_project_id == tenant_id:
return self.client
else:

_LI("Using tenant id %s", tenant_id)
return client.Client(version=2,
username=self.username,
api_key=self.api_key,
tenant_id=tenant_id,
auth_url=self.auth_url)

def import_metadata(self, filename):
"""Import backup metadata to DB from file."""
Expand Down