def __init__(self, type_logs): """ Open the specified file and use it as the stream for logging. """ # keep the absolute path, otherwise derived classes which use this # may come a cropper when the current directory changes self._name = "Database Handler" self.filters = [] self.lock = None cluster = Cluster.objects.get() try: logs_repository = cluster.system_settings.global_settings.repository if not logs_repository: for logs_repository in BaseAbstractRepository.get_data_repositories( ): if logs_repository.is_internal: break except: for logs_repository in BaseAbstractRepository.get_data_repositories( ): if logs_repository.is_internal: break if logs_repository.type_uri == 'mongodb': self.client = MongoDBClient(logs_repository) elif logs_repository.type_uri == 'elasticsearch': self.client = ElasticSearchClient(logs_repository) self.type_logs = type_logs
def __init__(self, *args, **kwargs): super(ModLogForm, self).__init__(*args, **kwargs) self = bootstrap_tooltips(self, exclude='repository_choices') repo_lst = BaseAbstractRepository.get_data_repositories() data_repo_lst = list() for rep in repo_lst: data_repo_lst.append(( rep.id, rep.repo_name, )) self.fields['repository_choices'] = ChoiceField(choices=data_repo_lst, required=False) repo_lst = BaseAbstractRepository.get_syslog_repositories() syslog_repo_lst = list() syslog_repo_lst.append(("", "")) for rep in repo_lst: syslog_repo_lst.append(( rep.id, rep.repo_name, )) self.fields['repository_syslog'] = ChoiceField(choices=syslog_repo_lst, required=False)
def __init__(self): cluster = Cluster.objects.get() for logs_repository in BaseAbstractRepository.get_data_repositories(): if logs_repository.is_internal: break self.log_rotate = cluster.system_settings.global_settings.log_rotate self.client = MongoDBClient(logs_repository)
def update(): cluster = Cluster.objects.get() for repo in BaseAbstractRepository.get_data_repositories(): if repo.is_internal: break cluster.system_settings.global_settings.logs_repository = repo.id cluster.save()
def __init__(self, *args, **kwargs): super(GLOBALSettingsForm, self).__init__(*args, **kwargs) self = bootstrap_tooltips(self) repo_lst = BaseAbstractRepository.get_data_repositories() data_repo_lst = [(repo.id, repo.repo_name) for repo in repo_lst] try: self.fields['logs_repository'] = ChoiceField(choices=data_repo_lst, required=True, widget=Select(attrs={'class': 'form-control'})) except: pass
def __init__(self, *args, **kwargs): super(PFSettingsForm, self).__init__(*args, **kwargs) self = bootstrap_tooltips(self, exclude='repository_choices') repo_lst = BaseAbstractRepository.get_data_repositories() data_repo_lst = list() for rep in repo_lst: data_repo_lst.append((rep.id, rep.repo_name)) self.fields['repository_choices'] = ChoiceField(choices=data_repo_lst, required=False, widget=Select(attrs={'class': 'form-control'})) repo_lst = BaseAbstractRepository.get_syslog_repositories() syslog_repo_lst = list() syslog_repo_lst.append(("","")) for rep in repo_lst: syslog_repo_lst.append((rep.id, rep.repo_name)) self.fields['repository_syslog'] = ChoiceField(choices=syslog_repo_lst, required=False, widget=Select(attrs={'class': 'form-control'})) self.fields['repository_type'] = ChoiceField(choices=PFSettings.TYPE_REPO, required=True, widget=Select(attrs={'class': 'form-control'}))
__doc__ = """This migration script update the names of collection and index""" import os import sys sys.path.append('/home/vlt-gui/vulture') os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'vulture.settings') import django django.setup() from gui.models.repository_settings import BaseAbstractRepository, MongoDBRepository, ElasticSearchRepository if __name__ == '__main__': repositories = BaseAbstractRepository.get_data_repositories() for repo in repositories: if isinstance(repo, MongoDBRepository): repo.db_packetfilter_collection_name = "vulture_pf" repo.db_diagnostic_collection_name = "vulture_diagnostic" repo.db_vulturelogs_collection_name = "vulture_logs" elif isinstance(repo, ElasticSearchRepository): repo.es_packetfilter_index_name = "vulture_pf" repo.es_packetfilter_type_name = "vulture_pf" repo.es_diagnostic_index_name = "vulture_diagnostic" repo.es_diagnostic_type_name = "vulture_diagnostic" repo.es_vulturelogs_index_name = "vulture_logs" repo.es_vulturelogs_type_name = "vulture_logs"