Commit e63dfaf1 authored by 김진영's avatar 김진영
Browse files

Update batch_test.py

parent 52ac04e6
from datetime import datetime, timedelta from datetime import datetime, timedelta
from textwrap import dedent from textwrap import dedent
import pendulum import pendulum
from airflow.operators.bash import BashOperator
# The DAG object; we'll need this to instantiate a DAG
from airflow import DAG from airflow import DAG
local_tz = pendulum.timezone("Asia/Seoul") local_tz = pendulum.timezone("Asia/Seoul")
# Operators; we need this to operate! # gasan 데이터 선언
from airflow.operators.bash import BashOperator gasan_data = [
{
"ip": "10.231.130.110",
"serialNum": "7D0B3C9PAGFCF3C",
"camName": "dt_lab_1"
},
{
"ip": "10.231.130.111",
"serialNum": "7D0B3C9PAG8D150",
"camName": "dt_lab_2"
},
{
"ip": "10.231.130.112",
"serialNum": "7D0B3C9PAGBB838",
"camName": "dt_lab_3"
},
{
"ip": "10.231.130.113",
"serialNum": "7D0B3C9PAG17F50",
"camName": "dt_lab_4"
},
]
with DAG( with DAG(
'batch_test', 'batch_test',
default_args={ default_args={
...@@ -24,13 +45,12 @@ with DAG( ...@@ -24,13 +45,12 @@ with DAG(
# gasan 작업 병렬처리 # gasan 작업 병렬처리
post_gasan_tasks = [] post_gasan_tasks = []
for i in range(4): for i, data in enumerate(gasan_data):
post_gasan_task = BashOperator( post_gasan_task = BashOperator(
task_id='post_gasan'+str(i), task_id='post_gasan'+str(i),
bash_command="curl -X \'POST\' \'http://10.231.238.224:30999/api/v1/camera/writeimage\' -H \'Content-Type: application/json\' -d \'{\"id\": \"test%s\", \"pw\": \"test\", \"ip\": \"10.123.123.1\", \"serialNum\": \"aaaa\", \"camName\": \"abc\"}\'" %(str(i)), bash_command="curl -X \'POST\' \'http://10.231.238.224:30999/api/v1/camera/writeimage\' -H \'Content-Type: application/json\' -d \'{\"id\": \"test%s\", \"pw\": \"test\", \"ip\": \"%s\", \"serialNum\": \"%s\", \"camName\": \"%s\"}\'" %(str(i), data["ip"], data["serialNum"], data["camName"]),
) )
post_gasan_tasks.append(post_gasan_task) post_gasan_tasks.append(post_gasan_task)
post_gasan_tasks post_gasan_tasks
# t1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment