def create(request, taxii_id): if request.method != 'POST': return error_page_free_format(request, 'invalid method') #activeユーザー以外はエラー if request.user.is_active == False: return error_page_inactive(request) #is_admin権限なしの場合はエラー if request.user.is_admin == False: return error_page_no_view_permission(request) try: time = get_configuartion_taxii_client_detail_create_time(request) #mongoからtaxii_client情報を取得 taxii_client = TaxiiClients.objects.get(id=taxii_id) #Cron設定 times = time.split(':') schedule_job = taxii_client.add_job(type_=ScheduleJobs.JOB_CRON, hour=times[0], minute=times[1], second=times[2]) #job追加 client = Client(taxii_id=taxii_id) client.add_job(schedule_job) replace_dict = get_common_replace_dict(request) replace_dict['client'] = taxii_client #レンダリング return render(request, 'configuration_taxii_client_detail.html', replace_dict) except Exception: #エラーページ return error_page(request)
def interval(request, taxii_id): if request.method != 'GET': return error_page_free_format(request, 'invalid method') if not request.user.is_active: return error_page_inactive(request) if not request.user.is_admin: return error_page_no_view_permission(request) try: interval = get_configuartion_taxii_client_detail_interval_interval(request) taxii_client = TaxiiClients.objects.get(id=taxii_id) client = Client(taxii_client=taxii_client) client.remove_interval_job() taxii_client.interval_schedule_job = None taxii_client.save() if interval != 0: schedule_job = taxii_client.add_job(type_=ScheduleJobs.JOB_INTERVAL, seconds=interval) client.add_job(schedule_job) replace_dict = get_common_replace_dict(request) replace_dict['client'] = taxii_client if interval != 0: replace_dict['interval_info_msg'] = 'Set Interval %d sec' % (interval) else: replace_dict['interval_info_msg'] = 'Stop a job by interval' return render(request, 'configuration_taxii_client_detail.html', replace_dict) except Exception: return error_page(request)
def create(request, taxii_id): if request.method != 'POST': return error_page_free_format(request, 'invalid method') if not request.user.is_active: return error_page_inactive(request) if not request.user.is_admin: return error_page_no_view_permission(request) try: time = get_configuartion_taxii_client_detail_create_time(request) taxii_client = TaxiiClients.objects.get(id=taxii_id) times = time.split(':') schedule_job = taxii_client.add_job(type_=ScheduleJobs.JOB_CRON, hour=times[0], minute=times[1], second=times[2]) client = Client(taxii_client=taxii_client) client.add_job(schedule_job) replace_dict = get_common_replace_dict(request) replace_dict['client'] = taxii_client return render(request, 'configuration_taxii_client_detail.html', replace_dict) except Exception: return error_page(request)
def interval(request, taxii_id): if request.method != 'GET': return error_page_free_format(request, 'invalid method') #activeユーザー以外はエラー if request.user.is_active == False: return error_page_inactive(request) #is_admin権限なしの場合はエラー if request.user.is_admin == False: return error_page_no_view_permission(request) try: interval = get_configuartion_taxii_client_detail_interval_interval( request) #mongoからtaxii_client情報を取得 taxii_client = TaxiiClients.objects.get(id=taxii_id) client = Client(taxii_id=taxii_id) #稼働しているスケジューラの job があったら削除する client.remove_interval_job() #taxii_client の internal_schedule_jobs を Noneにする taxii_client.interval_schedule_job = None taxii_client.save() if interval != 0: #Cron設定 schedule_job = taxii_client.add_job( type_=ScheduleJobs.JOB_INTERVAL, seconds=interval) #job追加 client.add_job(schedule_job) replace_dict = get_common_replace_dict(request) replace_dict['client'] = taxii_client if interval != 0: replace_dict['interval_info_msg'] = 'Set Interval %d sec' % ( interval) else: replace_dict['interval_info_msg'] = 'Stop a job by interval' #レンダリング return render(request, 'configuration_taxii_client_detail.html', replace_dict) except Exception: #エラーページ return error_page(request)