def test_load_keystone(self): """test_load_keystone check that we could build a map from keystone resources using Direct_objects directive.""" environ.setdefault('KEYSTONE_ADMIN_ENDPOINT', self.OS_AUTH_URL) openstackmap = OpenStackMap(auto_load=False, objects_strategy=OpenStackMap.DIRECT_OBJECTS) openstackmap.load_keystone() self.assertIsNotNone(openstackmap)
def test_load_keystone(self): """test_load_keystone check that we could build a map from keystone resources using Direct_objects directive.""" environ.setdefault('KEYSTONE_ADMIN_ENDPOINT', self.OS_AUTH_URL) openstackmap = OpenStackMap( auto_load=False, objects_strategy=OpenStackMap.DIRECT_OBJECTS) openstackmap.load_keystone() self.assertIsNotNone(openstackmap)
def __init__(self): """constructor""" self.logger = logging.getLogger(__name__) OpenStackMap.load_filters = False osmap = OpenStackMap(objects_strategy=OpenStackMap.NO_CACHE_OBJECTS, auto_load=False) osmap.load_keystone() osmap.load_neutron() self.map = osmap self.neutron = self.map.osclients.get_neutronclient()
def __init__(self): """constructor""" self.logger = logging.getLogger(__name__) OpenStackMap.load_filters = False osmap = OpenStackMap(objects_strategy=OpenStackMap.NO_CACHE_OBJECTS, auto_load=False) osmap.load_keystone() osmap.load_neutron() self.map = osmap self.neutron = self.map.osclients.get_neutronclient()
def get_email_osclient(username, password, region): """ Get the list of user of one region taking into account a bottom-up analysis. :param username: The name of the admin user that launch the request. :param password: The password of the admin user. :param region: The region in which we want to obtain the data. :return: The emaillist. """ print("Making analysis bottom-up...") # Set environment variables os.environ['OS_USERNAME'] = username os.environ['OS_PASSWORD'] = password os.environ['OS_TENANT_NAME'] = 'admin' os.environ['OS_REGION_NAME'] = region os.environ['KEYSTONE_ADMIN_ENDPOINT'] = 'http://cloud.lab.fiware.org:4730/' os.environ['OS_AUTH_URL'] = 'http://cloud.lab.fiware.org:4730/v2.0' # load data from servers map = OpenStackMap('tmp_cache', auto_load=False) map.load_keystone() # Get region filters and empty filter regions_filters = dict() empty_filter = None for filter in map.filters.values(): if 'region_id' in filter['filters']: regions_filters[filter['filters']['region_id']] = filter['id'] elif not filter['filters']: empty_filter = filter['id'] useremail = dict() # Get users. Genuine FIWARE Users should have cloud_project_id. Be aware that # there are users without this field (administrators and also other users) for user in map.users.values(): if 'cloud_project_id' not in user: continue project_id = user['cloud_project_id'] found = False if project_id not in map.filters_by_project: found = False else: for filter in map.filters_by_project[project_id]: if filter == regions_filters[region] or filter == empty_filter: found = True break if found: useremail[user.id] = user.name return useremail