def run(self, users_file): __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) admins = json.load(open(os.path.join(__location__, users_file))) keystone = _admin_token_connection() for user_name in admins: user = keystone.users.find(name=user_name) res = keystone.users.update(user, username=user_name) print user_name, res print 'Done.'
def run(self, keystone_path=settings.KEYSTONE_ROOT): __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) admins = json.load(open(os.path.join(__location__, 'keystone_admins.json'))) keystone = _admin_token_connection() admin_project = keystone.projects.find(name='admin') import pdb; pdb.set_trace() for user_name in admins: user = keystone.users.find(name=user_name) res = keystone.users.update(user, default_project=admin_project) print user_name, res print 'Done.'
def run(self, keystone_path=settings.KEYSTONE_ROOT): keystone = _admin_token_connection() # migration old ids not configured raise Exception() # Keystone services self._create_services_and_endpoints(keystone) # Enpoint groups self._create_endpoint_group_filters(keystone) keystone_roles = self._create_keystone_roles(keystone) idm_user = self._create_idm_user_and_project(keystone, keystone_roles) # user our migration method here to asign ids to roles and permissions idm_app = self._create_internal_roles_and_permissions(keystone) # Make the idm user administrator self._grant_administrator(keystone, idm_app, [idm_user])
def run(self, keystone_path=settings.KEYSTONE_ROOT): __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) admins = json.load( open(os.path.join(__location__, 'keystone_admins.json'))) keystone = _admin_token_connection() admin_project = keystone.projects.find(name='admin') import pdb pdb.set_trace() for user_name in admins: user = keystone.users.find(name=user_name) res = keystone.users.update(user, default_project=admin_project) print user_name, res print 'Done.'
def run(self, keystone_path=settings.KEYSTONE_ROOT): __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) categories = json.load( open(os.path.join(__location__, 'categories.json'))) keystone = _admin_token_connection() self.trial_role = keystone.roles.find(name='trial') self.community_role = keystone.roles.find(name='community') self.basic_role = keystone.roles.find(name='basic') for data in categories: user_id = data['user_id'] role_id = data['role_id'] region_id = data.get('region_id', None) if (role_id == self.trial_role.id and not region_id): region_id = 'Spain2' if role_id == self.community_role.id and not region_id: print('ERROR: {0} community with no region'.format(user_id)) continue if role_id == self.basic_role.id and region_id: region_id = None print('WARNING: {0} basic with region, ignoring it'.format( user_id)) if role_id not in [ self.trial_role.id, self.basic_role.id, self.community_role.id ]: print('ERROR: {0} invalid role_id {1}'.format( user_id, role_id)) continue self.update_account(keystone, user_id, role_id, region_id)
def run(self, keystone_path=settings.KEYSTONE_ROOT): keystone = _admin_token_connection() all_users = keystone.users.list() for user in all_users: if not hasattr(user, 'cloud_project_id'): print 'Skip {0}, no cloud project id'.format(user.name) continue try: keystone.endpoint_groups.add_endpoint_group_to_project( project=user.cloud_project_id, endpoint_group=NO_FILTER_ENDPOINT_GROUP_ID) print '200 OK {0}'.format(user.name) except exceptions.Conflict: print '409 User {0} already has it'.format(user.name) except exceptions.NotFound: print '404 Not found project {0} for user {1}'.format( user.cloud_project_id, user.name) print 'Done.'
def run(self, keystone_path=settings.KEYSTONE_ROOT): __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) categories = json.load(open(os.path.join(__location__, 'categories.json'))) keystone = _admin_token_connection() self.trial_role = keystone.roles.find(name='trial') self.community_role = keystone.roles.find(name='community') self.basic_role = keystone.roles.find(name='basic') for data in categories: user_id = data['user_id'] role_id = data['role_id'] region_id = data.get('region_id', None) if (role_id == self.trial_role.id and not region_id): region_id = 'Spain2' if role_id == self.community_role.id and not region_id: print ('ERROR: {0} community with no region'.format(user_id)) continue if role_id == self.basic_role.id and region_id: region_id = None print ('WARNING: {0} basic with region, ignoring it'.format(user_id)) if role_id not in [self.trial_role.id, self.basic_role.id, self.community_role.id]: print ('ERROR: {0} invalid role_id {1}'.format(user_id, role_id)) continue self.update_account(keystone, user_id, role_id, region_id)