From f42944e0769e1514524dfe4ad348ab95dd1503ae Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 15:28:26 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BB=BB=E5=8A=A1=E6=B5=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 views/server.py | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/views/server.py b/views/server.py
index 121993a..d36f013 100644
--- a/views/server.py
+++ b/views/server.py
@@ -1,4 +1,6 @@
 import json
+from datetime import datetime
+
 from connect_sql import DBHelper
 
 def import_host_info(data):
@@ -20,4 +22,32 @@ def import_host_info(data):
         agent_username = i.get('agent_hostname')
         agent_passwd = i.get('agent_password')
         val = ((agent_ip, agent_username, agent_passwd),)
-        DBHelper().insert(sql, val)
\ No newline at end of file
+        DBHelper().insert(sql, val)
+
+
+
+
+def get_agent_id(agent_ip):
+    """
+    获取agent_id
+    :param agent_ip:
+    :return:
+    """
+    sql = "select agent_id from agent_info where agent_ip='%s'" % agent_ip
+    get_agent_id = DBHelper().execute(sql).fetchall()
+    return get_agent_id[0][0]
+
+
+def create_task_stream(agent_ip):
+    """
+    创建任务流
+    :return:
+    """
+    create_task_stream_sql = "insert into task_stream(agent_ip,agent_id,stream_status," \
+                             "stream_CreateTime,stream_Updatetime) values (%s, %s, %s, %s, %s);"
+
+    stream_status = 'None'
+    agent_id = get_agent_id(agent_ip)
+    time = datetime.now().strftime('%Y-%-m-%d %H:%M:%S')
+    values = ((agent_ip, agent_id, stream_status, time, time),)
+    DBHelper().insert(create_task_stream_sql, values)
\ No newline at end of file
-- 
2.20.1

