Exemple #1
0
 def get_view(self):
     view = View()
     view.title = self.title.data
     view.link_name = self.link_name.data
     view.datasource = self.datasource.data
     view.description = self.description.data
     view.link_title = self.link_title.data
     view.buttontext = self.buttontext.data
     view.reload_intervall = self.reload_intervall.data
     view.layout_number_columns = self.layout_number_columns.data
     view.basic_layout = self.basic_layout.data
     return view
Exemple #2
0
 def get_view(self):
     view = View()
     view.title = self.title.data
     view.link_name = self.link_name.data
     view.datasource = self.datasource.data
     view.buttontext = self.buttontext.data
     view.reload_intervall = self.reload_intervall.data
     view.layout_number_columns = self.layout_number_columns.data
     return view
Exemple #3
0
def create_default_views():

    #######################
    # All hosts view
    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')
    setattr(filters, 'host_option', 'show')
    setattr(filters, 'host_state_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.first()
    view = View()
    view.title = 'All hosts'
    view.link_name = 'allhosts'
    view.description = 'Overall state of allhosts, with counts of services in the various states.'
    view.datasource = 'hosts'
    view.filters_id = filters.id
    view.layout_number_columns = 2
    db_session.add(view)
    db_session.commit()
    view = (View.query.filter_by(link_name=view.link_name).first())

    __add_column('host_name', view, 'host')
    __add_column('host_state', view)
    __add_column('last_check', view)

    #######################
    # All services view
    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')
    setattr(filters, 'host_option', 'show')
    setattr(filters, 'host_state_option', 'show')
    setattr(filters, 'service_state_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[1]
    view = View()
    view.title = 'All services'
    view.link_name = 'allservices'
    view.description = _('All services grouped\r\nby hosts.')
    view.datasource = 'services'
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_description', view, 'service')
    __add_column('service_state', view)
    __add_group_by('site', view)
    __add_group_by('host_name', view)

    ##########################
    # Host view
    filters = ViewFilters()
    setattr(filters, 'host_option', 'hide')
    setattr(filters, 'site_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[2]
    view = View()
    view.title = 'Services of Host'
    view.link_name = 'host'
    view.datasource = 'services'
    view.description = _('All services of a given host.')
    view.link_title = _('Services')
    view.layout_number_columns = 1
    view.basic_layout = 'table'
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_state', view)
    __add_column('service_description', view)
    __add_column('service_plugin_output', view)
    __add_column('check_command', view)

    ##########################
    # Service view
    filters = ViewFilters()
    setattr(filters, 'service_option', 'hide')
    setattr(filters, 'host_option', 'hide')
    setattr(filters, 'site_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[3]
    view = View()
    view.title = 'Service'
    view.link_name = 'service'
    view.link_title = 'Service details'
    view.datasource = 'services'
    view.description = 'Status of a single service, to be used for linking'
    view.layout_number_columns = 1
    view.basic_layout = 'single'
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    # add all columns for a service
    for column in get_columns_name('services'):
        if column:
            __add_column(column, view)

    ##########################################
    # CRIT Services of host
    filters = ViewFilters()
    setattr(filters, 'service_state_option', 'hard')
    setattr(filters, 'service_state_ok', False)
    setattr(filters, 'service_state_warning', False)
    setattr(filters, 'service_state_critical', True)
    setattr(filters, 'service_state_unknown', False)

    setattr(filters, 'site_option', 'hide')
    setattr(filters, 'host_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[4]
    view = View()
    view.title = 'CRIT Services of host'
    view.link_name = 'host_crit'
    view.link_title = 'Services: CRIT'
    view.datasource = 'services'
    view.description = 'All services of a given host that are in state CRIT'
    view.layout_number_columns = 2
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_state', view)
    __add_column('service_description', view)
    __add_column('service_plugin_output', view)
    __add_column('last_check', view) 

    ##########################################
    # Host problems
    
    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')
 
    setattr(filters, 'host_state_option', 'hard')
    setattr(filters, 'host_state_up', False)
    setattr(filters, 'host_state_down', True)
    setattr(filters, 'host_state_unreach', True)
    setattr(filters, 'host_state_pending', False)

    setattr(filters, 'is_host_scheduled_downtime_depth_option', 'hard')
    setattr(filters, 'is_host_scheduled_downtime_depth', '0')
    
    setattr(filters, 'is_host_acknowledged_option', 'show')

    setattr(filters, 'is_summary_host_option', 'show')
    setattr(filters, 'is_summary_host', '0')

    setattr(filters, 'is_host_in_notification_period_option', 'show')   

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[5]
    view = View()
    view.title = 'Host problems'
    view.link_name = 'hostproblems'
    view.datasource = 'hosts'
    view.description = 'A complete list of all host problems with a search form for selecting handled and unhandled' 
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('host_name', view, 'host')
    __add_column('host_state', view)
    __add_column('plugin_output', view)
    __add_column('num_services_ok', view)
    __add_column('num_services_warn', view)
    __add_column('num_services_crit', view)
    __add_column('num_services_unknown', view)
    __add_column('num_services_pending', view)

     ##########################################
    # Services problems

    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')

    setattr(filters, 'host_state_option', 'show')
    setattr(filters, 'host_state_up', True)
    setattr(filters, 'host_state_down', False)
    setattr(filters, 'host_state_unreach', False)
    setattr(filters, 'host_state_pending', True)

    setattr(filters, 'service_state_option', 'hard')
    setattr(filters, 'service_state_ok', False)
    setattr(filters, 'service_state_warning', True)
    setattr(filters, 'service_state_critical', True)
    setattr(filters, 'service_state_unknown', True)
    setattr(filters, 'service_state_pending', False)

    setattr(filters, 'is_host_scheduled_downtime_depth_option', 'hard')
    setattr(filters, 'is_host_scheduled_downtime_depth', '0')

    setattr(filters, 'is_service_acknowledged_option', 'show')
    setattr(filters, 'is_service_acknowledged', '-1')

    setattr(filters, 'is_summary_host_option', 'show')
    setattr(filters, 'is_summary_host', '0')

    setattr(filters, 'is_service_in_notification_period_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[6]
    view = View()
    view.title = _('Service problems')
    view.link_name = 'svcproblems'
    view.datasource = 'services'
    view.description = 'All problems of services not currently in a downtime.'
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('host_name', view, 'host')
    __add_column('service_description', view, 'service')
    __add_column('service_plugin_output', view)
    __add_column('last_check', view)
Exemple #4
0
 def set_view_dummy(self, datasource):
     self.__view = View()
     self.__view.datasource = datasource
Exemple #5
0
class ViewManager():
    """ A sort of proxy that facilitate views modification and views queries. """
    def __init__(self):
        self.__view = None
        self.__columns = None 
        self.__groupers = None
        self.__sorters = None
        self.__filters = None
    '''
    Set the view with the link_name. If a view is found, return the view found 
    '''
    def set_view(self, link_name):
        self.__view = View.query.filter_by(link_name=link_name).first()
        if self.__view:
            self.__columns = ViewColumn.query.filter_by(parent_id=self.__view.id).order_by(ViewColumn.id).all()
            self.__groupers = ViewGrouper.query.filter_by(parent_id=self.__view.id).order_by(ViewGrouper.id).all()
            self.__sorters = ViewSorter.query.filter_by(parent_id=self.__view.id).order_by(ViewSorter.id).all()
            self.__filters = self.__view.filters 
            return self.__view 
        else:
            return None
    
    def set_view_dummy(self, datasource):
        self.__view = View()
        self.__view.datasource = datasource

    def add_columns(self, columns, delete_before = False):
        if delete_before:
            for column in self.__columns:
                    db_session.delete(column)

        for column in columns:
            db_session.add(column)
        
        db_session.commit()

    def add_groupers(self, groupers, delete_before = False):
        if delete_before:
            for grouper in self.__groupers:
                    db_session.delete(grouper)

        for grouper in groupers:
            if grouper.column:
                db_session.add(grouper)
        
        db_session.commit()

    def add_sorters(self, sorters, delete_before = False):
        if delete_before:
            for sorter in self.__sorters:
                    db_session.delete(sorter)

        for sorter in sorters:
            if sorter.column:
                db_session.add(sorter)

        db_session.commit()

    def add_view(self, view):
        db_session.add(view)
        db_session.commit()
        
    def add_filters(self, filters):
        self.__view.filters = filters
        db_session.commit()

    def set_filters(self, filters):
        self.__filters.set_filters(filters)
    
    def set_extra_sorters(self, sorters):
        for colname, order in sorters.items():
            sorter = ViewSorter()
            sorter.column = colname
            sorter.sorter_option = order
            [self.__sorters.remove(sorter_item) for sorter_item in self.__sorters if sorter_item.column == colname]
            self.__sorters.append(sorter)

    def update_filters(self, filters):
        self.__view.filters.update(filters)
        db_session.commit()

    def get_filters(self):
        return self.__filters

    def get_columns_choices(self):
        return get_columns_pairs(self.__view.datasource)

    def get_columns(self):
        return self.__columns

    def get_sorters(self):
        return self.__sorters

    def get_sorters_columns(self):
        lst_columns = []
        for sorter in self.__sorters:
            lst_columns.append(sorter.column)
        return lst_columns

    def get_groupers(self):
        return self.__groupers
    
    def get_filter_display(self, form):
        lst_columns = cache_columns 
        lst_info = []
        for option, fil_col_names in lst_columns.iteritems():
            filter_name = option.replace("_option","")
            col_names = filters[filter_name].column_names
            filter_datasources = []
            for col_name in col_names:
                if painters.has_key(col_name):
                    filter_datasources = filter_datasources + painters[col_name].datasources
                if self.__view.datasource in filter_datasources:
                    option_field = getattr(form, option)
                    fields = []
                    for col in fil_col_names: 
                        fields.append(getattr(form, col))
                    lst_info.append(FilterFieldsInfo(option_field, fields))
        return lst_info
    
    def get_view(self):
        return self.__view

    def update_view(self, view):
        self.__view.update_view(view)
        db_session.commit()
Exemple #6
0
def create_default_views():

    #######################
    # All hosts view
    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')
    setattr(filters, 'host_option', 'show')
    setattr(filters, 'host_state_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.first()
    view = View()
    view.title = 'All hosts'
    view.link_name = 'allhosts'
    view.description = 'Overall state of allhosts, with counts of services in the various states.'
    view.datasource = 'hosts'
    view.filters_id = filters.id
    view.layout_number_columns = 2
    db_session.add(view)
    db_session.commit()
    view = (View.query.filter_by(link_name=view.link_name).first())

    __add_column('host_name', view, 'host')
    __add_column('host_state', view)
    __add_column('last_check', view)

    #######################
    # All services view
    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')
    setattr(filters, 'host_option', 'show')
    setattr(filters, 'host_state_option', 'show')
    setattr(filters, 'service_state_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[1]
    view = View()
    view.title = 'All services'
    view.link_name = 'allservices'
    view.description = _('All services grouped\r\nby hosts.')
    view.datasource = 'services'
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_description', view, 'service')
    __add_column('service_state', view)
    __add_group_by('site', view)
    __add_group_by('host_name', view)

    ##########################
    # Host view
    filters = ViewFilters()
    setattr(filters, 'host_option', 'hide')
    setattr(filters, 'site_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[2]
    view = View()
    view.title = 'Services of Host'
    view.link_name = 'host'
    view.datasource = 'services'
    view.description = _('All services of a given host.')
    view.link_title = _('Services')
    view.layout_number_columns = 1
    view.basic_layout = 'table'
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_state', view)
    __add_column('service_description', view)
    __add_column('service_plugin_output', view)
    __add_column('check_command', view)

    ##########################
    # Service view
    filters = ViewFilters()
    setattr(filters, 'service_option', 'hide')
    setattr(filters, 'host_option', 'hide')
    setattr(filters, 'site_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[3]
    view = View()
    view.title = 'Service'
    view.link_name = 'service'
    view.link_title = 'Service details'
    view.datasource = 'services'
    view.description = 'Status of a single service, to be used for linking'
    view.layout_number_columns = 1
    view.basic_layout = 'single'
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    # add all columns for a service
    for column in get_columns_name('services'):
        if column:
            __add_column(column, view)

    ##########################################
    # CRIT Services of host
    filters = ViewFilters()
    setattr(filters, 'service_state_option', 'hard')
    setattr(filters, 'service_state_ok', False)
    setattr(filters, 'service_state_warning', False)
    setattr(filters, 'service_state_critical', True)
    setattr(filters, 'service_state_unknown', False)

    setattr(filters, 'site_option', 'hide')
    setattr(filters, 'host_option', 'hide')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[4]
    view = View()
    view.title = 'CRIT Services of host'
    view.link_name = 'host_crit'
    view.link_title = 'Services: CRIT'
    view.datasource = 'services'
    view.description = 'All services of a given host that are in state CRIT'
    view.layout_number_columns = 2
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('service_state', view)
    __add_column('service_description', view)
    __add_column('service_plugin_output', view)
    __add_column('last_check', view)

    ##########################################
    # Host problems

    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')

    setattr(filters, 'host_state_option', 'hard')
    setattr(filters, 'host_state_up', False)
    setattr(filters, 'host_state_down', True)
    setattr(filters, 'host_state_unreach', True)
    setattr(filters, 'host_state_pending', False)

    setattr(filters, 'is_host_scheduled_downtime_depth_option', 'hard')
    setattr(filters, 'is_host_scheduled_downtime_depth', '0')

    setattr(filters, 'is_host_acknowledged_option', 'show')

    setattr(filters, 'is_summary_host_option', 'show')
    setattr(filters, 'is_summary_host', '0')

    setattr(filters, 'is_host_in_notification_period_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[5]
    view = View()
    view.title = 'Host problems'
    view.link_name = 'hostproblems'
    view.datasource = 'hosts'
    view.description = 'A complete list of all host problems with a search form for selecting handled and unhandled'
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('host_name', view, 'host')
    __add_column('host_state', view)
    __add_column('plugin_output', view)
    __add_column('num_services_ok', view)
    __add_column('num_services_warn', view)
    __add_column('num_services_crit', view)
    __add_column('num_services_unknown', view)
    __add_column('num_services_pending', view)

    ##########################################
    # Services problems

    filters = ViewFilters()
    setattr(filters, 'host_regex_option', 'show')

    setattr(filters, 'host_state_option', 'show')
    setattr(filters, 'host_state_up', True)
    setattr(filters, 'host_state_down', False)
    setattr(filters, 'host_state_unreach', False)
    setattr(filters, 'host_state_pending', True)

    setattr(filters, 'service_state_option', 'hard')
    setattr(filters, 'service_state_ok', False)
    setattr(filters, 'service_state_warning', True)
    setattr(filters, 'service_state_critical', True)
    setattr(filters, 'service_state_unknown', True)
    setattr(filters, 'service_state_pending', False)

    setattr(filters, 'is_host_scheduled_downtime_depth_option', 'hard')
    setattr(filters, 'is_host_scheduled_downtime_depth', '0')

    setattr(filters, 'is_service_acknowledged_option', 'show')
    setattr(filters, 'is_service_acknowledged', '-1')

    setattr(filters, 'is_summary_host_option', 'show')
    setattr(filters, 'is_summary_host', '0')

    setattr(filters, 'is_service_in_notification_period_option', 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[6]
    view = View()
    view.title = _('Service problems')
    view.link_name = 'svcproblems'
    view.datasource = 'services'
    view.description = 'All problems of services not currently in a downtime.'
    view.layout_number_columns = 1
    view.filters_id = filters.id
    db_session.add(view)
    db_session.commit()

    __add_column('host_name', view, 'host')
    __add_column('service_description', view, 'service')
    __add_column('service_plugin_output', view)
    __add_column('last_check', view)
Exemple #7
0
 def set_view_dummy(self, datasource):
     self.__view = View()
     self.__view.datasource = datasource
Exemple #8
0
class ViewManager():
    """ A sort of proxy that facilitate views modification and views queries. """
    def __init__(self):
        self.__view = None
        self.__columns = None
        self.__groupers = None
        self.__sorters = None
        self.__filters = None

    '''
    Set the view with the link_name. If a view is found, return the view found 
    '''

    def set_view(self, link_name):
        self.__view = View.query.filter_by(link_name=link_name).first()
        if self.__view:
            self.__columns = ViewColumn.query.filter_by(
                parent_id=self.__view.id).order_by(ViewColumn.id).all()
            self.__groupers = ViewGrouper.query.filter_by(
                parent_id=self.__view.id).order_by(ViewGrouper.id).all()
            self.__sorters = ViewSorter.query.filter_by(
                parent_id=self.__view.id).order_by(ViewSorter.id).all()
            self.__filters = self.__view.filters
            return self.__view
        else:
            return None

    def set_view_dummy(self, datasource):
        self.__view = View()
        self.__view.datasource = datasource

    def add_columns(self, columns, delete_before=False):
        if delete_before:
            for column in self.__columns:
                db_session.delete(column)

        for column in columns:
            db_session.add(column)

        db_session.commit()

    def add_groupers(self, groupers, delete_before=False):
        if delete_before:
            for grouper in self.__groupers:
                db_session.delete(grouper)

        for grouper in groupers:
            if grouper.column:
                db_session.add(grouper)

        db_session.commit()

    def add_sorters(self, sorters, delete_before=False):
        if delete_before:
            for sorter in self.__sorters:
                db_session.delete(sorter)

        for sorter in sorters:
            if sorter.column:
                db_session.add(sorter)

        db_session.commit()

    def add_view(self, view):
        db_session.add(view)
        db_session.commit()

    def add_filters(self, filters):
        self.__view.filters = filters
        db_session.commit()

    def set_filters(self, filters):
        self.__filters.set_filters(filters)

    def set_extra_sorters(self, sorters):
        for colname, order in sorters.items():
            sorter = ViewSorter()
            sorter.column = colname
            sorter.sorter_option = order
            [
                self.__sorters.remove(sorter_item)
                for sorter_item in self.__sorters
                if sorter_item.column == colname
            ]
            self.__sorters.append(sorter)

    def update_filters(self, filters):
        self.__view.filters.update(filters)
        db_session.commit()

    def get_filters(self):
        return self.__filters

    def get_hidden_filters(self):
        filters_tuples = []
        filters_obj = self.__filters
        for option, fil_col_names in cache_columns.iteritems():
            if getattr(filters_obj, option) == 'hide':
                filter_name = option.replace("_option", "")
                column_name = filters[filter_name].column_names
                filters_tuples.append((filter_name, column_name[0]))
        return filters_tuples

    def get_columns_choices(self):
        return get_columns_pairs(self.__view.datasource)

    def get_links_choices(self):
        views = View.query.all()
        links_choices = []
        links_choices.append(('', ''))
        for x in views:
            if x.link_title:
                if not self.__view or not self.__view.link_title == x.link_title:
                    links_choices.append((x.link_name, x.link_title))
            else:
                if not self.__view or not self.__view.link_name == x.link_name:
                    links_choices.append((x.link_name, x.title))

        return links_choices

    def get_columns(self):
        return self.__columns

    def get_sorters(self):
        return self.__sorters

    def get_sorters_columns(self):
        lst_columns = []
        for sorter in self.__sorters:
            lst_columns.append(sorter.column)
        return lst_columns

    def get_groupers(self):
        return self.__groupers

    def get_filter_display(self, form):
        lst_columns = cache_columns
        lst_info = []
        for option, fil_col_names in lst_columns.iteritems():
            filter_name = option.replace("_option", "")
            col_names = filters[filter_name].column_names
            filter_datasources = []
            for col_name in col_names:
                if painters.has_key(col_name):
                    filter_datasources = filter_datasources + painters[
                        col_name].datasources
                if self.__view.datasource in filter_datasources:
                    option_field = getattr(form, option)
                    fields = []
                    for col in fil_col_names:
                        fields.append(getattr(form, col))
                    lst_info.append(FilterFieldsInfo(option_field, fields))
        return lst_info

    def get_view(self):
        return self.__view

    def update_view(self, view):
        self.__view.update_view(view)
        db_session.commit()
Exemple #9
0
def create_default_views():
    filters = ViewFilters()
    for option, col_names in cache_columns.iteritems():
        setattr(filters, option, 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.first()
    view1 = View()
    view1.title = 'All hosts'
    view1.link_name = 'allhosts'
    view1.datasource = 'hosts'
    view1.filters_id = filters.id
    view1.layout_number_columns = 2
    db_session.add(view1)
    db_session.commit()
    view1 = (View.query.filter_by(link_name=view1.link_name).first())

    col1 = ViewColumn()
    col1.column = 'host_name'
    col1.parent_id = view1.id
    db_session.add(col1)

    col2 = ViewColumn()
    col2.column = 'host_state'
    col2.parent_id = view1.id
    db_session.add(col2)

    col3 = ViewColumn()
    col3.column = 'last_check'
    col3.parent_id = view1.id
    db_session.add(col3)
    db_session.commit()

    sort1 = ViewSorter()
    sort1.column = 'host_name'
    sort1.sorter_option = '1'
    sort1.parent_id = view1.id
    db_session.add(sort1)
    db_session.commit()

    group1 = ViewGrouper()
    group1.column = 'site'
    group1.parent_id = view1.id
    db_session.add(group1)
    db_session.commit()


    filters = ViewFilters()
    for option, col_names in cache_columns.iteritems():
        setattr(filters, option, 'show')

    db_session.add(filters)
    db_session.commit()

    filters = ViewFilters.query.all()[1]
    view2 = View()
    view2.title = 'All services'
    view2.link_name = 'allservices'
    view2.datasource = 'services'
    view2.layout_number_columns = 1
    view2.filters_id = filters.id
    db_session.add(view2)
    db_session.commit()

    col4 = ViewColumn()
    col4.column = 'service_description'
    col4.parent_id = view2.id
    db_session.add(col4)
    db_session.commit()

    col5 = ViewColumn()
    col5.column = 'service_state'
    col5.parent_id = view2.id
    db_session.add(col5)
    db_session.commit()