migration-tools/0008-add-agent_info-table-in-database.patch

98 lines
3.4 KiB
Diff
Raw Normal View History

2024-11-04 10:57:54 +08:00
From dbca836df232ed21f05798878dfb1773501fd4c2 Mon Sep 17 00:00:00 2001
From: lixin <lixinb@uniontech.com>
Date: Thu, 9 Nov 2023 14:16:49 +0800
Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=B7=BB=E5=8A=A0ag?=
=?UTF-8?q?ent=5Finfo=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uos-sysmig.sql | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
views/server.py | 10 +++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 uos-sysmig.sql
diff --git a/uos-sysmig.sql b/uos-sysmig.sql
new file mode 100644
index 0000000..eaf8aed
--- /dev/null
+++ b/uos-sysmig.sql
@@ -0,0 +1,52 @@
+-- MySQL dump 10.13 Distrib 8.0.27, for Linux (x86_64)
+--
+-- Host: 10.12.21.200 Database: uos-sysmig
+-- ------------------------------------------------------
+-- Server version 8.0.27
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!50503 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `agent_info`
+--
+
+DROP TABLE IF EXISTS `agent_info`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!50503 SET character_set_client = utf8mb4 */;
+CREATE TABLE `agent_info` (
+ `agent_id` int NOT NULL AUTO_INCREMENT,
+ `agent_ip` varchar(256) NOT NULL,
+ `agent_username` varchar(256) NOT NULL,
+ `agent_passwd` varbinary(256) NOT NULL,
+ `hostname` varchar(256) DEFAULT NULL,
+ `agent_os` varchar(256) DEFAULT NULL,
+ `agent_arch` varchar(45) DEFAULT NULL,
+ `agent_storage` int DEFAULT NULL,
+ `agent_kernel` varchar(45) DEFAULT NULL,
+ `agent_repo_kernel` varchar(256) DEFAULT NULL,
+ `agent_migration_os` varchar(256) DEFAULT NULL,
+ `agent_history_faild_reason` varchar(45) DEFAULT NULL,
+ `agent_online_status` int DEFAULT '0',
+ `repo_status` int DEFAULT NULL,
+ PRIMARY KEY (`agent_id`),
+ KEY `agent_ip` (`agent_ip`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping data for table `agent_info`
+--
+
+LOCK TABLES `agent_info` WRITE;
+/*!40000 ALTER TABLE `agent_info` DISABLE KEYS */;
+/*!40000 ALTER TABLE `agent_info` ENABLE KEYS */;
+UNLOCK TABLES;
\ No newline at end of file
diff --git a/views/server.py b/views/server.py
index 764d5bd..65ddba9 100644
--- a/views/server.py
+++ b/views/server.py
@@ -10,4 +10,12 @@ def import_host_info(data):
if not agent_info:
data = {"data": "faild"}
json_data = json.dumps(data)
- return json_data
\ No newline at end of file
+ return json_data
+
+
+ sql = "insert into agent_info(agent_ip, agent_username, agent_passwd) values (%s, %s, AES_ENCRYPT(%s, 'coco'));"
+ for i in agent_info:
+ agent_ip = i.get('agent_ip')
+ agent_username = i.get('agent_hostname')
+ agent_passwd = i.get('agent_password')
+ val = ((agent_ip, agent_username, agent_passwd),)
\ No newline at end of file
--
2.20.1