Adds the tenant_filter_file to the config file
tenant_filter_file is the path to a file that contains a list of tenant ids to migrate. If missing, swsync will migrate all the tenants.
This commit is contained in:
@@ -21,3 +21,9 @@ filler_keystone_client_concurrency = 5
|
|||||||
filler_swift_client_concurrency = 10
|
filler_swift_client_concurrency = 10
|
||||||
# This is usually bound to the max open files.
|
# This is usually bound to the max open files.
|
||||||
sync_swift_client_concurrency = 10
|
sync_swift_client_concurrency = 10
|
||||||
|
|
||||||
|
[sync]
|
||||||
|
# This fields holds the path the a file containing the list of tenant ids to
|
||||||
|
# migrate. If this field is left blank or commented out, swsync will migrate all
|
||||||
|
# the tenants.
|
||||||
|
tenant_filter_file =
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import keystoneclient.v2_0.client
|
|||||||
import swiftclient
|
import swiftclient
|
||||||
|
|
||||||
import swsync.containers
|
import swsync.containers
|
||||||
from utils import get_config
|
from utils import get_config, ConfigurationError
|
||||||
|
|
||||||
|
|
||||||
class Accounts(object):
|
class Accounts(object):
|
||||||
@@ -52,6 +52,22 @@ class Accounts(object):
|
|||||||
password=password,
|
password=password,
|
||||||
tenant_name=tenant_name)
|
tenant_name=tenant_name)
|
||||||
|
|
||||||
|
def get_target_tenant_filter(self):
|
||||||
|
"""Returns a set of target tenants from the tenant_list_file.
|
||||||
|
tenant_list_file is defined in the config file or given as a command
|
||||||
|
line argument.
|
||||||
|
|
||||||
|
If the file is not defined, returns None.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
tenant_filter_filename = get_config('sync', 'tenant_filter_file')
|
||||||
|
|
||||||
|
with open(tenant_filter_filename) as tenantsfile:
|
||||||
|
return {name.strip() for name in tenantsfile.readlines()}
|
||||||
|
except (ConfigurationError, IOError):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def account_headers_clean(self, account_headers, to_null=False):
|
def account_headers_clean(self, account_headers, to_null=False):
|
||||||
ret = {}
|
ret = {}
|
||||||
for key, value in account_headers.iteritems():
|
for key, value in account_headers.iteritems():
|
||||||
@@ -160,7 +176,16 @@ class Accounts(object):
|
|||||||
|
|
||||||
self.keystone_cnx = self.get_ks_auth_orig()
|
self.keystone_cnx = self.get_ks_auth_orig()
|
||||||
|
|
||||||
for tenant in self.keystone_cnx.tenants.list():
|
# if user has defined target tenants, limit the migration
|
||||||
|
# to them
|
||||||
|
_targets_filters = self.get_target_tenant_filter()
|
||||||
|
if _targets_filters is not None:
|
||||||
|
_targets = (tenant for tenant in self.keystone_cnx.tenants.list()
|
||||||
|
if tenant.id in _targets)
|
||||||
|
else:
|
||||||
|
_targets = self.keystone_cnx.tenants.list()
|
||||||
|
|
||||||
|
for tenant in _targets:
|
||||||
user_orig_st_url = bare_oa_st_url + tenant.id
|
user_orig_st_url = bare_oa_st_url + tenant.id
|
||||||
user_dst_st_url = bare_dst_st_url + tenant.id
|
user_dst_st_url = bare_dst_st_url + tenant.id
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user