def get_datasources_tables_data(self): try: datasources = congress.datasources_list(self.request) except Exception as e: msg = _('Unable to get services list: %s') % e.message messages.error(self.request, msg) return [] ds_temp = [] for ds in datasources: ds_id = ds['id'] try: ds_tables = congress.datasource_tables_list(self.request, ds_id) except Exception as e: msg_args = {'ds_id': ds_id, 'error': e.message} msg = _('Unable to get tables list for service "%(ds_id)s": ' '%(error)s') % msg_args messages.error(self.request, msg) return [] for table in ds_tables: table.set_value('datasource_id', ds_id) table.set_value('datasource_name', ds['name']) table.set_value('datasource_driver', ds['driver']) table.set_id_as_name_if_empty() ds_temp.append(table) logger.info("ds_temp %s" % ds_temp) return ds_temp
def _get_service_tables(request): # Return all service tables. all_tables = [] try: # Get all the services. services = congress.datasources_list(request) except Exception as e: LOG.error('Unable to get list of data sources: %s' % e.message) else: try: for service in services: # Get all the tables in this service. service_id = service['id'] service_tables = congress.datasource_tables_list(request, service_id) # Get the names of the tables. datasource_tables = [] for table in service_tables: table.set_id_as_name_if_empty() datasource_tables.append(table['name']) all_tables.append({'datasource': service['name'], 'tables': datasource_tables}) except Exception as e: LOG.error('Unable to get tables for data source "%s": %s' % (service_id, e.message)) return all_tables
def get_datasources_tables_data(self): try: datasources = congress.datasources_list(self.request) except Exception as e: msg = _('Unable to get services list: %s') % e.message messages.error(self.request, msg) return [] ds_temp = [] for ds in datasources: ds_id = ds['id'] try: ds_tables = congress.datasource_tables_list( self.request, ds_id) except Exception as e: msg_args = {'ds_id': ds_id, 'error': e.message} msg = _('Unable to get tables list for service "%(ds_id)s": ' '%(error)s') % msg_args messages.error(self.request, msg) return [] for table in ds_tables: table.set_value('datasource_id', ds_id) table.set_value('datasource_name', ds['name']) table.set_value('datasource_driver', ds['driver']) table.set_id_as_name_if_empty() ds_temp.append(table) logger.info("ds_temp %s" % ds_temp) return ds_temp
def get_datasources_tables_data(self): try: datasources = congress.datasources_list(self.request) except Exception as e: msg = _('Unable to get services list: %s') % e.message messages.error(self.request, msg) return [] ds_temp = [] for ds in datasources: ds_id = ds['id'] try: ds_tables = congress.datasource_tables_list(self.request, ds_id) except Exception as e: msg_args = {'ds_id': ds_id, 'error': e.message} msg = _('Unable to get tables list for service "%(ds_id)s": ' '%(error)s') % msg_args messages.error(self.request, msg) return [] for table in ds_tables: table.set_value('datasource_id', ds_id) table.set_value('datasource_name', ds['name']) table.set_value('datasource_driver', ds['driver']) table.set_id_as_name_if_empty() # Object ids within a Horizon table must be unique. Otherwise, # Horizon will cache the column values for the object by id and # use the same column values for all rows with the same id. table.set_value('table_id', table['id']) table.set_value('id', '%s-%s' % (ds_id, table['table_id'])) ds_temp.append(table) logger.debug("ds_temp %s" % ds_temp) return ds_temp
def get_datasources_tables_data(self): try: ds1 = congress.datasources_list(self.request) except Exception as e: msg = _('Unable to get plugins list: %s') % e.message messages.error(self.request, msg) return [] ds_temp = [] for d1 in ds1: s = d1['id'] owner_id = d1['owner_id'] try: ds = congress.datasource_tables_list(self.request, s) except Exception as e: msg_args = {'ds_name': s, 'error': e.message} msg = _('Unable to get tables list for plugin "%(ds_name)s": ' '%(error)s') % msg_args messages.error(self.request, msg) return [] for d in ds: d.set_value('datasource', s) d.set_value('owner_id', owner_id) d.set_id_as_name_if_empty() ds_temp.append(d) logger.info("ds_temp %s" % ds_temp) return ds_temp